UNPKG

2.48 kBJavaScriptView Raw
1var test = require('tap').test
2
3var normalize = require('../normalize-git-url.js')
4
5test('basic normalization tests', function (t) {
6 t.same(
7 normalize('git+ssh://user@hostname:project.git#commit-ish'),
8 { url: 'user@hostname:project.git', branch: 'commit-ish' }
9 )
10 t.same(
11 normalize('git+http://user@hostname/project/blah.git#commit-ish'),
12 { url: 'http://user@hostname/project/blah.git', branch: 'commit-ish' }
13 )
14 t.same(
15 normalize('git+https://user@hostname/project/blah.git#commit-ish'),
16 { url: 'https://user@hostname/project/blah.git', branch: 'commit-ish' }
17 )
18 t.same(
19 normalize('git+https://user@hostname:project/blah.git#commit-ish'),
20 { url: 'https://user@hostname/project/blah.git', branch: 'commit-ish' }
21 )
22 t.same(
23 normalize('git+ssh://git@github.com:npm/npm.git#v1.0.27'),
24 { url: 'git@github.com:npm/npm.git', branch: 'v1.0.27' }
25 )
26 t.same(
27 normalize('git+ssh://git@github.com:/npm/npm.git#v1.0.28'),
28 { url: 'git@github.com:/npm/npm.git', branch: 'v1.0.28' }
29 )
30 t.same(
31 normalize('git+ssh://git@github.com:org/repo#dev'),
32 { url: 'git@github.com:org/repo', branch: 'dev' }
33 )
34 t.same(
35 normalize('git+ssh://git@github.com/org/repo#dev'),
36 { url: 'ssh://git@github.com/org/repo', branch: 'dev' }
37 )
38 t.same(
39 normalize('git+ssh://foo:22/some/path'),
40 { url: 'ssh://foo:22/some/path', branch: 'master' }
41 )
42 t.same(
43 normalize('git@github.com:org/repo#dev'),
44 { url: 'git@github.com:org/repo', branch: 'dev' }
45 )
46 t.same(
47 normalize('git+https://github.com/KenanY/node-uuid'),
48 { url: 'https://github.com/KenanY/node-uuid', branch: 'master' }
49 )
50 t.same(
51 normalize('git+https://github.com/KenanY/node-uuid#7a018f2d075b03a73409e8356f9b29c9ad4ea2c5'),
52 { url: 'https://github.com/KenanY/node-uuid', branch: '7a018f2d075b03a73409e8356f9b29c9ad4ea2c5' }
53 )
54 t.same(
55 normalize('git+ssh://git@git.example.com:b/b.git#v1.0.0'),
56 { url: 'git@git.example.com:b/b.git', branch: 'v1.0.0' }
57 )
58 t.same(
59 normalize('git+ssh://git@github.com:npm/npm-proto.git#othiym23/organized'),
60 { url: 'git@github.com:npm/npm-proto.git', branch: 'othiym23/organized' }
61 )
62 t.same(
63 normalize('git+file:///foo/bar.git'),
64 { url: 'file:///foo/bar.git', branch: 'master' }
65 )
66 t.same(
67 normalize('git+file://C:\\Users\\hello\\testing.git#zkat/windows-files'),
68 { url: 'file://C:\\Users\\hello\\testing.git', branch: 'zkat/windows-files'}
69 )
70 t.end()
71})