help.visibleGlobalOptions.test.js
This file
Path
tests/help.visibleGlobalOptions.test.js
47 lines · 1.9 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–3why, one step back1import { test, describe } from 'node:test';2import assert from 'node:assert/strict';3import * as commander from '../index.js';Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 4why, one step back4Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 5–12why, one step back5describe('Help.visibleGlobalOptions()', () => {6 test('when default configuration then return empty array', () => {7 const program = new commander.Command();8 program.option('--global');9 const sub = program.command('sub');10 const helper = sub.createHelp();11 assert.deepEqual(helper.visibleGlobalOptions(program), []);12 });Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 13why, one step back13Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 14–23why, one step back14 test('when showGlobalOptions:true then return program options', () => {15 const program = new commander.Command();16 program.option('--global').configureHelp({ showGlobalOptions: true });17 const sub = program.command('sub');18 const helper = sub.createHelp();19 const visibleOptionNames = helper20 .visibleGlobalOptions(sub)21 .map((option) => option.name());22 assert.deepEqual(visibleOptionNames, ['global']);23 });Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 24why, one step back24Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 25–34why, one step back25 test('when showGlobalOptions:true and program has version then return version', () => {26 const program = new commander.Command();27 program.configureHelp({ showGlobalOptions: true }).version('1.2.3');28 const sub = program.command('sub');29 const helper = sub.createHelp();30 const visibleOptionNames = helper31 .visibleGlobalOptions(sub)32 .map((option) => option.name());33 assert.deepEqual(visibleOptionNames, ['version']);34 });Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 35why, one step back35Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 36–46why, one step back36 test('when showGlobalOptions:true and nested commands then return combined global options', () => {37 const program = new commander.Command();38 program.configureHelp({ showGlobalOptions: true }).option('--global');39 const sub1 = program.command('sub1').option('--sub1');40 const sub2 = sub1.command('sub2');41 const helper = sub2.createHelp();42 const visibleOptionNames = helper43 .visibleGlobalOptions(sub2)44 .map((option) => option.name());45 assert.deepEqual(visibleOptionNames, ['sub1', 'global']);46 });Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631
line 47why, one step back47});