]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/get-basic.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / test / get-basic.js
1 var test = require('tap').test
2
3 var server = require('./lib/server.js')
4 var common = require('./lib/common.js')
5 var client = common.freshClient()
6
7 var us = require('./fixtures/underscore/1.3.3/cache.json')
8 var usroot = require('./fixtures/underscore/cache.json')
9
10 function nop () {}
11
12 var URI = 'https://npm.registry:8043/rewrite'
13 var TIMEOUT = 3600
14 var FOLLOW = false
15 var STALE_OK = true
16 var TOKEN = 'lolbutts'
17 var AUTH = {
18   token: TOKEN
19 }
20 var PARAMS = {
21   timeout: TIMEOUT,
22   follow: FOLLOW,
23   staleOk: STALE_OK,
24   auth: AUTH
25 }
26
27 test('get call contract', function (t) {
28   t.throws(function () {
29     client.get(undefined, PARAMS, nop)
30   }, 'requires a URI')
31
32   t.throws(function () {
33     client.get([], PARAMS, nop)
34   }, 'requires URI to be a string')
35
36   t.throws(function () {
37     client.get(URI, undefined, nop)
38   }, 'requires params object')
39
40   t.throws(function () {
41     client.get(URI, '', nop)
42   }, 'params must be object')
43
44   t.throws(function () {
45     client.get(URI, PARAMS, undefined)
46   }, 'requires callback')
47
48   t.throws(function () {
49     client.get(URI, PARAMS, 'callback')
50   }, 'callback must be function')
51
52   t.end()
53 })
54
55 test('basic request', function (t) {
56   server.expect('/underscore/1.3.3', function (req, res) {
57     res.json(us)
58   })
59
60   server.expect('/underscore', function (req, res) {
61     res.json(usroot)
62   })
63
64   server.expect('/@bigco%2funderscore', function (req, res) {
65     res.json(usroot)
66   })
67
68   t.plan(3)
69   client.get('http://localhost:1337/underscore/1.3.3', PARAMS, function (er, data) {
70     t.deepEqual(data, us)
71   })
72
73   client.get('http://localhost:1337/underscore', PARAMS, function (er, data) {
74     t.deepEqual(data, usroot)
75   })
76
77   client.get('http://localhost:1337/@bigco%2funderscore', PARAMS, function (er, data) {
78     t.deepEqual(data, usroot)
79   })
80 })
81
82 test('cleanup', function (t) {
83   server.close()
84   t.end()
85 })