-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
79 lines (63 loc) · 3.41 KB
/
test.js
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
/* global describe, it */
var parse = require('./')
var assert = require('better-assert')
describe('parse(url)', function () {
it('should support git://*', function () {
var url = 'git@bitbucket.org:alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should support git://*.git', function () {
var url = 'git://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should support https://*', function () {
var url = 'https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should support https://*.git', function () {
var url = 'https://alex@bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should return undefined on failure', function () {
var url = 'git://bitbucket.org/alex-e-leon/.git'
assert(parse(url) == null)
})
it('should parse git@bitbucket.org:/alex-e-leon/node-bitbucket-url-from-git.git', function () {
var url = 'git@bitbucket.org:/alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should parse git@bitbucket.com:bcoe/thumbd.git#2.7.0', function () {
var url = 'git@bitbucket.org:alex-e-leon/node-bitbucket-url-from-git.git#2.7.0'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should parse git+https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git', function () {
var url = 'git+https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
it('should parse git+ssh://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git', function () {
var url = 'git+ssh://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git.git'
parse(url).should.eql('https://bitbucket.org/alex-e-leon/node-bitbucket-url-from-git')
})
// snippet urls.
it('should parse git@ snippet urls', function () {
var url = 'git@bitbucket.org:snippets/alex-e-leon/nepk84/a-snippet.git'
parse(url).should.equal('https://bitbucket.org/snippets/alex-e-leon/nepk84')
})
it('should parse https://gist urls', function () {
var url = 'https://alex@bitbucket.org/snippets/alex-e-leon/nepk84/a-snippet.git'
parse(url).should.equal('https://bitbucket.org/snippets/alex-e-leon/nepk84')
})
// Handle arbitrary GitHub Enterprise domains.
it('should parse parse extra bitbucket enterprise urls provided', function () {
var url = 'git://bitbucket.example.com/alex-e-leon/node-bitbucket-url-from-git.git'
parse(
url, {extraBaseUrls: ['bitbucket.example.com']}
).should.equal('https://bitbucket.example.com/alex-e-leon/node-bitbucket-url-from-git')
})
it('should parse bitbucket enterprise urls with multiple subdomains', function () {
var url = 'git://bitbucket.internal.example.com/alex-e-leon/node-bitbucket-url-from-git.git'
parse(
url, {extraBaseUrls: ['bitbucket.internal.example.com']}
).should.equal('https://bitbucket.internal.example.com/alex-e-leon/node-bitbucket-url-from-git')
})
})