-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.js
More file actions
53 lines (43 loc) · 1.13 KB
/
Copy pathtest.js
File metadata and controls
53 lines (43 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
require('should');
var cps = require('./index');
describe('cps', function () {
function answer() {
return 42;
}
function divide(a, b) {
if (b === 0) {
throw Error('b is 0');
}
return a / b;
}
function sayHello(name) {
name = name || 'world';
return 'hello ' + name;
}
it('should work on function with no arguments', function () {
cps(answer)(function (err, res) {
(!err).should.be.true;
res.should.eql(answer());
});
});
it('should work on functions with several arguments', function () {
cps(divide)(4, 2, function (err, res) {
(!err).should.be.true;
res.should.eql(divide(4, 2));
});
});
it('should provide errors in first argument for callback', function () {
cps(divide)(4, 0, function (err, res) {
err.should.be.ok;
(!res).should.be.true;
});
});
it('should fail if no callback provided in last argument', function () {
cps(divide).bind(4, 2).should.throw();
});
it('should properly handle default arguments', function () {
cps(sayHello)(function (err, res) {
res.should.eql(sayHello());
});
});
});