summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/npm-package-arg/test/github.js
blob: a7cc1f462fd1165b69000028186df3cbab30f3de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var npa = require('../npa.js')

require('tap').test('basic', function (t) {
  t.setMaxListeners(999)

  var tests = {
    'user/foo-js': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:user/foo-js',
      raw: 'user/foo-js'
    },

    'user/foo-js#bar/baz': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:user/foo-js#bar/baz',
      raw: 'user/foo-js#bar/baz'
    },

    'user..blerg--/..foo-js# . . . . . some . tags / / /': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:user..blerg--/..foo-js# . . . . . some . tags / / /',
      raw: 'user..blerg--/..foo-js# . . . . . some . tags / / /'
    },

    'user/foo-js#bar/baz/bin': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      raw: 'user/foo-js#bar/baz/bin'
    },

    'foo@user/foo-js': {
      name: 'foo',
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:user/foo-js',
      raw: 'foo@user/foo-js'
    },

    'github:user/foo-js': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:user/foo-js',
      raw: 'github:user/foo-js'
    },

    'git+ssh://git@github.com/user/foo#1.2.3': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'git+ssh://git@github.com/user/foo.git#1.2.3',
      raw: 'git+ssh://git@github.com/user/foo#1.2.3'
    },

    'git://github.com/user/foo': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'git://github.com/user/foo.git',
      raw: 'git://github.com/user/foo'
    },

    'https://github.com/user/foo.git': {
      name: null,
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'git+https://github.com/user/foo.git',
      raw: 'https://github.com/user/foo.git'
    },

    '@foo/bar@git+ssh://github.com/user/foo': {
      name: '@foo/bar',
      scope: '@foo',
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'git+ssh://git@github.com/user/foo.git',
      rawSpec: 'git+ssh://github.com/user/foo',
      raw: '@foo/bar@git+ssh://github.com/user/foo'
    },

    'foo@bar/foo': {
      name: 'foo',
      type: 'hosted',
      hosted: { type: 'github' },
      spec: 'github:bar/foo',
      raw: 'foo@bar/foo'
    }
  }

  Object.keys(tests).forEach(function (arg) {
    var res = npa(arg)
    t.type(res, 'Result', arg + ' is a result')
    t.has(res, tests[arg], arg + ' matches expectations')
  })

  t.end()
})