• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict'
2const test = require('tap').test
3const npa = require('npm-package-arg')
4const isRegistry = require('../../lib/utils/is-registry.js')
5
6test('current npa', (t) => {
7  t.is(Boolean(isRegistry(npa('foo@1.0.0'))), true, 'version')
8  t.is(Boolean(isRegistry(npa('foo@^1.0.0'))), true, 'range')
9  t.is(Boolean(isRegistry(npa('foo@test'))), true, 'tag')
10  t.is(Boolean(isRegistry(npa('foo@git://foo.bar/test.git'))), false, 'git')
11  t.is(Boolean(isRegistry(npa('foo@foo/bar'))), false, 'github')
12  t.is(Boolean(isRegistry(npa('foo@http://example.com/example.tgz'))), false, 'remote')
13  t.is(Boolean(isRegistry(npa('foo@file:example.tgz'))), false, 'file')
14  t.is(Boolean(isRegistry(npa('foo@file:example/'))), false, 'dir')
15  t.done()
16})
17
18test('legacy spec data', (t) => {
19  t.is(Boolean(isRegistry({type: 'version'})), true, 'version')
20  t.is(Boolean(isRegistry({type: 'range'})), true, 'range')
21  t.is(Boolean(isRegistry({type: 'tag'})), true, 'tag')
22  t.is(Boolean(isRegistry({type: 'git'})), false, 'git')
23  t.is(Boolean(isRegistry({type: 'file'})), false, 'file')
24  t.is(Boolean(isRegistry({type: 'directory'})), false, 'directory')
25  t.is(Boolean(isRegistry({type: 'remote'})), false, 'remote')
26  t.done()
27})
28