• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1var test = require('tap').test
2var common = require('../common-tap.js')
3var mr = common.fakeRegistry.compat
4var server
5
6test('setup', function (t) {
7  mr({port: common.port, throwOnUnmatched: true}, function (err, s) {
8    t.ifError(err, 'registry mocked successfully')
9    server = s
10    t.end()
11  })
12})
13
14test('scoped package names not mangled on error with non-root registry', function (t) {
15  server.get('/@scope%2ffoo').reply(404, {})
16  common.npm(
17    [
18      '--registry=' + common.registry,
19      '--cache=' + common.cache,
20      'cache',
21      'add',
22      '@scope/foo@*',
23      '--force'
24    ],
25    {},
26    function (er, code, stdout, stderr) {
27      t.ifError(er, 'correctly handled 404')
28      t.equal(code, 1, 'exited with error')
29      t.match(stderr, /E404/, 'should notify the sort of error as a 404')
30      t.match(stderr, /@scope(?:%2f|\/)foo/, 'should have package name in error')
31      server.done()
32      server.close()
33      t.end()
34    }
35  )
36})
37