]> 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/tag.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 / tag.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 URI = 'http://localhost:1337/underscore'
10 var USERNAME = 'username'
11 var PASSWORD = '%1234@asdf%'
12 var EMAIL = 'i@izs.me'
13 var VERSION = '1.3.2'
14 var TAG = 'not-lodash'
15 var AUTH = {
16   username: USERNAME,
17   password: PASSWORD,
18   email: EMAIL
19 }
20 var PARAMS = {
21   tag: TAG,
22   version: VERSION,
23   auth: AUTH
24 }
25
26 test('tag call contract', function (t) {
27   t.throws(function () {
28     client.tag(undefined, AUTH, nop)
29   }, 'requires a URI')
30
31   t.throws(function () {
32     client.tag([], AUTH, nop)
33   }, 'requires URI to be a string')
34
35   t.throws(function () {
36     client.tag(URI, undefined, nop)
37   }, 'requires params object')
38
39   t.throws(function () {
40     client.tag(URI, '', nop)
41   }, 'params must be object')
42
43   t.throws(function () {
44     client.tag(URI, AUTH, undefined)
45   }, 'requires callback')
46
47   t.throws(function () {
48     client.tag(URI, AUTH, 'callback')
49   }, 'callback must be function')
50
51   t.throws(
52     function () {
53       var params = { tag: TAG, auth: AUTH }
54       client.tag(URI, params, nop)
55     },
56     { name: 'AssertionError', message: 'must pass version to tag' },
57     'tag must include version'
58   )
59
60   t.throws(
61     function () {
62       var params = { version: VERSION, auth: AUTH }
63       client.tag(URI, params, nop)
64     },
65     { name: 'AssertionError', message: 'must pass tag name to tag' },
66     'tag must include name'
67   )
68
69   t.throws(
70     function () {
71       var params = { version: VERSION, tag: TAG }
72       client.tag(URI, params, nop)
73     },
74     { name: 'AssertionError', message: 'must pass auth to tag' },
75     'params must include auth'
76   )
77
78   t.end()
79 })
80
81 test('tag a package', function (t) {
82   server.expect('PUT', '/underscore/not-lodash', function (req, res) {
83     t.equal(req.method, 'PUT')
84
85     var b = ''
86     req.setEncoding('utf8')
87     req.on('data', function (d) {
88       b += d
89     })
90
91     req.on('end', function () {
92       var updated = JSON.parse(b)
93
94       t.deepEqual(updated, '1.3.2')
95
96       res.statusCode = 201
97       res.json({ tagged: true })
98     })
99   })
100
101   client.tag(URI, PARAMS, function (error, data) {
102     t.ifError(error, 'no errors')
103     t.ok(data.tagged, 'was tagged')
104
105     server.close()
106     t.end()
107   })
108 })