diff options
Diffstat (limited to 'test/lib/utils/read-user-info.js')
-rw-r--r-- | test/lib/utils/read-user-info.js | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/test/lib/utils/read-user-info.js b/test/lib/utils/read-user-info.js index 35101f1d7..be805a2a8 100644 --- a/test/lib/utils/read-user-info.js +++ b/test/lib/utils/read-user-info.js @@ -7,11 +7,6 @@ const read = (opts, cb) => { return cb(null, readResult) } -const npmlog = { - clearProgress: () => {}, - showProgress: () => {}, -} - const npmUserValidate = { username: (username) => { if (username === 'invalid') { @@ -29,12 +24,23 @@ const npmUserValidate = { }, } +let logMsg = null const readUserInfo = t.mock('../../../lib/utils/read-user-info.js', { read, - npmlog, + npmlog: { + clearProgress: () => {}, + showProgress: () => {}, + }, + 'proc-log': { + warn: (msg) => logMsg = msg, + }, 'npm-user-validate': npmUserValidate, }) +t.beforeEach(() => { + logMsg = null +}) + t.test('otp', async (t) => { readResult = '1234' t.teardown(() => { @@ -75,11 +81,7 @@ t.test('username - invalid warns and retries', async (t) => { readOpts = null }) - let logMsg - const log = { - warn: (msg) => logMsg = msg, - } - const pResult = readUserInfo.username(null, null, { log }) + const pResult = readUserInfo.username(null, null) // have to swap it to a valid username after execution starts // or it will loop forever readResult = 'valid' @@ -105,11 +107,7 @@ t.test('email - invalid warns and retries', async (t) => { readOpts = null }) - let logMsg - const log = { - warn: (msg) => logMsg = msg, - } - const pResult = readUserInfo.email(null, null, { log }) + const pResult = readUserInfo.email(null, null) readResult = 'foo@bar.baz' const result = await pResult t.equal(result, 'foo@bar.baz', 'received the email') |