options.dual-options.test.js
This file
Path
tests/options.dual-options.test.js
99 lines · 3.8 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–4why, one step back1import { Option, DualOptions } from '../lib/option.js';2import { Command } from '../index.js';3import { test, describe } from 'node:test';4import assert from 'node:assert/strict';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 5–7why, one step back56// This tests an internal helper class which is not currently exposed on the package.7Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 8–16why, one step back8describe('DualOptions internal helper class', () => {9 test('when positive option then stored in positiveOptions', () => {10 const program = new Command();11 program.option('--one');12 const helper = new DualOptions(program.options);13 assert.equal(helper.positiveOptions.size, 1);14 assert.equal(helper.negativeOptions.size, 0);15 assert.equal(helper.dualOptions.size, 0);16 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 17why, one step back17Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 18–25why, one step back18 test('when negative option then stored in negativeOptions', () => {19 const program = new Command();20 program.option('--no-one');21 const helper = new DualOptions(program.options);22 assert.equal(helper.positiveOptions.size, 0);23 assert.equal(helper.negativeOptions.size, 1);24 assert.equal(helper.dualOptions.size, 0);25 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 26why, one step back26Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 27–32why, one step back27 test('when unrelated positive and negative options then no dual options', () => {28 const program = new Command();29 program.option('--one').option('--no-two');30 const helper = new DualOptions(program.options);31 assert.equal(helper.dualOptions.size, 0);32 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 33why, one step back33Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 34–39why, one step back34 test('when related positive and negative options then stored as dual option', () => {35 const program = new Command();36 program.option('--one').option('--no-one');37 const helper = new DualOptions(program.options);38 assert.equal(helper.dualOptions.size, 1);39 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 40why, one step back40Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 41–46why, one step back41 test('when related negative and positive options then stored as dual option', () => {42 const program = new Command();43 program.option('--no-one').option('--one');44 const helper = new DualOptions(program.options);45 assert.equal(helper.dualOptions.size, 1);46 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 47why, one step back47Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 48–51why, one step back48 describe('valueFromOption with boolean option', () => {49 const positiveOption = new Option('--one');50 const negativeOption = new Option('--no-one');51 const options = [positiveOption, negativeOption];Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 52why, one step back52Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 53–56why, one step back53 test('when negativeOption with false then return true', () => {54 const helper = new DualOptions(options);55 assert.equal(helper.valueFromOption(false, negativeOption), true);56 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 57why, one step back57Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 58–61why, one step back58 test('when negativeOption with true then return false', () => {59 const helper = new DualOptions(options);60 assert.equal(helper.valueFromOption(true, negativeOption), false);61 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 62why, one step back62Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 63–66why, one step back63 test('when positiveOption with false then return false', () => {64 const helper = new DualOptions(options);65 assert.equal(helper.valueFromOption(false, positiveOption), false);66 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 67why, one step back67Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 68–71why, one step back68 test('when positiveOption with true then return true', () => {69 const helper = new DualOptions(options);70 assert.equal(helper.valueFromOption(true, positiveOption), true);71 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 72–73why, one step back72 });73Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 74–77why, one step back74 describe('valueFromOption with option expecting value and negative with preset', () => {75 const positiveOption = new Option('--one <value>');76 const negativeOption = new Option('--no-one').preset('FALSE');77 const options = [positiveOption, negativeOption];Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 78why, one step back78Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 79–82why, one step back79 test('when negativeOption with FALSE then return true', () => {80 const helper = new DualOptions(options);81 assert.equal(helper.valueFromOption('FALSE', negativeOption), true);82 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 83why, one step back83Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 84–87why, one step back84 test('when negativeOption with string then return false', () => {85 const helper = new DualOptions(options);86 assert.equal(helper.valueFromOption('foo', negativeOption), false);87 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 88why, one step back88Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 89–92why, one step back89 test('when positiveOption with FALSE then return false', () => {90 const helper = new DualOptions(options);91 assert.equal(helper.valueFromOption('FALSE', positiveOption), false);92 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 93why, one step back93Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 94–97why, one step back94 test('when positiveOption with true then return true', () => {95 const helper = new DualOptions(options);96 assert.equal(helper.valueFromOption('foo', positiveOption), true);97 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
lines 98–99why, one step back98 });99});