@@ -10,59 +10,70 @@ import * as assert from "assert"
1010
1111suite ( "Github" , async ( ) => {
1212 test ( "ssh" , async ( ) => {
13- async function findRemote ( hostname : string ) {
14- return "git@github.com:recipeyak/recipeyak.git"
13+ for ( let url of [
14+ "git@github.com:recipeyak/recipeyak.git" ,
15+ "git@github.com:recipeyak/recipeyak" ,
16+ ] ) {
17+ async function findRemote ( hostname : string ) {
18+ return url
19+ }
20+ const gh = new Github ( { } , "origin" , findRemote )
21+ const result = await gh . getUrls ( {
22+ selection : [ 17 , 24 ] ,
23+ head : createSha ( "db99a912f5c4bffe11d91e163cd78ed96589611b" ) ,
24+ relativeFilePath : "frontend/src/components/App.tsx" ,
25+ } )
26+ const expected = {
27+ blobUrl :
28+ "https://github.com/recipeyak/recipeyak/blob/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25" ,
29+ blameUrl :
30+ "https://github.com/recipeyak/recipeyak/blame/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25" ,
31+ compareUrl :
32+ "https://github.com/recipeyak/recipeyak/compare/db99a912f5c4bffe11d91e163cd78ed96589611b" ,
33+ historyUrl :
34+ "https://github.com/recipeyak/recipeyak/commits/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx" ,
35+ prUrl :
36+ "https://github.com/recipeyak/recipeyak/pull/new/db99a912f5c4bffe11d91e163cd78ed96589611b" ,
37+ repoUrl : "https://github.com/recipeyak/recipeyak" ,
38+ }
39+ assert . deepEqual ( result , expected )
1540 }
16- const gh = new Github ( { } , "origin" , findRemote )
17- const result = await gh . getUrls ( {
18- selection : [ 17 , 24 ] ,
19- head : createSha ( "db99a912f5c4bffe11d91e163cd78ed96589611b" ) ,
20- relativeFilePath : "frontend/src/components/App.tsx" ,
21- } )
22- const expected = {
23- blobUrl :
24- "https://github.com/recipeyak/recipeyak/blob/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25" ,
25- blameUrl :
26- "https://github.com/recipeyak/recipeyak/blame/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx#L18-L25" ,
27- compareUrl :
28- "https://github.com/recipeyak/recipeyak/compare/db99a912f5c4bffe11d91e163cd78ed96589611b" ,
29- historyUrl :
30- "https://github.com/recipeyak/recipeyak/commits/db99a912f5c4bffe11d91e163cd78ed96589611b/frontend/src/components/App.tsx" ,
31- prUrl :
32- "https://github.com/recipeyak/recipeyak/pull/new/db99a912f5c4bffe11d91e163cd78ed96589611b" ,
33- repoUrl : "https://github.com/recipeyak/recipeyak" ,
34- }
35- assert . deepEqual ( result , expected )
3641 } )
3742 test ( "https" , async ( ) => {
38- async function findRemote ( hostname : string ) {
39- return "https://github.mycompany.com/recipeyak/recipeyak.git"
43+ for ( let url of [
44+ "git@github.mycompany.com:recipeyak/recipeyak.git" ,
45+ "git@github.mycompany.com:recipeyak/recipeyak" ,
46+ ] ) {
47+ async function findRemote ( hostname : string ) {
48+ return url
49+ }
50+ const gh = new Github (
51+ {
52+ github : { hostnames : [ "github.mycompany.com" ] } ,
53+ } ,
54+ "origin" ,
55+ findRemote ,
56+ )
57+ const result = await gh . getUrls ( {
58+ selection : [ 17 , 24 ] ,
59+ head : createBranch ( "master" ) ,
60+ relativeFilePath : "frontend/src/components/App.tsx" ,
61+ } )
62+ const expected = {
63+ blobUrl :
64+ "https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx#L18-L25" ,
65+ blameUrl :
66+ "https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18-L25" ,
67+ compareUrl :
68+ "https://github.mycompany.com/recipeyak/recipeyak/compare/master" ,
69+ historyUrl :
70+ "https://github.mycompany.com/recipeyak/recipeyak/commits/master/frontend/src/components/App.tsx" ,
71+ prUrl :
72+ "https://github.mycompany.com/recipeyak/recipeyak/pull/new/master" ,
73+ repoUrl : "https://github.mycompany.com/recipeyak/recipeyak" ,
74+ }
75+ assert . deepEqual ( result , expected )
4076 }
41- const gh = new Github (
42- {
43- github : { hostnames : [ "github.mycompany.com" ] } ,
44- } ,
45- "origin" ,
46- findRemote ,
47- )
48- const result = await gh . getUrls ( {
49- selection : [ 17 , 24 ] ,
50- head : createBranch ( "master" ) ,
51- relativeFilePath : "frontend/src/components/App.tsx" ,
52- } )
53- const expected = {
54- blobUrl :
55- "https://github.mycompany.com/recipeyak/recipeyak/blob/master/frontend/src/components/App.tsx#L18-L25" ,
56- blameUrl :
57- "https://github.mycompany.com/recipeyak/recipeyak/blame/master/frontend/src/components/App.tsx#L18-L25" ,
58- compareUrl :
59- "https://github.mycompany.com/recipeyak/recipeyak/compare/master" ,
60- historyUrl :
61- "https://github.mycompany.com/recipeyak/recipeyak/commits/master/frontend/src/components/App.tsx" ,
62- prUrl : "https://github.mycompany.com/recipeyak/recipeyak/pull/new/master" ,
63- repoUrl : "https://github.mycompany.com/recipeyak/recipeyak" ,
64- }
65- assert . deepEqual ( result , expected )
6677 } )
6778} )
6879
0 commit comments