command.nested.test.js
This file
Path
tests/command.nested.test.js
11 lines · 418 bytes · JavaScript
Last changed by
Switching to esm-only (#2464)John Geebefore adoptionf4bd470
History of this fileTake it
123456789101112import * as commander from '../index.js';import { test } from 'node:test';import assert from 'node:assert/strict';
test('when call nested subcommand then runs', (t) => { const program = new commander.Command(); const leafAction = t.mock.fn(); program.command('sub1').command('sub2').action(leafAction); program.parse('node test.js sub1 sub2'.split(' ')); assert.equal(leafAction.mock.callCount(), 1);});