1 var test = require("tap").test;
2 var rps = require("../index.js")
3 var path = require("path")
5 test("npa-basic", function (t) {
12 spec: ">=1.2.0 <1.3.0",
44 "@f fo o al/ a d s ;f ": {
45 raw: "@f fo o al/ a d s ;f",
47 rawSpec: "@f fo o al/ a d s ;f",
48 spec: path.resolve("@f fo o al/ a d s ;f"),
67 "git+ssh://git@notgithub.com/user/foo#1.2.3": {
70 spec: "ssh://git@notgithub.com/user/foo#1.2.3",
71 raw: "git+ssh://git@notgithub.com/user/foo#1.2.3"
74 "git+file://path/to/repo#1.2.3": {
77 spec: "file://path/to/repo#1.2.3",
78 raw: "git+file://path/to/repo#1.2.3"
81 "git://notgithub.com/user/foo": {
84 spec: "git://notgithub.com/user/foo",
85 raw: "git://notgithub.com/user/foo"
88 "@foo/bar@git+ssh://notgithub.com/user/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"
102 "file:path/to/foo": {
105 spec: path.resolve(__dirname,"..","path/to/foo"),
106 raw: "file:path/to/foo"
108 "file:../path/to/foo": {
111 spec: path.resolve(__dirname,"..","../path/to/foo"),
112 raw: "file:../path/to/foo"
114 "file:///path/to/foo": {
117 spec: "/path/to/foo",
118 raw: "file:///path/to/foo"
121 "https://server.com/foo.tgz": {
124 spec: "https://server.com/foo.tgz",
125 raw: "https://server.com/foo.tgz"
143 t.plan( 2 + Object.keys(tests).length * 3 )
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")
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) {
158 rps("gopher://yea right", path.resolve(__dirname,'..'), function (err) {
159 t.ok(err, "Unsupported URL Type: gopher://yea right")