2021-03-04 17:40:28 -05:00
|
|
|
// Thanks to nyc not working properly with proxies this
|
2021-03-11 17:54:23 -05:00
|
|
|
// doesn't affect coverage. but it does ensure that every command has a usage
|
|
|
|
// that contains its name, and if it has completion it is a function
|
2020-10-02 17:52:19 -04:00
|
|
|
const npm = require('../../lib/npm.js')
|
|
|
|
const t = require('tap')
|
|
|
|
const { cmdList } = require('../../lib/utils/cmd-list.js')
|
|
|
|
|
|
|
|
t.test('load npm', t => npm.load(er => {
|
2020-11-17 15:37:44 -05:00
|
|
|
if (er)
|
2020-10-02 17:52:19 -04:00
|
|
|
throw er
|
|
|
|
}))
|
|
|
|
|
|
|
|
t.test('load each command', t => {
|
|
|
|
t.plan(cmdList.length)
|
|
|
|
for (const cmd of cmdList.sort((a, b) => a.localeCompare(b))) {
|
|
|
|
t.test(cmd, t => {
|
|
|
|
const impl = npm.commands[cmd]
|
2021-03-01 11:38:43 -05:00
|
|
|
if (impl.completion) {
|
|
|
|
t.plan(3)
|
|
|
|
t.isa(impl.completion, 'function', 'completion, if present, is a function')
|
|
|
|
} else
|
|
|
|
t.plan(2)
|
2020-10-02 17:52:19 -04:00
|
|
|
t.isa(impl, 'function', 'implementation is a function')
|
2021-03-04 17:40:28 -05:00
|
|
|
t.match(impl.usage, cmd, 'usage contains the command')
|
2020-10-02 17:52:19 -04:00
|
|
|
})
|
|
|
|
}
|
|
|
|
})
|