From 5575834e07c532fd069d67fdb9877a417958f8fb Mon Sep 17 00:00:00 2001 From: nlf Date: Tue, 15 Dec 2020 09:05:59 -0800 Subject: [PATCH] add tests for set command --- test/lib/set.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/lib/set.js diff --git a/test/lib/set.js b/test/lib/set.js new file mode 100644 index 0000000000000..aeb239e9c4e39 --- /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() + }) +})