Spaces:
Sleeping
Sleeping
File size: 1,647 Bytes
be5030f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
'use strict'
const TestRunner = require('test-runner')
const commandLineArgs = require('../')
const a = require('assert')
const runner = new TestRunner()
runner.test('defaultOption: multiple string', function () {
const optionDefinitions = [
{ name: 'files', defaultOption: true, multiple: true }
]
const argv = [ 'file1', 'file2' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
files: [ 'file1', 'file2' ]
})
})
runner.test('defaultOption: after a boolean', function () {
const definitions = [
{ name: 'one', type: Boolean },
{ name: 'two', defaultOption: true }
]
a.deepStrictEqual(
commandLineArgs(definitions, { argv: [ '--one', 'sfsgf' ] }),
{ one: true, two: 'sfsgf' }
)
})
runner.test('defaultOption: multiple-defaultOption values spread out', function () {
const optionDefinitions = [
{ name: 'one' },
{ name: 'two' },
{ name: 'files', defaultOption: true, multiple: true }
]
const argv = [ '--one', '1', 'file1', 'file2', '--two', '2' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
one: '1',
two: '2',
files: [ 'file1', 'file2' ]
})
})
runner.test('defaultOption: multiple-defaultOption values spread out 2', function () {
const optionDefinitions = [
{ name: 'one', type: Boolean },
{ name: 'two' },
{ name: 'files', defaultOption: true, multiple: true }
]
const argv = [ 'file0', '--one', 'file1', '--files', 'file2', '--two', '2', 'file3' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
one: true,
two: '2',
files: [ 'file0', 'file1', 'file2', 'file3' ]
})
})
|