command.name.test.js
This file
Path
tests/command.name.test.js
57 lines · 2.1 KiB · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
The walk stopped after 200 commits: lines older than 471ec40 point at it.
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
lines 1–4why, one step back1import * as path from 'path';2import * as commander from '../index.js';3import { test, describe } from 'node:test';4import assert from 'node:assert/strict';Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
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 copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 51why, one step back51Switching to esm-only (#2464)John Geebefore adoptionf4bd470
line 52why, one step back52 test('when pass import.meta.filename to nameFromFilename then name is plain name of this file', () => {Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 53why, one step back53 const program = new commander.Command();Switching to esm-only (#2464)John Geebefore adoptionf4bd470
line 54why, one step back54 program.nameFromFilename(import.meta.filename);Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 55–56why, one step back55 assert.equal(program.name(), 'command.name.test');56 });Add copyInheritedSettings to README (#1798)John Geebefore adoption471ec40
line 57why, one step back57});