command.executableSubcommand.lookup.test.js
This file
Path
tests/command.executableSubcommand.lookup.test.js
96 lines · 3.7 KiB · JavaScript
Last changed by
Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
History of this fileTake it
Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 1–2why, one step back1const childProcess = require('child_process');2const path = require('path');Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 3–4why, one step back3const util = require('util');4const execAsync = util.promisify(childProcess.exec);Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
line 5why, one step back5Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 6why, one step back6// Calling node explicitly so pm works without file suffix cross-platform.Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
line 7why, one step back7Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 8–10why, one step back8// Get false positives due to use of testOrSkipOnWindows9/* eslint-disable jest/no-standalone-expect */10Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
lines 11–13why, one step back11const testOrSkipOnWindows = (process.platform === 'win32') ? test.skip : test;12const pm = path.join(__dirname, './fixtures/pm');13Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 14–16why, one step back14test('when subcommand file missing then error', () => {15 expect.assertions(1);16 return execAsync(`node ${pm} list`).catch((err) => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
lines 17–18why, one step back17 if (process.platform === 'win32') {18 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 19why, one step back19 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 20why, one step back20 expect(err.stderr).toBeDefined();Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 21why, one step back21 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 22why, one step back22 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 23why, one step back23 expect(err.stderr).toMatch(new RegExp(/Error: 'pm-list' does not exist/));Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 24why, one step back24 }Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 25–27why, one step back25 });26});27Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 28–30why, one step back28test('when alias subcommand file missing then error', () => {29 expect.assertions(1);30 return execAsync(`node ${pm} lst`).catch((err) => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
lines 31–32why, one step back31 if (process.platform === 'win32') {32 // Get uncaught thrown error on WindowsMerge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 33why, one step back33 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 34why, one step back34 expect(err.stderr).toBeDefined();Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 35why, one step back35 } else {Merge branch 'develop' into release/7.xJohn Geebefore adoptiond90ef12
line 36why, one step back36 // eslint-disable-next-line jest/no-conditional-expectUpdate dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 37why, one step back37 expect(err.stderr).toMatch(new RegExp(/Error: 'pm-list' does not exist/));Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 38why, one step back38 }Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 39–41why, one step back39 });40});41Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 42–44why, one step back42test('when subcommand file has no suffix then lookup succeeds', async() => {43 const { stdout } = await execAsync(`node ${pm} install`);44 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 45–46why, one step back45});46Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 47–49why, one step back47test('when alias subcommand file has no suffix then lookup succeeds', async() => {48 const { stdout } = await execAsync(`node ${pm} i`);49 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 50–51why, one step back50});51Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 52–54why, one step back52test('when subcommand target executablefile has no suffix then lookup succeeds', async() => {53 const { stdout } = await execAsync(`node ${pm} specifyInstall`);54 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 55–56why, one step back55});56Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 57–59why, one step back57test('when subcommand file suffix .js then lookup succeeds', async() => {58 const { stdout } = await execAsync(`node ${pm} publish`);59 expect(stdout).toBe('publish\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 60–61why, one step back60});61Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 62–64why, one step back62test('when alias subcommand file suffix .js then lookup succeeds', async() => {63 const { stdout } = await execAsync(`node ${pm} p`);64 expect(stdout).toBe('publish\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 65–66why, one step back65});66Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 67–69why, one step back67test('when subcommand target executablefile has suffix .js then lookup succeeds', async() => {68 const { stdout } = await execAsync(`node ${pm} specifyPublish`);69 expect(stdout).toBe('publish\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 70–71why, one step back70});71Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 72why, one step back72testOrSkipOnWindows('when subcommand file is symlink then lookup succeeds', async() => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 73why, one step back73 const pmlink = path.join(__dirname, 'fixtures', 'pmlink');Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 74–75why, one step back74 const { stdout } = await execAsync(`node ${pmlink} install`);75 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 76–77why, one step back76});77Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 78why, one step back78testOrSkipOnWindows('when subcommand file is double symlink then lookup succeeds', async() => {Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 79why, one step back79 const pmlink = path.join(__dirname, 'fixtures', 'another-dir', 'pm');Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 80–81why, one step back80 const { stdout } = await execAsync(`node ${pmlink} install`);81 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 82–83why, one step back82});83Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
line 84why, one step back84test('when subcommand suffix is .ts then lookup succeeds', async() => {Merge branch 'develop' into release/5.xJohn Geebefore adoptiondd23b4c
lines 85–86why, one step back85 // We support looking for ts files for ts-node in particular, but don't need to test ts-node itself.86 // The program and the subcommand `pm-install.ts` are both plain JavaScript code.Windows tests (and GitHub Actions) (#1070)John Geebefore adoption7ab5fbf
line 87why, one step back87 const binLinkTs = path.join(__dirname, 'fixtures-ts', 'pm.ts');Merge branch 'develop' into release/5.xJohn Geebefore adoptiondd23b4c
line 88why, one step back88 // childProcess.execFile('node', ['-r', 'ts-node/register', binLinkTs, 'install'], function(_error, stdout, stderr) {Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 89–90why, one step back89 const { stdout } = await execAsync(`node ${binLinkTs} install`);90 expect(stdout).toBe('install\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
lines 91–92why, one step back91});92Update dependencies and rewrite tests (#1167)John Geebefore adoptiond736ff7
lines 93–95why, one step back93test('when subsubcommand then lookup sub-sub-command', async() => {94 const { stdout } = await execAsync(`node ${pm} cache clear`);95 expect(stdout).toBe('cache-clear\n');Move to Jest as testing framework (#1035)John Geebefore adoptiond7f9cd4
line 96why, one step back96});