Skip to content
Myr

command.usage.test.js

This file

Path

tests/command.usage.test.js

92 lines · 2.8 KiB · JavaScript

Last changed by

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

History of this file

Take it

The walk stopped after 200 commits: lines older than 3103c6b point at it.

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 1why, one step back
1const commander = require('../');

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

line 2why, one step back
2const { test, describe } = require('node:test');

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

line 3why, one step back
3const assert = require('node:assert/strict');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 4why, one step back
4

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

lines 5–7why, one step back
5describe('command Usage section in help', () => {
6 test('when default usage and check program help then starts with default usage', () => {7 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 8why, one step back
8

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

lines 9–10why, one step back
9 program.name('test');
10 const helpInformation = program.helpInformation();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 11why, one step back
11

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

lines 12–13why, one step back
12 assert.match(helpInformation, /^Usage: test \[options\]/);
13 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 14why, one step back
14

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

lines 15–18why, one step back
15 test('when custom usage and check program help then starts with custom usage', () => {
16 const myUsage = 'custom';17 const program = new commander.Command();18 program.usage(myUsage);

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 19why, one step back
19

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

lines 20–21why, one step back
20 program.name('test');
21 const helpInformation = program.helpInformation();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 22why, one step back
22

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

lines 23–24why, one step back
23 assert.match(helpInformation, new RegExp(`^Usage: test ${myUsage}`));
24 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 25why, one step back
25

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

lines 26–28why, one step back
26 test('when default usage and check subcommand help then starts with default usage including program name', () => {
27 const program = new commander.Command();28 const subCommand = program.command('info');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 29why, one step back
29

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

lines 30–31why, one step back
30 program.name('test');
31 const helpInformation = subCommand.helpInformation();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 32why, one step back
32

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

lines 33–34why, one step back
33 assert.match(helpInformation, /^Usage: test info \[options\]/);
34 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 35why, one step back
35

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

lines 36–39why, one step back
36 test('when custom usage and check subcommand help then starts with custom usage including program name', () => {
37 const myUsage = 'custom';38 const program = new commander.Command();39 const subCommand = program.command('info').usage(myUsage);

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 40why, one step back
40

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

lines 41–42why, one step back
41 program.name('test');
42 const helpInformation = subCommand.helpInformation();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 43why, one step back
43

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

lines 44–45why, one step back
44 assert.match(helpInformation, new RegExp(`^Usage: test info ${myUsage}`));
45 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 46why, one step back
46

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

lines 47–48why, one step back
47 test('when has option then [options] included in usage', () => {
48 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 49why, one step back
49

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

line 50why, one step back
50 program.option('--foo');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 51why, one step back
51

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

lines 52–53why, one step back
52 assert.match(program.usage(), /\[options\]/);
53 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 54why, one step back
54

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

lines 55–56why, one step back
55 test('when no options then [options] not included in usage', () => {
56 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 57why, one step back
57

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

line 58why, one step back
58 program.helpOption(false);

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 59why, one step back
59

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

lines 60–61why, one step back
60 assert.doesNotMatch(program.usage(), /\[options\]/);
61 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 62why, one step back
62

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

lines 63–64why, one step back
63 test('when has command then [command] included in usage', () => {
64 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 65why, one step back
65

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

line 66why, one step back
66 program.command('foo');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 67why, one step back
67

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

lines 68–69why, one step back
68 assert.match(program.usage(), /\[command\]/);
69 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 70why, one step back
70

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

lines 71–72why, one step back
71 test('when no commands then [command] not included in usage', () => {
72 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 73why, one step back
73

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

lines 74–75why, one step back
74 assert.doesNotMatch(program.usage(), /\[command\]/);
75 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 76why, one step back
76

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

lines 77–78why, one step back
77 test('when argument then argument included in usage', () => {
78 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 79why, one step back
79

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

line 80why, one step back
80 program.argument('<file>');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 81why, one step back
81

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

lines 82–83why, one step back
82 assert.match(program.usage(), /<file>/);
83 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 84why, one step back
84

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

lines 85–86why, one step back
85 test('when options and command and argument then all three included in usage', () => {
86 const program = new commander.Command();

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 87why, one step back
87

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

line 88why, one step back
88 program.argument('<file>').option('--alpha').command('beta');

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 89why, one step back
89

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

lines 90–91why, one step back
90 assert.equal(program.usage(), '[options] [command] <file>');
91 });

Add more tests for implies (#1730)John Geebefore adoption3103c6b

line 92why, one step back
92});