summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/test/star.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/test/star.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/star.js89
1 files changed, 77 insertions, 12 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/test/star.js b/deps/npm/node_modules/npm-registry-client/test/star.js
index 43c8888ef2..1a8576f854 100644
--- a/deps/npm/node_modules/npm-registry-client/test/star.js
+++ b/deps/npm/node_modules/npm-registry-client/test/star.js
@@ -1,22 +1,83 @@
-var tap = require("tap")
+var test = require("tap").test
var server = require("./lib/server.js")
var common = require("./lib/common.js")
+var client = common.freshClient()
+var cache = require("./fixtures/underscore/cache.json")
-var DEP_USER = "username"
+function nop () {}
-var nerfed = "//localhost:" + server.port + "/:"
+var URI = "https://npm.registry:8043/rewrite"
+var STARRED = true
+var USERNAME = "username"
+var PASSWORD = "%1234@asdf%"
+var EMAIL = "i@izs.me"
+var AUTH = {
+ username : USERNAME,
+ password : PASSWORD,
+ email : EMAIL
+}
+var PARAMS = {
+ starred : STARRED,
+ auth : AUTH
+}
-var configuration = {}
-configuration[nerfed + "username"] = DEP_USER
-configuration[nerfed + "_password"] = new Buffer("%1234@asdf%").toString("base64")
-configuration[nerfed + "email"] = "i@izs.me"
+test("star call contract", function (t) {
+ t.throws(function () {
+ client.star(undefined, PARAMS, nop)
+ }, "requires a URI")
-var client = common.freshClient(configuration)
+ t.throws(function () {
+ client.star([], PARAMS, nop)
+ }, "requires URI to be a string")
-var cache = require("./fixtures/underscore/cache.json")
+ t.throws(function () {
+ client.star(URI, undefined, nop)
+ }, "requires params object")
+
+ t.throws(function () {
+ client.star(URI, "", nop)
+ }, "params must be object")
+
+ t.throws(function () {
+ client.star(URI, PARAMS, undefined)
+ }, "requires callback")
+
+ t.throws(function () {
+ client.star(URI, PARAMS, "callback")
+ }, "callback must be function")
+
+ t.throws(
+ function () {
+ var params = {
+ starred : STARRED
+ }
+ client.star(URI, params, nop)
+ },
+ { name : "AssertionError", message : "must pass auth to star" },
+ "params must include auth"
+ )
+
+ t.test("token auth disallowed in star", function (t) {
+ var params = {
+ auth : {
+ token : "lol"
+ }
+ }
+ client.star(URI, params, function (err) {
+ t.equal(
+ err && err.message,
+ "This operation is unsupported for token-based auth",
+ "star doesn't support token-based auth"
+ )
+ t.end()
+ })
+ })
+
+ t.end()
+})
-tap.test("star a package", function (t) {
+test("star a package", function (t) {
server.expect("GET", "/underscore?write=true", function (req, res) {
t.equal(req.method, "GET")
@@ -46,14 +107,18 @@ tap.test("star a package", function (t) {
current + " still likes this package"
)
}
- t.ok(updated.users[DEP_USER], "user is in the starred list")
+ t.ok(updated.users[USERNAME], "user is in the starred list")
res.statusCode = 201
res.json({starred:true})
})
})
- client.star("http://localhost:1337/underscore", true, function (error, data) {
+ var params = {
+ starred : STARRED,
+ auth : AUTH
+ }
+ client.star("http://localhost:1337/underscore", params, function (error, data) {
t.ifError(error, "no errors")
t.ok(data.starred, "was starred")