summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/normalize-package-data/test/scoped.js
blob: 82d2a543f97251258d9c0ab89a9b72a09f759240 (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
49
50
51
52
53
54
55
56
57
58
59
var test = require("tap").test

var fixNameField = require("../lib/fixer.js").fixNameField
var fixBinField = require("../lib/fixer.js").fixBinField

test("a simple scoped module has a valid name", function (t) {
  var data = {name : "@org/package"}
  fixNameField(data, false)
  t.equal(data.name, "@org/package", "name was unchanged")

  t.end()
})

test("'org@package' is not a valid name", function (t) {
  t.throws(function () {
    fixNameField({name : "org@package"}, false)
  }, "blows up as expected")

  t.end()
})

test("'org=package' is not a valid name", function (t) {
  t.throws(function () {
    fixNameField({name : "org=package"}, false)
  }, "blows up as expected")

  t.end()
})

test("'@org=sub/package' is not a valid name", function (t) {
  t.throws(function () {
    fixNameField({name : "@org=sub/package"}, false)
  }, "blows up as expected")

  t.end()
})

test("'@org/' is not a valid name", function (t) {
  t.throws(function () {
    fixNameField({name : "@org/"}, false)
  }, "blows up as expected")

  t.end()
})

test("'@/package' is not a valid name", function (t) {
  t.throws(function () {
    fixNameField({name : "@/package"}, false)
  }, "blows up as expected")

  t.end()
})

test("name='@org/package', bin='bin.js' is bin={package:'bin.js'}", function (t) {
  var obj = {name : "@org/package", bin: "bin.js"}
  fixBinField(obj)
  t.isDeeply(obj.bin, {package: 'bin.js'})
  t.end()
})