command.name.test.js
This file
Path
tests/command.name.test.js
57 lines · 2.1 KiB · JavaScript
Last changed by
Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
History of this fileTake it
The walk stopped after 200 commits: lines older than 3103c6b point at it.
Add more tests for implies (#1730)John Geebefore adoption3103c6b
lines 1–2why, one step back1const path = require('path');2const commander = require('../');Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 3why, one step back3const { test, describe } = require('node:test');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 4why, one step back4const assert = require('node:assert/strict');Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 5why, one step back5Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 6–10why, one step back6describe('Command.name()', () => {7 test('when construct with name then name is set', () => {8 const program = new commander.Command('foo');9 assert.equal(program.name(), 'foo');10 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 11why, one step back11Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 12–17why, one step back12 test('when set program name and parse then name is as assigned', () => {13 const program = new commander.Command();14 program.name('custom');15 program.parse(['node', 'test']);16 assert.equal(program.name(), 'custom');17 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 18why, one step back18Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 19–24why, one step back19 test('when program name not set and parse with script argument then plain name is found from script name', () => {20 const program = new commander.Command();21 program.parse(['node', path.resolve(process.cwd(), 'script.js')], {22 from: 'node',23 });24 assert.equal(program.name(), 'script');Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 25why, one step back25 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 26why, one step back26Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 27–31why, one step back27 test('when command name not set and no script argument in parse then name is program', () => {28 const program = new commander.Command();29 program.parse([], { from: 'user' });30 assert.equal(program.name(), 'program');31 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 32why, one step back32Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 33–37why, one step back33 test('when add command then command is named', () => {34 const program = new commander.Command();35 const subcommand = program.command('mycommand <file>');36 assert.equal(subcommand.name(), 'mycommand');37 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 38why, one step back38Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 39–44why, one step back39 test('when set program name then name appears in help', () => {40 const program = new commander.Command();41 program.name('custom-name');42 const helpInformation = program.helpInformation();43 assert.match(helpInformation, /^Usage: custom-name/);44 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 45why, one step back45Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 46–50why, one step back46 test('when pass path to nameFromFilename then name is plain name', () => {47 const program = new commander.Command();48 program.nameFromFilename(path.resolve(process.cwd(), 'foo.js'));49 assert.equal(program.name(), 'foo');50 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 51why, one step back51Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 52–56why, one step back52 test('when pass __filename to nameFromFilename then name is plain name of this file', () => {53 const program = new commander.Command();54 program.nameFromFilename(__filename);55 assert.equal(program.name(), 'command.name.test');56 });Add more tests for implies (#1730)John Geebefore adoption3103c6b
line 57why, one step back57});