source: trip-planner-front/node_modules/minimist/test/short.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.6 KB
Line 
1var parse = require('../');
2var test = require('tape');
3
4test('numeric short args', function (t) {
5 t.plan(2);
6 t.deepEqual(parse([ '-n123' ]), { n: 123, _: [] });
7 t.deepEqual(
8 parse([ '-123', '456' ]),
9 { 1: true, 2: true, 3: 456, _: [] }
10 );
11});
12
13test('short', function (t) {
14 t.deepEqual(
15 parse([ '-b' ]),
16 { b : true, _ : [] },
17 'short boolean'
18 );
19 t.deepEqual(
20 parse([ 'foo', 'bar', 'baz' ]),
21 { _ : [ 'foo', 'bar', 'baz' ] },
22 'bare'
23 );
24 t.deepEqual(
25 parse([ '-cats' ]),
26 { c : true, a : true, t : true, s : true, _ : [] },
27 'group'
28 );
29 t.deepEqual(
30 parse([ '-cats', 'meow' ]),
31 { c : true, a : true, t : true, s : 'meow', _ : [] },
32 'short group next'
33 );
34 t.deepEqual(
35 parse([ '-h', 'localhost' ]),
36 { h : 'localhost', _ : [] },
37 'short capture'
38 );
39 t.deepEqual(
40 parse([ '-h', 'localhost', '-p', '555' ]),
41 { h : 'localhost', p : 555, _ : [] },
42 'short captures'
43 );
44 t.end();
45});
46
47test('mixed short bool and capture', function (t) {
48 t.same(
49 parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
50 {
51 f : true, p : 555, h : 'localhost',
52 _ : [ 'script.js' ]
53 }
54 );
55 t.end();
56});
57
58test('short and long', function (t) {
59 t.deepEqual(
60 parse([ '-h', 'localhost', '-fp', '555', 'script.js' ]),
61 {
62 f : true, p : 555, h : 'localhost',
63 _ : [ 'script.js' ]
64 }
65 );
66 t.end();
67});
Note: See TracBrowser for help on using the repository browser.