diff options
Diffstat (limited to 'test/lib/commands/help.js')
-rw-r--r-- | test/lib/commands/help.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lib/commands/help.js b/test/lib/commands/help.js index b76234d99..f84f94ad2 100644 --- a/test/lib/commands/help.js +++ b/test/lib/commands/help.js @@ -310,3 +310,41 @@ t.test('npm help with complex installation path finds proper help file', async t t.match(openUrlArg, /commands(\/|\\)npm-install.html$/, 'attempts to open the correct url') }) + +t.test('npm help - prefers npm help pages', async t => { + // Unusual ordering is to get full test coverage of all branches inside the + // sort function. + globResult = [ + '/root/man/man6/npm-install.6', + '/root/man/man1/install.1', + '/root/man/man5/npm-install.5', + ] + t.teardown(() => { + globResult = globDefaults + spawnBin = null + spawnArgs = null + }) + await help.exec(['install']) + + t.equal(spawnBin, 'man', 'calls man by default') + t.strictSame(spawnArgs, ['/root/man/man5/npm-install.5'], 'passes the correct arguments') +}) + +t.test('npm help - works in the presence of strange man pages', async t => { + // Unusual ordering is to get full test coverage of all branches inside the + // sort function. + globResult = [ + '/root/man/man6/config.6strange', + '/root/man/man1/config.1', + '/root/man/man5/config.5ssl', + ] + t.teardown(() => { + globResult = globDefaults + spawnBin = null + spawnArgs = null + }) + await help.exec(['config']) + + t.equal(spawnBin, 'man', 'calls man by default') + t.strictSame(spawnArgs, ['/root/man/man1/config.1'], 'passes the correct arguments') +}) |