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

get-project-scope.js « utils « lib « test - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9737b06433c227b21cb0a362ee820c4276b12fad (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const getProjectScope = require('../../../lib/utils/get-project-scope.js')
const t = require('tap')

t.test('package.json with scope', t => {
  const dir = t.testdir({
    'package.json': JSON.stringify({ name: '@foo/bar' }),
  })
  t.equal(getProjectScope(dir), '@foo')
  t.end()
})

t.test('package.json with slash, but no @', t => {
  const dir = t.testdir({
    'package.json': JSON.stringify({ name: 'foo/bar' }),
  })
  t.equal(getProjectScope(dir), '')
  t.end()
})

t.test('package.json without scope', t => {
  const dir = t.testdir({
    'package.json': JSON.stringify({ name: 'foo' }),
  })
  t.equal(getProjectScope(dir), '')
  t.end()
})

t.test('package.json without name', t => {
  const dir = t.testdir({
    'package.json': JSON.stringify({}),
  })
  t.equal(getProjectScope(dir), '')
  t.end()
})

t.test('package.json not JSON', t => {
  const dir = t.testdir({
    'package.json': 'hello',
  })
  t.equal(getProjectScope(dir), '')
  t.end()
})

t.test('no package.json', t => {
  const dir = t.testdir({})
  t.equal(getProjectScope(dir), '')
  t.end()
})