]> gerrit.simantics Code Review - simantics/district.git/blobdiff - 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
diff --git a/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/unpublish-scoped.js b/org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/npm-registry-client/test/unpublish-scoped.js
new file mode 100644 (file)
index 0000000..26d4ac7
--- /dev/null
@@ -0,0 +1,68 @@
+var test = require('tap').test
+
+var server = require('./lib/server.js')
+var common = require('./lib/common.js')
+var client = common.freshClient()
+
+var cache = require('./fixtures/@npm/npm-registry-client/cache.json')
+
+var REV = '/-rev/213-0a1049cf56172b7d9a1184742c6477b9'
+var PACKAGE = '/@npm%2fnpm-registry-client'
+var URI = common.registry + PACKAGE
+var TOKEN = 'of-glad-tidings'
+var VERSION = '3.0.6'
+var AUTH = {
+  token: TOKEN
+}
+var PARAMS = {
+  version: VERSION,
+  auth: AUTH
+}
+
+test('unpublish a package', function (t) {
+  server.expect('GET', '/@npm%2fnpm-registry-client?write=true', function (req, res) {
+    t.equal(req.method, 'GET')
+
+    res.json(cache)
+  })
+
+  server.expect('PUT', '/@npm%2fnpm-registry-client' + REV, function (req, res) {
+    t.equal(req.method, 'PUT')
+
+    var b = ''
+    req.setEncoding('utf-8')
+    req.on('data', function (d) {
+      b += d
+    })
+
+    req.on('end', function () {
+      var updated = JSON.parse(b)
+      t.notOk(updated.versions[VERSION])
+    })
+
+    res.json(cache)
+  })
+
+  server.expect('GET', PACKAGE, function (req, res) {
+    t.equal(req.method, 'GET')
+
+    res.json(cache)
+  })
+
+  server.expect(
+    'DELETE',
+    PACKAGE + '/-' + PACKAGE + '-' + VERSION + '.tgz' + REV,
+    function (req, res) {
+      t.equal(req.method, 'DELETE')
+
+      res.json({ unpublished: true })
+    }
+  )
+
+  client.unpublish(URI, PARAMS, function (er) {
+    t.ifError(er, 'no errors')
+
+    server.close()
+    t.end()
+  })
+})