-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
57 lines (47 loc) · 1.02 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
54
55
56
57
var namespace = require('tessed').namespace
var command = require('./index')
var alias = require('@cli/alias')
var handler = require('@cli/handler')
var test = namespace('command')
test('command()', function (t) {
var fn1 = function () {}
var c = command(
alias('test'),
handler(fn1)
)
t.equal(typeof c, 'function', 'returns a function')
t.deepEqual(c(), {
type: 'command',
value: {
alias: ['test'],
'handler': [fn1]
},
options: undefined
}, 'basic execution')
t.deepEqual(c({key: 'value'}), {
type: 'command',
value: {
alias: ['test'],
'handler': [fn1]
},
options: {key: 'value'}
}, 'with options')
})
test('combines multiple values', function (t) {
var fn1 = function () {}
var fn2 = function () {}
var c = command(
alias('one'),
alias('two'),
handler(fn1),
handler(fn2)
)
t.deepEqual(c(), {
type: 'command',
value: {
alias: ['one', 'two'],
'handler': [fn1, fn2]
},
options: undefined
}, 'values')
})