option.chain.test.js
This file
Path
tests/option.chain.test.js
53 lines · 1.7 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354import { Option } from '../index.js';import { test, describe } from 'node:test';import assert from 'node:assert/strict';
describe('Option methods that should return this for chaining', () => { test('when call .default() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.default(3); assert.equal(result, option); });
test('when call .argParser() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.argParser(() => {}); assert.equal(result, option); });
test('when call .makeOptionMandatory() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.makeOptionMandatory(); assert.equal(result, option); });
test('when call .hideHelp() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.hideHelp(); assert.equal(result, option); });
test('when call .choices() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.choices(['a']); assert.equal(result, option); });
test('when call .env() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.env('e'); assert.equal(result, option); });
test('when call .conflicts() then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.conflicts(['a']); assert.equal(result, option); });
test('when call .helpGroup(heading) then returns this', () => { const option = new Option('-e,--example <value>'); const result = option.helpGroup('Options:'); assert.equal(result, option); });});