Skip to content
Myr

help.longestOptionTermLength.test.js

This file

Path

tests/help.longestOptionTermLength.test.js

38 lines · 1.3 KiB · JavaScript

Last changed by

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

History of this file

Take it

The walk stopped after 200 commits: lines older than 471ec40 point at 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';

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 4–7why, one step back
4
5// These are tests of the Help class, not of the Command help.6// There is some overlap with the higher level Command tests (which predate Help).7

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

line 8why, one step back
8describe('Help.longestOptionTermLength()', () => {

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 9–12why, one step back
9 test('when no option then returns zero', () => {
10 const program = new commander.Command();11 program.helpOption(false);12 const helper = new commander.Help();

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

line 13why, one step back
13 assert.equal(helper.longestOptionTermLength(program, helper), 0);

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 14–18why, one step back
14 });
1516 test('when just implicit help option returns length of help flags', () => {17 const program = new commander.Command();18 const helper = new commander.Help();

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

lines 19–20why, one step back
19 assert.equal(
20 helper.longestOptionTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 21–22why, one step back
21 '-h, --help'.length,
22 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 23–32why, one step back
23 });
2425 test('when multiple option then returns longest length', () => {26 const longestOptionFlags = '-l, --longest <value>';27 const program = new commander.Command();28 program29 .option('--before', 'optional description of flags')30 .option(longestOptionFlags)31 .option('--after');32 const helper = new commander.Help();

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

lines 33–34why, one step back
33 assert.equal(
34 helper.longestOptionTermLength(program, helper),

Reformat code with Prettier (#2180)John Geebefore adoption1bdc749

lines 35–36why, one step back
35 longestOptionFlags.length,
36 );

Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40

lines 37–38why, one step back
37 });
38});