]> 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/unpublish-scoped.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 / unpublish-scoped.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 cache = require('./fixtures/@npm/npm-registry-client/cache.json')
8
9 var REV = '/-rev/213-0a1049cf56172b7d9a1184742c6477b9'
10 var PACKAGE = '/@npm%2fnpm-registry-client'
11 var URI = common.registry + PACKAGE
12 var TOKEN = 'of-glad-tidings'
13 var VERSION = '3.0.6'
14 var AUTH = {
15   token: TOKEN
16 }
17 var PARAMS = {
18   version: VERSION,
19   auth: AUTH
20 }
21
22 test('unpublish a package', function (t) {
23   server.expect('GET', '/@npm%2fnpm-registry-client?write=true', function (req, res) {
24     t.equal(req.method, 'GET')
25
26     res.json(cache)
27   })
28
29   server.expect('PUT', '/@npm%2fnpm-registry-client' + REV, function (req, res) {
30     t.equal(req.method, 'PUT')
31
32     var b = ''
33     req.setEncoding('utf-8')
34     req.on('data', function (d) {
35       b += d
36     })
37
38     req.on('end', function () {
39       var updated = JSON.parse(b)
40       t.notOk(updated.versions[VERSION])
41     })
42
43     res.json(cache)
44   })
45
46   server.expect('GET', PACKAGE, function (req, res) {
47     t.equal(req.method, 'GET')
48
49     res.json(cache)
50   })
51
52   server.expect(
53     'DELETE',
54     PACKAGE + '/-' + PACKAGE + '-' + VERSION + '.tgz' + REV,
55     function (req, res) {
56       t.equal(req.method, 'DELETE')
57
58       res.json({ unpublished: true })
59     }
60   )
61
62   client.unpublish(URI, PARAMS, function (er) {
63     t.ifError(er, 'no errors')
64
65     server.close()
66     t.end()
67   })
68 })