UNPKG

746 BJavaScriptView Raw
1'use strict'
2const TestRunner = require('test-runner')
3const commandLineArgs = require('../')
4const a = require('assert')
5
6const runner = new TestRunner()
7
8runner.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})