-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.js
58 lines (45 loc) · 1.14 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
58
const w = require('whew')
const assert = require('assert')
const gar = require('./')
w.add('-h hey --toggle -ac --hey=hi -spaced "hey there" -num 1 lone', (result) => {
const parsed = gar(['-h', 'hey', '--toggle', '-ac', '--hey=hi', '-spaced', 'hey there', '-num', '1', 'lone'])
assert.deepStrictEqual(parsed, {
'h': 'hey',
'toggle': true,
'a': true,
'c': true,
'hey': 'hi',
'spaced': 'hey there',
'num': 1,
'_': ['lone']
})
result(true, 'Object matched expected!')
})
w.add('lone --toggle -xyz', (result) => {
const parsed = gar(['lone', '--toggle', '-xyz'])
assert.deepStrictEqual(parsed, {
'toggle': true,
'x': true,
'y': true,
'z': true,
'_': ['lone']
})
result(true, 'Object matched expected!')
})
w.add('lone --toggle TRUE -xyz', (result) => {
const parsed = gar(['lone', '--toggle', 'TRUE', '-xyz'])
assert.deepStrictEqual(parsed, {
'toggle': true,
'x': true,
'y': true,
'z': true,
'_': ['lone']
})
result(true, 'Object matched expected!')
})
w.add('No arguments', (result) => {
const parsed = gar([])
assert.deepStrictEqual(parsed, {'_' : []})
result(true, 'Object matched expected!')
})
w.test()