command.onCommand.test.js
This file
Path
tests/command.onCommand.test.js
37 lines · 1.5 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 b2842dc point at it.
update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 1why, one step back1const commander = require('../');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 2–3why, one step back2const { test, describe } = require('node:test');3const assert = require('node:assert/strict');update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 4–7why, one step back45// The action handler used to be implemented using command events and listeners.6// Now, this is mostly just for backwards compatibility.7Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 8why, one step back8describe("Command.command('*')", () => {Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 9–10why, one step back9 test('when action handler for subcommand then emit command:subcommand', (t) => {10 const mockListener = t.mock.fn();update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 11why, one step back11 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 12why, one step back12 program.command('sub').action(() => {});update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 13–14why, one step back13 program.on('command:sub', mockListener);14 program.parse(['sub'], { from: 'user' });Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 15why, one step back15 assert.equal(mockListener.mock.callCount(), 1);update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 16–17why, one step back16 });17Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 18–19why, one step back18 test('when no action handler for subcommand then still emit command:subcommand', (t) => {19 const mockListener = t.mock.fn();update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 20why, one step back20 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 21why, one step back21 program.command('sub');update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 22–23why, one step back22 program.on('command:sub', mockListener);23 program.parse(['sub'], { from: 'user' });Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 24why, one step back24 assert.equal(mockListener.mock.callCount(), 1);update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 25–26why, one step back25 });26Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 27–28why, one step back27 test('when subcommand has argument then emit command:subcommand with argument', (t) => {28 const mockListener = t.mock.fn();update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 29why, one step back29 const program = new commander.Command();Reformat code with Prettier (#2180)John Geebefore adoption1bdc749
line 30why, one step back30 program.command('sub <file>').action(() => {});update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 31–32why, one step back31 program.on('command:sub', mockListener);32 program.parse(['sub', 'file'], { from: 'user' });Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
lines 33–35why, one step back33 assert.equal(mockListener.mock.callCount(), 1);34 const callArgs = mockListener.mock.calls[0].arguments;35 assert.deepEqual(callArgs, [['file'], []]);update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 36–37why, one step back36 });37});