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()
9 var URI = 'https://npm.registry:8043/rewrite'
10 var USERNAME = 'sample'
11 var PASSWORD = '%1234@asdf%'
12 var EMAIL = 'i@izs.me'
28 test('stars call contract', function (t) {
29 t.throws(function () {
30 client.stars(undefined, PARAMS, nop)
33 t.throws(function () {
34 client.stars([], PARAMS, nop)
35 }, 'requires URI to be a string')
37 t.throws(function () {
38 client.stars(URI, undefined, nop)
39 }, 'requires params object')
41 t.throws(function () {
42 client.stars(URI, '', nop)
43 }, 'params must be object')
45 t.throws(function () {
46 client.stars(URI, PARAMS, undefined)
47 }, 'requires callback')
49 t.throws(function () {
50 client.stars(URI, PARAMS, 'callback')
51 }, 'callback must be function')
53 t.test('no username anywhere', function (t) {
55 client.stars(URI, params, function (err) {
58 'must pass either username or auth to stars',
59 'username must not be empty')
67 test('get the stars for a package', function (t) {
68 server.expect('GET', '/-/_view/starredByUser?key=%22sample%22', function (req, res) {
69 t.equal(req.method, 'GET')
74 client.stars('http://localhost:1337/', PARAMS, function (er, info) {
75 t.ifError(er, 'no errors')
76 t.deepEqual(info, USERS, 'got the list of users')