summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-registry-client/test/ping.js
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2015-07-09 20:48:26 -0700
committerJeremiah Senkpiel <fishrock123@rocketmail.com>2015-07-16 12:26:54 -0700
commit938cc757bb996244df6301cd91187789f4f8a909 (patch)
treee701fd52797d3babf9f1ab3355c96d2d8457c0eb /deps/npm/node_modules/npm-registry-client/test/ping.js
parent6c3aabf455f5ed9c65bd6ae1ea208c752317216b (diff)
downloadnode-new-938cc757bb996244df6301cd91187789f4f8a909.tar.gz
deps: upgrade to npm 2.13.0
PR-URL: https://github.com/nodejs/io.js/pull/2152 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/test/ping.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/test/ping.js75
1 files changed, 75 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/test/ping.js b/deps/npm/node_modules/npm-registry-client/test/ping.js
new file mode 100644
index 0000000000..002d8ba8f2
--- /dev/null
+++ b/deps/npm/node_modules/npm-registry-client/test/ping.js
@@ -0,0 +1,75 @@
+var test = require('tap').test
+
+var server = require('./lib/server.js')
+var common = require('./lib/common.js')
+var client = common.freshClient()
+
+function nop () {}
+
+var TOKEN = 'not-bad-meaning-bad-but-bad-meaning-wombat'
+var AUTH = { token: TOKEN }
+var PARAMS = { auth: AUTH }
+var DEP_USER = 'username'
+var HOST = 'localhost'
+
+test('ping call contract', function (t) {
+ t.throws(function () {
+ client.ping(undefined, AUTH, nop)
+ }, 'requires a URI')
+
+ t.throws(function () {
+ client.ping([], AUTH, nop)
+ }, 'requires URI to be a string')
+
+ t.throws(function () {
+ client.ping(common.registry, undefined, nop)
+ }, 'requires params object')
+
+ t.throws(function () {
+ client.ping(common.registry, '', nop)
+ }, 'params must be object')
+
+ t.throws(function () {
+ client.ping(common.registry, AUTH, undefined)
+ }, 'requires callback')
+
+ t.throws(function () {
+ client.ping(common.registry, AUTH, 'callback')
+ }, 'callback must be function')
+
+ t.throws(
+ function () {
+ var params = {}
+ client.ping(common.registry, params, nop)
+ },
+ { name: 'AssertionError', message: 'must pass auth to ping' },
+ 'must pass auth to ping'
+ )
+
+ t.end()
+})
+
+test('ping', function (t) {
+ server.expect('GET', '/-/ping?write=true', function (req, res) {
+ t.equal(req.method, 'GET')
+ res.statusCode = 200
+ res.json({
+ ok: true,
+ host: HOST,
+ peer: HOST,
+ username: DEP_USER
+ })
+ })
+
+ client.ping(common.registry, PARAMS, function (error, found) {
+ t.ifError(error, 'no errors')
+ var wanted = {
+ ok: true,
+ host: HOST,
+ peer: HOST,
+ username: DEP_USER
+ }
+ t.same(found, wanted)
+ t.end()
+ })
+})