Skip to content
Myr

help.showGlobalOptions.test.js

This file

Path

tests/help.showGlobalOptions.test.js

52 lines · 2.0 KiB · JavaScript

Last changed by

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

History of this file

Take it

Switching to esm-only (#2464)John Geebefore adoptionf4bd470

lines 1–3why, one step back
1import * as commander from '../index.js';
2import { test, describe } from 'node:test';3import assert from 'node:assert/strict';

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 4why, one step back
4

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 5–11why, one step back
5describe('Help.showGlobalOptions()', () => {
6 test('when default configuration then global options hidden', () => {7 const program = new commander.Command();8 program.option('--global');9 const sub = program.command('sub');10 assert.doesNotMatch(sub.helpInformation(), /global/);11 });

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 12why, one step back
12

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 13–18why, one step back
13 test('when showGlobalOptions:true then program options shown', () => {
14 const program = new commander.Command();15 program.option('--global').configureHelp({ showGlobalOptions: true });16 const sub = program.command('sub');17 assert.match(sub.helpInformation(), /global/);18 });

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 19why, one step back
19

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 20–25why, one step back
20 test('when showGlobalOptions:true and no global options then global options header not shown', () => {
21 const program = new commander.Command();22 program.configureHelp({ showGlobalOptions: true });23 const sub = program.command('sub');24 assert.doesNotMatch(sub.helpInformation(), /Global/);25 });

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 26why, one step back
26

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 27–36why, one step back
27 test('when showGlobalOptions:true and nested commands then combined nested options shown program last', () => {
28 const program = new commander.Command();29 program.option('--global').configureHelp({ showGlobalOptions: true });30 const sub1 = program.command('sub1').option('--sub1');31 const sub2 = sub1.command('sub2');32 assert.match(33 sub2.helpInformation(),34 /Global Options:\n {2}--sub1\n {2}--global\n/,35 );36 });

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 37why, one step back
37

Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795

lines 38–51why, one step back
38 test('when showGlobalOptions:true and sortOptions: true then global options sorted', () => {
39 const program = new commander.Command();40 program41 .option('-3')42 .option('-4')43 .option('-2')44 .configureHelp({ showGlobalOptions: true, sortOptions: true });45 const sub1 = program.command('sub1').option('-6').option('-1').option('-5');46 const sub2 = sub1.command('sub2');47 assert.match(48 sub2.helpInformation(),49 /Global Options:\n {2}-1\n {2}-2\n {2}-3\n {2}-4\n {2}-5\n {2}-6\n/,50 );51 });

Merge branch 'master' into release/10.xJohn Geebefore adoption2bdd631

line 52why, one step back
52});