command.executableSubcommand.default.test.js
This file
Path
tests/command.executableSubcommand.default.test.js
27 lines · 933 bytes · JavaScript
Last changed by
Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
History of this fileTake it
Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 1–3why, one step back1const childProcess = require('child_process');2const path = require('path');3Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 4why, one step back4// Calling node explicitly so pm works without file suffix cross-platform.Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
line 5why, one step back5Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
lines 6–7why, one step back6const pm = path.join(__dirname, './fixtures/pm');7Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
line 8why, one step back8test('when default subcommand and no command then call default', (done) => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 9why, one step back9 childProcess.exec(`node ${pm}`, function(_error, stdout, stderr) {Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 10–14why, one step back10 expect(stdout).toBe('default\n');11 done();12 });13});14Call default subcommand when there are unknown options on command line. (#1047)John Geebefore adoption5cac9d6
line 15why, one step back15test('when default subcommand and unrecognised argument then call default with argument', (done) => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 16why, one step back16 childProcess.exec(`node ${pm} an-argument`, function(_error, stdout, stderr) {Call default subcommand when there are unknown options on command line. (#1047)John Geebefore adoption5cac9d6
lines 17–22why, one step back17 expect(stdout).toBe("default\n[ 'an-argument' ]\n");18 done();19 });20});2122test('when default subcommand and unrecognised option then call default with option', (done) => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 23why, one step back23 childProcess.exec(`node ${pm} --an-option`, function(_error, stdout, stderr) {Call default subcommand when there are unknown options on command line. (#1047)John Geebefore adoption5cac9d6
line 24why, one step back24 expect(stdout).toBe("default\n[ '--an-option' ]\n");Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 25–27why, one step back25 done();26 });27});