-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
53 lines (40 loc) · 1.28 KB
/
test.js
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
const assume = require('assume');
const optionalOpts = require('./index');
describe('optional-options', function() {
let optOpts;
beforeEach(function() {
optOpts = optionalOpts();
});
it('returns a function', function() {
assume(optOpts).is.a('function');
});
it('returns options and callback if they are both passed in', function() {
const opts = {};
const cb = function() {};
const result = optOpts(opts, cb);
assume(result.options).equals(opts);
assume(result.callback).equals(cb);
});
it('returns the callback if it is the only thing passed in', function() {
const cb = function() {};
const result = optOpts(cb);
assume(result.options).eqls({});
assume(result.callback).equals(cb);
});
it('allows the options key to be set', function() {
optOpts = optionalOpts('opts');
const opts = {};
const cb = function() {};
const result = optOpts(opts, cb);
assume(result.opts).equals(opts);
assume(result.callback).equals(cb);
});
it('allows the callback key to be set', function() {
optOpts = optionalOpts('options', 'next');
const opts = {};
const cb = function() {};
const result = optOpts(opts, cb);
assume(result.options).equals(opts);
assume(result.next).equals(cb);
});
});