Skip to content

Commit 9147cf7

Browse files
committed
chore: import addl tests
1 parent de14115 commit 9147cf7

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎test/index.js‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,9 @@ test('multiAlias', t => {
219219
// t.same(argv.beep, { boop : true });
220220
// t.end();
221221
// });
222+
223+
test('parse with modifier functions' , t => {
224+
const argv = fn(['-b', '123'], { boolean:'b' });
225+
t.same(argv, { b:true, _:[123] });
226+
t.end();
227+
});

‎test/num.js‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const test = require('tape');
2+
const fn = require('../lib');
3+
4+
test('nums', t => {
5+
const argv = fn([
6+
'-x', '1234',
7+
'-y', '5.67',
8+
'-z', '1e7',
9+
'-w', '10f',
10+
'--hex', '0xdeadbeef',
11+
'789'
12+
]);
13+
t.same(argv, {
14+
x : 1234,
15+
y : 5.67,
16+
z : 1e7,
17+
w : '10f',
18+
hex : 0xdeadbeef,
19+
_ : ['789']
20+
});
21+
t.is(typeof argv.x, 'number');
22+
t.is(typeof argv.y, 'number');
23+
t.is(typeof argv.z, 'number');
24+
t.is(typeof argv.w, 'string');
25+
t.is(typeof argv.hex, 'number');
26+
t.is(typeof argv._[0], 'string');
27+
t.end();
28+
});
29+
30+
test('already a number', t => {
31+
const argv = fn(['-x', 1234, 789]);
32+
t.same(argv, { x:1234, _:[789] });
33+
t.is(typeof argv._[0], 'number');
34+
t.is(typeof argv.x, 'number');
35+
t.end();
36+
});

0 commit comments

Comments
 (0)