Skip to content

Commit

Permalink
extra alias test
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Jun 19, 2018
1 parent 749a904 commit 827ba1e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 17 deletions.
51 changes: 51 additions & 0 deletions test/alias-cluster.js
@@ -0,0 +1,51 @@
'use strict'
const TestRunner = require('test-runner')
const commandLineArgs = require('../')
const a = require('assert')

const runner = new TestRunner()

runner.test('alias-cluster: two flags, one option', function () {
const optionDefinitions = [
{ name: 'flagA', alias: 'a', type: Boolean },
{ name: 'flagB', alias: 'b', type: Boolean },
{ name: 'three', alias: 'c' }
]

const argv = [ '-abc', 'yeah' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
flagA: true,
flagB: true,
three: 'yeah'
})
})

runner.test('alias-cluster: two flags, one option 2', function () {
const optionDefinitions = [
{ name: 'flagA', alias: 'a', type: Boolean },
{ name: 'flagB', alias: 'b', type: Boolean },
{ name: 'three', alias: 'c' }
]

const argv = [ '-c', 'yeah', '-ab' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
flagA: true,
flagB: true,
three: 'yeah'
})
})

runner.test('alias-cluster: three string options', function () {
const optionDefinitions = [
{ name: 'flagA', alias: 'a' },
{ name: 'flagB', alias: 'b' },
{ name: 'three', alias: 'c' }
]

const argv = [ '-abc', 'yeah' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
flagA: null,
flagB: null,
three: 'yeah'
})
})
19 changes: 2 additions & 17 deletions test/notations.js → test/option=value-notation.js
Expand Up @@ -5,22 +5,7 @@ const a = require('assert')

const runner = new TestRunner()

runner.test('getOpt short notation: two flags, one option', function () {
const optionDefinitions = [
{ name: 'flagA', alias: 'a' },
{ name: 'flagB', alias: 'b' },
{ name: 'three', alias: 'c' }
]

const argv = [ '-abc', 'yeah' ]
a.deepStrictEqual(commandLineArgs(optionDefinitions, { argv }), {
flagA: null,
flagB: null,
three: 'yeah'
})
})

runner.test('option=value notation: two plus a regular notation', function () {
runner.test('--option=value notation: two plus a regular notation', function () {
const optionDefinitions = [
{ name: 'one' },
{ name: 'two' },
Expand All @@ -34,7 +19,7 @@ runner.test('option=value notation: two plus a regular notation', function () {
a.strictEqual(result.three, '3')
})

runner.test('option=value notation: value contains "="', function () {
runner.test('--option=value notation: value contains "="', function () {
const optionDefinitions = [
{ name: 'url' },
{ name: 'two' },
Expand Down

0 comments on commit 827ba1e

Please sign in to comment.