Skip to content

Commit

Permalink
test: fix adduser tests post-new-config
Browse files Browse the repository at this point in the history
test/lib/adduser.js was consuming some of the utils that are now part of
the new @npmcli/config module, this commit bumps the module to get a
patch that makes it work and updates the test to consume instead.
  • Loading branch information
ruyadorno committed Aug 20, 2020
1 parent ea80f35 commit 374f793
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 32 deletions.
24 changes: 12 additions & 12 deletions node_modules/@npmcli/config/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@npmcli/config/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -117,7 +117,7 @@
"write-file-atomic": "^2.4.3",
"make-fetch-happen": "^8.0.9",
"leven": "^3.1.0",
"@npmcli/config": "^1.1.4"
"@npmcli/config": "^1.1.5"
},
"bundleDependencies": [
"@npmcli/arborist",
Expand Down
30 changes: 19 additions & 11 deletions test/lib/adduser.js
@@ -1,7 +1,7 @@
const requireInject = require('require-inject')
const { test } = require('tap')
const getCredentialsByURI = require('../../lib/config/get-credentials-by-uri.js')
const setCredentialsByURI = require('../../lib/config/set-credentials-by-uri.js')
const { getCredentialsByURI, setCredentialsByURI } =
require('@npmcli/config').prototype

let result = ''

Expand All @@ -24,30 +24,31 @@ const authDummy = () => Promise.resolve({
}
})

const deleteMock = (key, where) => {
deletedConfig = {
...deletedConfig,
[key]: where
}
}
const adduser = requireInject('../../lib/adduser.js', {
npmlog: {
disableProgress: () => null
},
'../../lib/npm.js': {
flatOptions: _flatOptions,
config: {
del (key, where) {
deletedConfig = {
...deletedConfig,
[key]: where
}
},
del: deleteMock,
delete: deleteMock,
get (key, where) {
if (!where || where === 'user') {
return _flatOptions[key]
}
},
getCredentialsByURI,
save (_, cb) {
async save () {
if (failSave) {
return cb(new Error('error saving user config'))
throw new Error('error saving user config')
}
cb()
},
set (key, value, where) {
setConfig = {
Expand All @@ -73,6 +74,13 @@ test('simple login', (t) => {
deletedConfig,
{
_token: 'user',
_password: 'user',
username: 'user',
email: 'user',
_auth: 'user',
_authtoken: 'user',
_authToken: 'user',
'//registry.npmjs.org/:-authtoken': undefined,
'//registry.npmjs.org/:_authToken': 'user'
},
'should delete token in user config'
Expand Down

0 comments on commit 374f793

Please sign in to comment.