command.createOption.test.js
This file
Path
tests/command.createOption.test.js
46 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('../');Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
line 2why, one step back2const { test, describe } = require('node:test');Switch from Jest to Node.js built-in test runner (#2463)John Geebefore adoption3dd6086
line 3why, one step back3const assert = require('node:assert/strict');update chinese readme (#1727)wenjiebefore adoptionb2842dc
lines 4–17why, one step back45class MyOption extends commander.Option {6 constructor(flags, description) {7 super(flags, description);8 this.myProperty = 'MyOption';9 }10}1112class MyCommand extends commander.Command {13 createOption(flags, description) {14 return new MyOption(flags, description);15 }16}17Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 18–24why, one step back18describe('Command.createOption() override in subclass', () => {19 test('when override createOption then used for option()', () => {20 const program = new MyCommand();21 program.option('-a, --alpha');22 assert.equal(program.options.length, 1);23 assert.equal(program.options[0].myProperty, 'MyOption');24 });update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 25why, one step back25Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 26–31why, one step back26 test('when override createOption then used for requiredOption()', () => {27 const program = new MyCommand();28 program.requiredOption('-a, --alpha');29 assert.equal(program.options.length, 1);30 assert.equal(program.options[0].myProperty, 'MyOption');31 });update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 32why, one step back32Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 33–38why, one step back33 test('when override createOption then used for version()', () => {34 const program = new MyCommand();35 program.version('1.2.3');36 assert.equal(program.options.length, 1);37 assert.equal(program.options[0].myProperty, 'MyOption');38 });update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 39why, one step back39Add describe wrappers so test output makes sense without filenames (#2472)John Geebefore adoptionb3e6795
lines 40–45why, one step back40 test('when override createOption then used for help option in visibleOptions', () => {41 const program = new MyCommand();42 const visibleOptions = program.createHelp().visibleOptions(program);43 assert.equal(visibleOptions.length, 1);44 assert.equal(visibleOptions[0].myProperty, 'MyOption');45 });update chinese readme (#1727)wenjiebefore adoptionb2842dc
line 46why, one step back46});