Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
f8aa80ac
Commit
f8aa80ac
authored
Jun 10, 2015
by
antirek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests
parent
cceeaea7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
23 deletions
+16
-23
app.js
app.js
+10
-0
context.js
lib/context.js
+2
-2
index.js
test/index.js
+4
-21
No files found.
app.js
0 → 100644
View file @
f8aa80ac
var
ding
=
require
(
'
./lib/index
'
);
var
handler
=
function
(
context
)
{
context
.
onEvent
(
'
variables
'
)
.
then
(
function
(
vars
)
{
return
context
.
streamFile
(
'
beep
'
);
});
};
ding
.
createServer
(
handler
).
listen
(
3000
);
lib/context.js
View file @
f8aa80ac
...
@@ -234,7 +234,7 @@ Context.prototype.sendImage = function (image) {
...
@@ -234,7 +234,7 @@ Context.prototype.sendImage = function (image) {
};
};
Context
.
prototype
.
sendText
=
function
(
text
)
{
Context
.
prototype
.
sendText
=
function
(
text
)
{
return
this
.
sendCommand
(
'
SEND TEXT "
'
+
text
);
return
this
.
sendCommand
(
'
SEND TEXT "
'
+
text
+
'
"
'
);
};
};
Context
.
prototype
.
channelStatus
=
function
(
name
)
{
Context
.
prototype
.
channelStatus
=
function
(
name
)
{
...
@@ -305,7 +305,7 @@ Context.prototype.sayPhonetic = function (string, escape_digits) {
...
@@ -305,7 +305,7 @@ Context.prototype.sayPhonetic = function (string, escape_digits) {
Context
.
prototype
.
streamFile
=
function
(
filename
,
digits
)
{
Context
.
prototype
.
streamFile
=
function
(
filename
,
digits
)
{
var
acceptDigits
=
digits
?
digits
:
"
1234567890#*
"
;
var
acceptDigits
=
digits
?
digits
:
"
1234567890#*
"
;
return
this
.
sendCommand
(
'
STREAM FILE "
'
+
filename
+
'
" "
'
+
acceptDigits
+
'
"
\n
'
);
return
this
.
sendCommand
(
'
STREAM FILE "
'
+
filename
+
'
" "
'
+
acceptDigits
+
'
"
'
);
};
};
Context
.
prototype
.
waitForDigit
=
function
(
timeoutIn
)
{
Context
.
prototype
.
waitForDigit
=
function
(
timeoutIn
)
{
...
...
test/index.js
View file @
f8aa80ac
...
@@ -311,18 +311,7 @@ describe('Context', function() {
...
@@ -311,18 +311,7 @@ describe('Context', function() {
it
(
'
sends correct command
'
,
function
()
{
it
(
'
sends correct command
'
,
function
()
{
this
.
context
.
getVariable
(
'
test
'
);
this
.
context
.
getVariable
(
'
test
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
GET VARIABLE test
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
GET VARIABLE test
\n
'
);
});
});
it
(
'
gets result
'
,
function
(
done
)
{
this
.
context
.
getVariable
(
'
test
'
,
function
(
err
,
res
)
{
expect
(
res
.
result
).
eql
(
'
1 (abcd)
'
);
done
();
});
var
self
=
this
;
process
.
nextTick
(
function
()
{
self
.
context
.
stream
.
write
(
'
200 result=1 (abcd)
\n
'
);
})
});
});
});
describe
(
'
receiveChar
'
,
function
()
{
describe
(
'
receiveChar
'
,
function
()
{
...
@@ -343,13 +332,7 @@ describe('Context', function() {
...
@@ -343,13 +332,7 @@ describe('Context', function() {
it
(
'
sends
'
,
function
()
{
it
(
'
sends
'
,
function
()
{
this
.
context
.
streamFile
(
'
test
'
,
'
1234567890#*
'
,
function
()
{});
this
.
context
.
streamFile
(
'
test
'
,
'
1234567890#*
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
STREAM FILE "test" "1234567890#*"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
STREAM FILE "test" "1234567890#*"
\n
'
);
});
});
it
(
'
defaults to all digits
'
,
function
()
{
this
.
context
.
streamFile
(
'
test
'
,
function
()
{});
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
STREAM FILE "test" "1234567890#*"
\n
'
);
});
});
});
describe
(
'
record file
'
,
function
()
{
describe
(
'
record file
'
,
function
()
{
...
@@ -424,14 +407,14 @@ describe('Context', function() {
...
@@ -424,14 +407,14 @@ describe('Context', function() {
describe
(
'
send text
'
,
function
()
{
describe
(
'
send text
'
,
function
()
{
it
(
'
send text
'
,
function
()
{
it
(
'
send text
'
,
function
()
{
this
.
context
.
sendText
(
'
1234
'
,
function
()
{}
);
this
.
context
.
sendText
(
'
1234
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SEND TEXT "1234"
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
SEND TEXT "1234"
\n
'
);
});
});
});
});
describe
(
'
waitForDigit
'
,
function
()
{
describe
(
'
waitForDigit
'
,
function
()
{
it
(
'
sends with default timeout
'
,
function
()
{
it
(
'
sends with default timeout
'
,
function
()
{
this
.
context
.
waitForDigit
(
function
()
{}
);
this
.
context
.
waitForDigit
();
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
WAIT FOR DIGIT 5000
\n
'
);
expect
(
this
.
context
.
sent
.
join
(
''
)).
to
.
eql
(
'
WAIT FOR DIGIT 5000
\n
'
);
});
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment