Sha256: d523124c13bf8665ecdbeded25f0f122e679fbb19442ccb46bbc9467df5455d5

Contents?: true

Size: 1.67 KB

Versions: 5

Compression:

Stored size: 1.67 KB

Contents

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)
    server.close()
    t.end()
  })
})

Version data entries

5 entries across 4 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/deps/npm/node_modules/npm-registry-client/test/ping.js
node-compiler-0.9.0 vendor/node-v7.2.1/deps/npm/node_modules/npm-registry-client/test/ping.js
node-compiler-0.8.0 vendor/node-v7.2.0/deps/npm/node_modules/npm-registry-client/test/ping.js
node-compiler-0.7.0 vendor/node-v6.9.1/deps/npm/node_modules/npm-registry-client/test/ping.js
node-compiler-0.7.0 vendor/node-v7.1.0/deps/npm/node_modules/npm-registry-client/test/ping.js