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