Skip to content

Commit

Permalink
add tests for set command
Browse files Browse the repository at this point in the history
PR-URL: #2354
Credit: @nlf
Close: #2354
Reviewed-by: @ruyadorno
  • Loading branch information
nlf committed Dec 15, 2020
1 parent 996a2f6 commit 8c67c38
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/lib/set.js
Original file line number Diff line number Diff line change
@@ -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()
})
})

0 comments on commit 8c67c38

Please sign in to comment.