29 lines
848 B
JavaScript
Raw Normal View History

2018-05-16 10:10:23 +02:00
'use strict'
const TestRunner = require('test-runner')
const a = require('assert')
const Definitions = require('../../lib/option-definitions')
const runner = new TestRunner()
runner.test('.get(long option)', function () {
const definitions = Definitions.from([ { name: 'one' } ])
a.strictEqual(definitions.get('--one').name, 'one')
})
runner.test('.get(short option)', function () {
const definitions = Definitions.from([ { name: 'one', alias: 'o' } ])
a.strictEqual(definitions.get('-o').name, 'one')
})
runner.test('.get(name)', function () {
const definitions = Definitions.from([ { name: 'one' } ])
a.strictEqual(definitions.get('one').name, 'one')
})
runner.test('.validate()', function () {
a.throws(function () {
const definitions = new Definitions()
definitions.load([ { name: 'one' }, { name: 'one' } ])
})
})