@@ -36,11 +36,11 @@ describe('GithubRepo / GithubURLs', () => {
3636 } ) ;
3737 it ( 'should throw on bad params' , ( ) => {
3838 assert . throws ( ( ) => {
39- repo = new GithubRepo ( { repoOwner : null , repoProject : null } , null , null ) ;
39+ repo = new GithubRepo ( { repoOwner : null , repoProject : null , githubHost : null } , null , null ) ;
4040 } ) ;
4141 } ) ;
4242 it ( 'should be constructor' , ( ) => {
43- repo = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' } , 'baz' , gitTest . opts ) ;
43+ repo = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' , githubHost : 'github.com' } , 'baz' , gitTest . opts ) ;
4444 urls = repo . urls ;
4545 assert . ok ( urls , 'instance' ) ;
4646 } ) ;
@@ -56,7 +56,7 @@ describe('GithubRepo / GithubURLs', () => {
5656 } ) ;
5757 } ) ;
5858 it ( 'should return replaced urls' , ( ) => {
59- urls = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' } , 'baz' , gitTest . opts ) . urls ;
59+ urls = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' , githubHost : 'github.com' } , 'baz' , gitTest . opts ) . urls ;
6060 var api = 'https://api.github.com/repos/foo/bar' ;
6161 var raw = 'https://raw.githubusercontent.com/foo/bar' ;
6262 var base = 'https://github.com/foo/bar' ;
@@ -66,7 +66,7 @@ describe('GithubRepo / GithubURLs', () => {
6666 assert . strictEqual ( urls . rawFile ( '2ece23298f06d9fb45772fdb1d38086918c80f44' , 'sub/folder/file.txt' ) , rawFile , 'rawFile' ) ;
6767 } ) ;
6868 it ( 'should return correctly replaced urls if repoConfig is modified after repo creation' , ( ) => {
69- var repoConfig = { repoOwner : 'foo' , repoProject : 'bar' } ;
69+ var repoConfig = { repoOwner : 'foo' , repoProject : 'bar' , githubHost : 'github.com' } ;
7070 urls = new GithubRepo ( repoConfig , 'baz' , gitTest . opts ) . urls ;
7171 repoConfig . repoOwner = 'correctOwner' ;
7272 repoConfig . repoProject = 'correctProject' ;
@@ -77,9 +77,19 @@ describe('GithubRepo / GithubURLs', () => {
7777 assert . strictEqual ( urls . base ( ) , base , 'base' ) ;
7878 } ) ;
7979 it ( 'should return no trailing slash' , ( ) => {
80- urls = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' } , 'baz' , gitTest . opts ) . urls ;
80+ urls = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' , githubHost : 'github.com' } , 'baz' , gitTest . opts ) . urls ;
8181 assert . notMatch ( urls . apiBranches ( ) , / \/ $ / , 'apiBranches' ) ;
8282 assert . notMatch ( urls . apiBranch ( 'abc' ) , / \/ $ / , 'apiBranch' ) ;
8383 } ) ;
84+ it ( 'should handle enterprise github urls' , ( ) => {
85+ urls = new GithubRepo ( { repoOwner : 'foo' , repoProject : 'bar' , githubHost : 'github.mycompany.com' } , 'baz' , gitTest . opts ) . urls ;
86+ var api = 'https://github.mycompany.com/api/v3/repos/foo/bar' ;
87+ var raw = 'https://github.mycompany.com/foo/bar/raw' ;
88+ var base = 'https://github.mycompany.com/foo/bar' ;
89+ var rawFile = raw + '/2ece23298f06d9fb45772fdb1d38086918c80f44/sub/folder/file.txt' ;
90+ assert . strictEqual ( urls . api ( ) , api , 'api' ) ;
91+ assert . strictEqual ( urls . base ( ) , base , 'base' ) ;
92+ assert . strictEqual ( urls . rawFile ( '2ece23298f06d9fb45772fdb1d38086918c80f44' , 'sub/folder/file.txt' ) , rawFile , 'rawFile' ) ;
93+ } ) ;
8494 } ) ;
8595} ) ;
0 commit comments