Skip to content
Myr

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 file

Take it

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 1–3why, one step back
1const childProcess = require('child_process');
2const path = require('path');3

Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf

line 4why, one step back
4// 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 back
5

Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf

lines 6–7why, one step back
6const pm = path.join(__dirname, './fixtures/pm');
7

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

line 8why, one step back
8test('when default subcommand and no command then call default', (done) => {

Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf

line 9why, one step back
9 childProcess.exec(`node ${pm}`, function(_error, stdout, stderr) {

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 10–14why, one step back
10 expect(stdout).toBe('default\n');
11 done();12 });13});14

Call default subcommand when there are unknown options on command line. (#1047)John Geebefore adoption5cac9d6

line 15why, one step back
15test('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 back
16 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 back
17 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 back
23 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 back
24 expect(stdout).toBe("default\n[ '--an-option' ]\n");

Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4

lines 25–27why, one step back
25 done();
26 });27});