]> 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/dist-tags-rm.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 / dist-tags-rm.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 function nop () {}
8
9 var BASE_URL = 'http://localhost:1337/'
10 var URI = '/-/package/underscore/dist-tags/test'
11 var TOKEN = 'foo'
12 var AUTH = {
13   token: TOKEN
14 }
15 var PACKAGE = 'underscore'
16 var DIST_TAG = 'test'
17 var PARAMS = {
18   'package': PACKAGE,
19   distTag: DIST_TAG,
20   auth: AUTH
21 }
22
23 test('distTags.rm call contract', function (t) {
24   t.throws(function () {
25     client.distTags.rm(undefined, AUTH, nop)
26   }, 'requires a URI')
27
28   t.throws(function () {
29     client.distTags.rm([], PARAMS, nop)
30   }, 'requires URI to be a string')
31
32   t.throws(function () {
33     client.distTags.rm(BASE_URL, undefined, nop)
34   }, 'requires params object')
35
36   t.throws(function () {
37     client.distTags.rm(BASE_URL, '', nop)
38   }, 'params must be object')
39
40   t.throws(function () {
41     client.distTags.rm(BASE_URL, PARAMS, undefined)
42   }, 'requires callback')
43
44   t.throws(function () {
45     client.distTags.rm(BASE_URL, PARAMS, 'callback')
46   }, 'callback must be function')
47
48   t.throws(
49     function () {
50       var params = {
51         distTag: DIST_TAG,
52         auth: AUTH
53       }
54       client.distTags.rm(BASE_URL, params, nop)
55     },
56     {
57       name: 'AssertionError',
58       message: 'must pass package name to distTags.rm'
59     },
60     'distTags.rm must include package name'
61   )
62
63   t.throws(
64     function () {
65       var params = {
66         'package': PACKAGE,
67         auth: AUTH
68       }
69       client.distTags.rm(BASE_URL, params, nop)
70     },
71     {
72       name: 'AssertionError',
73       message: 'must pass package distTag name to distTags.rm'
74     },
75     'distTags.rm must include dist-tag'
76   )
77
78   t.throws(
79     function () {
80       var params = {
81         'package': PACKAGE,
82         distTag: DIST_TAG
83       }
84       client.distTags.rm(BASE_URL, params, nop)
85     },
86     { name: 'AssertionError', message: 'must pass auth to distTags.rm' },
87     'distTags.rm must include auth'
88   )
89
90   t.end()
91 })
92
93 test('remove a dist-tag from a package', function (t) {
94   server.expect('DELETE', URI, function (req, res) {
95     t.equal(req.method, 'DELETE')
96
97     var b = ''
98     req.setEncoding('utf8')
99     req.on('data', function (d) {
100       b += d
101     })
102
103     req.on('end', function () {
104       t.notOk(b, 'got no message body')
105
106       res.statusCode = 200
107       res.json({})
108     })
109   })
110
111   client.distTags.rm(BASE_URL, PARAMS, function (error, data) {
112     t.ifError(error, 'no errors')
113     t.notOk(data.test, 'dist-tag removed')
114
115     server.close()
116     t.end()
117   })
118 })