Skip to content
Myr

command.addHelpOption.test.js

This file

Path

tests/command.addHelpOption.test.js

41 lines · 1.3 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–4why, one step back
1import { Option } from '../index.js';
2import { createTestCommand } from './testHelpers.js';3import { test, describe } from 'node:test';4import assert from 'node:assert/strict';

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 5–7why, one step back
5
6// More complete tests are in command.helpOption.test.js.7

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

line 8why, one step back
8describe('Command.addHelpOption()', () => {

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 9why, one step back
9 test('when addHelpOption has custom flags then custom short flag invokes help', () => {

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 10–11why, one step back
10 const program = createTestCommand();
11 program.addHelpOption(new Option('-c,--custom-help'));

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 12why, one step back
12

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 13–18why, one step back
13 assert.throws(
14 () => {15 program.parse(['-c'], { from: 'user' });16 },17 { message: '(outputHelp)' },18 );

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 19–21why, one step back
19 });
2021 test('when addHelpOption has custom flags then custom long flag invokes help', () => {

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 22–23why, one step back
22 const program = createTestCommand();
23 program.addHelpOption(new Option('-c,--custom-help'));

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 24why, one step back
24

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

lines 25–30why, one step back
25 assert.throws(
26 () => {27 program.parse(['--custom-help'], { from: 'user' });28 },29 { message: '(outputHelp)' },30 );

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 31–33why, one step back
31 });
3233 test('when addHelpOption with hidden help option then help does not include help option', () => {

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 34why, one step back
34 const program = createTestCommand();

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 35–37why, one step back
35 program.addHelpOption(
36 new Option('-c,--custom-help', 'help help help').hideHelp(),37 );

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

line 38why, one step back
38 const helpInfo = program.helpInformation();

Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086

line 39why, one step back
39 assert.doesNotMatch(helpInfo, /help/);

Merge pull request #2140 from tj/release/12.xJohn Geebefore adoptione3192a1

lines 40–41why, one step back
40 });
41});