source: node_modules/minimist/test/dash.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1'use strict';
2
3var parse = require('../');
4var test = require('tape');
5
6test('-', function (t) {
7 t.plan(6);
8 t.deepEqual(parse(['-n', '-']), { n: '-', _: [] });
9 t.deepEqual(parse(['--nnn', '-']), { nnn: '-', _: [] });
10 t.deepEqual(parse(['-']), { _: ['-'] });
11 t.deepEqual(parse(['-f-']), { f: '-', _: [] });
12 t.deepEqual(
13 parse(['-b', '-'], { boolean: 'b' }),
14 { b: true, _: ['-'] }
15 );
16 t.deepEqual(
17 parse(['-s', '-'], { string: 's' }),
18 { s: '-', _: [] }
19 );
20});
21
22test('-a -- b', function (t) {
23 t.plan(2);
24 t.deepEqual(parse(['-a', '--', 'b']), { a: true, _: ['b'] });
25 t.deepEqual(parse(['--a', '--', 'b']), { a: true, _: ['b'] });
26});
27
28test('move arguments after the -- into their own `--` array', function (t) {
29 t.plan(1);
30 t.deepEqual(
31 parse(['--name', 'John', 'before', '--', 'after'], { '--': true }),
32 { name: 'John', _: ['before'], '--': ['after'] }
33 );
34});
35
36test('--- option value', function (t) {
37 // A multi-dash value is largely an edge case, but check the behaviour is as expected,
38 // and in particular the same for short option and long option (as made consistent in Jan 2023).
39 t.plan(2);
40 t.deepEqual(parse(['-n', '---']), { n: '---', _: [] });
41 t.deepEqual(parse(['--nnn', '---']), { nnn: '---', _: [] });
42});
43
Note: See TracBrowser for help on using the repository browser.