UNPKG

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