]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-package-arg/test/basic.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-package-arg / test / basic.js
1 var npa = require("../npa.js")
2 var path = require("path")
3
4 require("tap").test("basic", function (t) {
5   t.setMaxListeners(999)
6
7   var tests = {
8     "foo@1.2": {
9       name: "foo",
10       type: "range",
11       spec: ">=1.2.0 <1.3.0",
12       raw: "foo@1.2",
13       rawSpec: "1.2"
14     },
15
16     "@foo/bar": {
17       raw: "@foo/bar",
18       name: "@foo/bar",
19       scope: "@foo",
20       rawSpec: "",
21       spec: "latest",
22       type: "tag"
23     },
24
25     "@foo/bar@": {
26       raw: "@foo/bar@",
27       name: "@foo/bar",
28       scope: "@foo",
29       rawSpec: "",
30       spec: "latest",
31       type: "tag"
32     },
33
34     "@foo/bar@baz": {
35       raw: "@foo/bar@baz",
36       name: "@foo/bar",
37       scope: "@foo",
38       rawSpec: "baz",
39       spec: "baz",
40       type: "tag"
41     },
42
43     "@f fo o al/ a d s ;f ": {
44       raw: "@f fo o al/ a d s ;f",
45       name: null,
46       rawSpec: "@f fo o al/ a d s ;f",
47       spec: path.resolve("@f fo o al/ a d s ;f"),
48       type: "local"
49     },
50
51     "foo@1.2.3": {
52       name: "foo",
53       type: "version",
54       spec: "1.2.3",
55       raw: "foo@1.2.3"
56     },
57
58     "foo@=v1.2.3": {
59       name: "foo",
60       type: "version",
61       spec: "1.2.3",
62       raw: "foo@=v1.2.3",
63       rawSpec: "=v1.2.3"
64     },
65
66     "git+ssh://git@notgithub.com/user/foo#1.2.3": {
67       name: null,
68       type: "git",
69       spec: "ssh://git@notgithub.com/user/foo#1.2.3",
70       raw: "git+ssh://git@notgithub.com/user/foo#1.2.3"
71     },
72
73     "git+file://path/to/repo#1.2.3": {
74       name: null,
75       type: "git",
76       spec: "file://path/to/repo#1.2.3",
77       raw: "git+file://path/to/repo#1.2.3"
78     },
79
80     "git://notgithub.com/user/foo": {
81       name: null,
82       type: "git",
83       spec: "git://notgithub.com/user/foo",
84       raw: "git://notgithub.com/user/foo"
85     },
86
87     "@foo/bar@git+ssh://notgithub.com/user/foo": {
88       name: "@foo/bar",
89       scope: "@foo",
90       spec: "ssh://notgithub.com/user/foo",
91       rawSpec: "git+ssh://notgithub.com/user/foo",
92       raw: "@foo/bar@git+ssh://notgithub.com/user/foo"
93     },
94
95     "/path/to/foo": {
96       name: null,
97       type: "local",
98       spec: path.resolve(__dirname, "/path/to/foo"),
99       raw: "/path/to/foo"
100     },
101
102     "file:path/to/foo": {
103       name: null,
104       type: "local",
105       spec: "path/to/foo",
106       raw: "file:path/to/foo"
107     },
108
109     "file:~/path/to/foo": {
110       name: null,
111       type: "local",
112       spec: "~/path/to/foo",
113       raw: "file:~/path/to/foo"
114     },
115
116     "file:../path/to/foo": {
117       name: null,
118       type: "local",
119       spec: "../path/to/foo",
120       raw: "file:../path/to/foo"
121     },
122
123     "file:///path/to/foo": {
124       name: null,
125       type: "local",
126       spec: "/path/to/foo",
127       raw: "file:///path/to/foo"
128     },
129
130     "https://server.com/foo.tgz": {
131       name: null,
132       type: "remote",
133       spec: "https://server.com/foo.tgz",
134       raw: "https://server.com/foo.tgz"
135     },
136
137     "foo@latest": {
138       name: "foo",
139       type: "tag",
140       spec: "latest",
141       raw: "foo@latest"
142     },
143
144     "foo": {
145       name: "foo",
146       type: "tag",
147       spec: "latest",
148       raw: "foo"
149     }
150   }
151
152   Object.keys(tests).forEach(function (arg) {
153     var res = npa(arg)
154     t.type(res, "Result", arg + " is result")
155     t.has(res, tests[arg], arg + " matches expectations")
156   })
157
158   // Completely unreasonable invalid garbage throws an error
159   t.throws(function() {
160     npa("this is not a \0 valid package name or url")
161   })
162
163   t.throws(function() {
164     npa("gopher://yea right")
165   }, "Unsupported URL Type: gopher://yea right")
166
167   t.end()
168 })