1 var test = require('tap').test
3 var server = require('./lib/server.js')
4 var common = require('./lib/common.js')
5 var client = common.freshClient()
7 var us = require('./fixtures/underscore/1.3.3/cache.json')
8 var usroot = require('./fixtures/underscore/cache.json')
12 var URI = 'https://npm.registry:8043/rewrite'
16 var TOKEN = 'lolbutts'
27 test('get call contract', function (t) {
28 t.throws(function () {
29 client.get(undefined, PARAMS, nop)
32 t.throws(function () {
33 client.get([], PARAMS, nop)
34 }, 'requires URI to be a string')
36 t.throws(function () {
37 client.get(URI, undefined, nop)
38 }, 'requires params object')
40 t.throws(function () {
41 client.get(URI, '', nop)
42 }, 'params must be object')
44 t.throws(function () {
45 client.get(URI, PARAMS, undefined)
46 }, 'requires callback')
48 t.throws(function () {
49 client.get(URI, PARAMS, 'callback')
50 }, 'callback must be function')
55 test('basic request', function (t) {
56 server.expect('/underscore/1.3.3', function (req, res) {
60 server.expect('/underscore', function (req, res) {
64 server.expect('/@bigco%2funderscore', function (req, res) {
69 client.get('http://localhost:1337/underscore/1.3.3', PARAMS, function (er, data) {
73 client.get('http://localhost:1337/underscore', PARAMS, function (er, data) {
74 t.deepEqual(data, usroot)
77 client.get('http://localhost:1337/@bigco%2funderscore', PARAMS, function (er, data) {
78 t.deepEqual(data, usroot)
82 test('cleanup', function (t) {