]> 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-error-403.js
Adding new mappable attributes for vertices and edges
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / npm-registry-client / test / get-error-403.js
1 var tap = require('tap')
2
3 var server = require('./lib/server.js')
4 var common = require('./lib/common.js')
5
6 tap.test('get fails with 403', function (t) {
7   server.expect('/habanero', function (req, res) {
8     t.equal(req.method, 'GET', 'got expected method')
9
10     res.writeHead(403)
11     res.end('{"error":"get that cat out of the toilet that\'s gross omg"}')
12   })
13
14   var client = common.freshClient()
15   client.config.retry.minTimeout = 100
16   client.get(
17     'http://localhost:1337/habanero',
18     {},
19     function (er) {
20       t.ok(er, 'failed as expected')
21
22       t.equal(er.statusCode, 403, 'status code was attached as expected')
23       t.equal(er.code, 'E403', 'error code was formatted as expected')
24       t.equal(
25         er.message,
26         'get that cat out of the toilet that\'s gross omg : habanero',
27         'got error message'
28       )
29
30       server.close()
31       t.end()
32     }
33   )
34 })