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 | runner.test('ambiguous input: value looks like option', function () {
|
9 | const optionDefinitions = [
|
10 | { name: 'colour', type: String, alias: 'c' }
|
11 | ]
|
12 | a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv: [ '-c', 'red' ] }), {
|
13 | colour: 'red'
|
14 | })
|
15 | a.throws(function () {
|
16 | commandLineArgs(optionDefinitions, { argv: [ '--colour', '--red' ] })
|
17 | })
|
18 | a.doesNotThrow(function () {
|
19 | commandLineArgs(optionDefinitions, { argv: [ '--colour=--red' ] })
|
20 | })
|
21 | a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv: [ '--colour=--red' ] }), {
|
22 | colour: '--red'
|
23 | })
|
24 | })
|