]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/node_modules/github-url-from-git/test.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / node_modules / github-url-from-git / test.js
1 var parse = require('./');
2 var assert = require('better-assert');
3
4 describe('parse(url)', function(){
5   it('should support git://*', function(){
6     var url = 'git://github.com/jamesor/mongoose-versioner';
7     parse(url).should.equal('https://github.com/jamesor/mongoose-versioner');
8   })
9
10   it('should support git://*.git', function(){
11     var url = 'git://github.com/treygriffith/cellar.git';
12     parse(url).should.equal('https://github.com/treygriffith/cellar');
13   })
14
15   it('should support https://*', function(){
16     var url = 'https://github.com/Empeeric/i18n-node';
17     parse(url).should.equal('https://github.com/Empeeric/i18n-node');
18   })
19
20   it('should support https://*.git', function(){
21     var url = 'https://jpillora@github.com/banchee/tranquil.git';
22     parse(url).should.equal('https://github.com/banchee/tranquil');
23   })
24
25   it('should return undefined on failure', function(){
26     var url = 'git://github.com/justgord/.git';
27     assert(null == parse(url));
28   })
29
30   it('should parse git@github.com:bcoe/thumbd.git', function() {
31     var url = 'git@github.com:bcoe/thumbd.git';
32     parse(url).should.eql('https://github.com/bcoe/thumbd');
33   })
34
35   it('should parse git@github.com:bcoe/thumbd.git#2.7.0', function() {
36     var url = 'git@github.com:bcoe/thumbd.git#2.7.0';
37     parse(url).should.eql('https://github.com/bcoe/thumbd');
38   })
39
40   it('should parse git+https://github.com/bcoe/thumbd.git', function() {
41     var url = 'git+https://github.com/bcoe/thumbd.git';
42     parse(url).should.eql('https://github.com/bcoe/thumbd');
43   })
44
45   it('should parse git+ssh://github.com/bcoe/thumbd.git', function() {
46     var url = 'git+ssh://github.com/bcoe/thumbd.git';
47     parse(url).should.eql('https://github.com/bcoe/thumbd');
48   })
49
50   it('should parse https://EastCloud@github.com/EastCloud/node-websockets.git', function() {
51     var url = 'https://EastCloud@github.com/EastCloud/node-websockets.git';
52     parse(url).should.eql('https://github.com/EastCloud/node-websockets');
53   })
54
55   // gist urls.
56
57   it('should parse git@gist urls', function() {
58     var url = 'git@gist.github.com:3135914.git';
59     parse(url).should.equal('https://gist.github.com/3135914')
60   })
61
62   it('should parse https://gist urls', function() {
63     var url = 'https://gist.github.com/3135914.git';
64     parse(url).should.equal('https://gist.github.com/3135914')
65   })
66
67   // Handle arbitrary GitHub Enterprise domains.
68
69   it('should parse parse extra GHE urls provided', function() {
70     var url = 'git://github.example.com/treygriffith/cellar.git';
71     parse(
72       url, {extraBaseUrls: ['github.example.com']}
73     ).should.equal('https://github.example.com/treygriffith/cellar');
74   });
75
76   it('should parse GHE urls with multiple subdomains', function() {
77     var url = 'git://github.internal.example.com/treygriffith/cellar.git';
78     parse(
79       url, {extraBaseUrls: ['github.internal.example.com']}
80     ).should.equal('https://github.internal.example.com/treygriffith/cellar');
81   });
82 })
83
84 describe('re', function() {
85   it('should expose GitHub url parsing regex', function() {
86     parse.re.source.should.equal(
87       /^(?:https?:\/\/|git:\/\/|git\+ssh:\/\/|git\+https:\/\/)?(?:[^@]+@)?(gist.github.com|github.com)[:\/]([^\/]+\/[^\/]+?|[0-9]+)$/.source
88     )
89   });
90 })