initial
This commit is contained in:
44
node_modules/command-line-args/test/ambiguous-input.js
generated
vendored
Normal file
44
node_modules/command-line-args/test/ambiguous-input.js
generated
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
'use strict'
|
||||
const TestRunner = require('test-runner')
|
||||
const commandLineArgs = require('../')
|
||||
const a = require('assert')
|
||||
|
||||
const runner = new TestRunner()
|
||||
|
||||
runner.test('ambiguous input: value looks like an option 1', function () {
|
||||
const optionDefinitions = [
|
||||
{ name: 'colour', type: String, alias: 'c' }
|
||||
]
|
||||
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv: [ '-c', 'red' ] }), {
|
||||
colour: 'red'
|
||||
})
|
||||
})
|
||||
|
||||
runner.test('ambiguous input: value looks like an option 2', function () {
|
||||
const optionDefinitions = [
|
||||
{ name: 'colour', type: String, alias: 'c' }
|
||||
]
|
||||
const argv = [ '--colour', '--red' ]
|
||||
a.throws(
|
||||
() => commandLineArgs(optionDefinitions, { argv }),
|
||||
err => err.name === 'UNKNOWN_OPTION'
|
||||
)
|
||||
})
|
||||
|
||||
runner.test('ambiguous input: value looks like an option 3', function () {
|
||||
const optionDefinitions = [
|
||||
{ name: 'colour', type: String, alias: 'c' }
|
||||
]
|
||||
a.doesNotThrow(function () {
|
||||
commandLineArgs(optionDefinitions, { argv: [ '--colour=--red' ] })
|
||||
})
|
||||
})
|
||||
|
||||
runner.test('ambiguous input: value looks like an option 4', function () {
|
||||
const optionDefinitions = [
|
||||
{ name: 'colour', type: String, alias: 'c' }
|
||||
]
|
||||
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv: [ '--colour=--red' ] }), {
|
||||
colour: '--red'
|
||||
})
|
||||
})
|
Reference in New Issue
Block a user