1 var npa = require("../npa.js")
2 var path = require("path")
4 require("tap").test("basic", function (t) {
11 spec: ">=1.2.0 <1.3.0",
43 "@f fo o al/ a d s ;f ": {
44 raw: "@f fo o al/ a d s ;f",
46 rawSpec: "@f fo o al/ a d s ;f",
47 spec: path.resolve("@f fo o al/ a d s ;f"),
66 "git+ssh://git@notgithub.com/user/foo#1.2.3": {
69 spec: "ssh://git@notgithub.com/user/foo#1.2.3",
70 raw: "git+ssh://git@notgithub.com/user/foo#1.2.3"
73 "git+file://path/to/repo#1.2.3": {
76 spec: "file://path/to/repo#1.2.3",
77 raw: "git+file://path/to/repo#1.2.3"
80 "git://notgithub.com/user/foo": {
83 spec: "git://notgithub.com/user/foo",
84 raw: "git://notgithub.com/user/foo"
87 "@foo/bar@git+ssh://notgithub.com/user/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"
98 spec: path.resolve(__dirname, "/path/to/foo"),
102 "file:path/to/foo": {
106 raw: "file:path/to/foo"
109 "file:~/path/to/foo": {
112 spec: "~/path/to/foo",
113 raw: "file:~/path/to/foo"
116 "file:../path/to/foo": {
119 spec: "../path/to/foo",
120 raw: "file:../path/to/foo"
123 "file:///path/to/foo": {
126 spec: "/path/to/foo",
127 raw: "file:///path/to/foo"
130 "https://server.com/foo.tgz": {
133 spec: "https://server.com/foo.tgz",
134 raw: "https://server.com/foo.tgz"
152 Object.keys(tests).forEach(function (arg) {
154 t.type(res, "Result", arg + " is result")
155 t.has(res, tests[arg], arg + " matches expectations")
158 // Completely unreasonable invalid garbage throws an error
159 t.throws(function() {
160 npa("this is not a \0 valid package name or url")
163 t.throws(function() {
164 npa("gopher://yea right")
165 }, "Unsupported URL Type: gopher://yea right")