1 | 'use strict'
|
2 | const TestRunner = require('test-runner')
|
3 | const commandLineArgs = require('../')
|
4 | const a = require('assert')
|
5 |
|
6 | const runner = new TestRunner()
|
7 |
|
8 | const optionDefinitions = [
|
9 | { name: 'verbose', alias: 'v' },
|
10 | { name: 'colour', alias: 'c' },
|
11 | { name: 'number', alias: 'n' },
|
12 | { name: 'dry-run', alias: 'd' }
|
13 | ]
|
14 |
|
15 | runner.test('alias: one boolean', function () {
|
16 | const argv = [ '-v' ]
|
17 | a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
|
18 | verbose: null
|
19 | })
|
20 | })
|
21 |
|
22 | runner.test('alias: one --this-type boolean', function () {
|
23 | const argv = [ '-d' ]
|
24 | a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
|
25 | 'dry-run': null
|
26 | })
|
27 | })
|
28 |
|
29 | runner.test('alias: one boolean, one string', function () {
|
30 | const argv = [ '-v', '-c' ]
|
31 | a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
|
32 | verbose: null,
|
33 | colour: null
|
34 | })
|
35 | })
|