MCPcopy Create free account
hub / github.com/npm/cli / setupOtplease

Function setupOtplease

test/lib/utils/auth.js:6–22  ·  view source on GitHub ↗
(t, { otp = {}, ...rest }, fn)

Source from the content-addressed store, hash-verified

4
5// TODO make this real and not a mock
6const setupOtplease = async (t, { otp = {}, ...rest }, fn) => {
7 const { otplease } = tmock(t, '{LIB}/utils/auth.js', {
8 '{LIB}/utils/read-user-info.js': {
9 otp: async () => '1234',
10 },
11 '{LIB}/utils/open-url.js': {
12 createOpener: () => () => {},
13 },
14 'npm-profile': {
15 webAuthOpener: async (opener) => {
16 opener()
17 return { token: '1234' }
18 },
19 },
20 })
21 return otplease(await setupMockNpm(t, rest).then(({ npm }) => npm), otp, fn)
22}
23
24t.test('returns function results on success', async (t) => {
25 const result = await setupOtplease(t, {}, () => 'test string')

Callers 1

auth.jsFile · 0.85

Calls 3

tmockFunction · 0.85
otpleaseFunction · 0.85
setupMockNpmFunction · 0.85

Tested by

no test coverage detected