Welcome to mirror list, hosted at ThFree Co, Russian Federation.

whoami.js « lib « test « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: c54ee2a5a2be7875514d61f6dc23c3b0ef40f139 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const t = require('tap')
const { real: mockNpm } = require('../fixtures/mock-npm')

const username = 'foo'
const { joinedOutput, command, npm } = mockNpm(t, {
  '../../lib/utils/get-identity.js': () => Promise.resolve(username),
})

t.before(async () => {
  await npm.load()
})

t.test('npm whoami', async (t) => {
  await command('whoami')
  t.equal(joinedOutput(), username, 'should print username')
})

t.test('npm whoami --json', async (t) => {
  t.teardown(() => {
    npm.config.set('json', false)
  })
  npm.config.set('json', true)
  await command('whoami')
  t.equal(JSON.parse(joinedOutput()), username, 'should print username')
})