diff options
author | nlf <quitlahok@gmail.com> | 2020-12-15 20:05:59 +0300 |
---|---|---|
committer | nlf <quitlahok@gmail.com> | 2020-12-15 22:20:56 +0300 |
commit | 8c67c38a4f476ff5be938db6b6b3ee9ac6b44db5 (patch) | |
tree | c5ea7275915582b4bfd29d086102b4185f091591 /test | |
parent | 996a2f6b130d6678998a2f6a5ec97d75534d5f66 (diff) |
add tests for set command
PR-URL: https://github.com/npm/cli/pull/2354
Credit: @nlf
Close: #2354
Reviewed-by: @ruyadorno
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/set.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/test/lib/set.js b/test/lib/set.js new file mode 100644 index 000000000..aeb239e9c --- /dev/null +++ b/test/lib/set.js @@ -0,0 +1,33 @@ +const { test } = require('tap') +const requireInject = require('require-inject') + +let configArgs = null +const npm = { + commands: { + config: (args, cb) => { + configArgs = args + return cb() + }, + }, +} + +const set = requireInject('../../lib/set.js', { + '../../lib/npm.js': npm, +}) + +test('npm set - no args', t => { + return set([], (err) => { + t.match(err, /npm set/, 'prints usage') + t.end() + }) +}) + +test('npm set', t => { + return set(['email', 'me@me.me'], (err) => { + if (err) + throw err + + t.strictSame(configArgs, ['set', 'email', 'me@me.me'], 'passed the correct arguments to config') + t.end() + }) +}) |