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

whoami.js « commands « lib « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc6144ec1dd284e0536cac60279192c0a25681f4 (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
26
const t = require('tap')
const { real: mockNpm } = require('../../fixtures/mock-npm')

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

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

t.test('npm whoami', async (t) => {
  await npm.exec('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 npm.exec('whoami', [])
  t.equal(JSON.parse(joinedOutput()), username, 'should print username')
})