@@ -24,13 +24,50 @@ describe('getServerUrl tests', () => {
2424} )
2525
2626describe ( 'isGhes tests' , ( ) => {
27+ const pristineEnv = process . env
28+
29+ beforeEach ( ( ) => {
30+ jest . resetModules ( )
31+ process . env = { ...pristineEnv }
32+ } )
33+
34+ afterAll ( ( ) => {
35+ process . env = pristineEnv
36+ } )
37+
2738 it ( 'basics' , async ( ) => {
39+ delete process . env [ 'GITHUB_SERVER_URL' ]
2840 expect ( urlHelper . isGhes ( ) ) . toBeFalsy ( )
2941 expect ( urlHelper . isGhes ( 'https://github.com' ) ) . toBeFalsy ( )
3042 expect ( urlHelper . isGhes ( 'https://contoso.ghe.com' ) ) . toBeFalsy ( )
3143 expect ( urlHelper . isGhes ( 'https://test.github.localhost' ) ) . toBeFalsy ( )
3244 expect ( urlHelper . isGhes ( 'https://src.onpremise.fabrikam.com' ) ) . toBeTruthy ( )
3345 } )
46+
47+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is not defined' , async ( ) => {
48+ delete process . env [ 'GITHUB_SERVER_URL' ]
49+ expect ( urlHelper . isGhes ( ) ) . toBeFalsy ( )
50+ } )
51+
52+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to github.com' , async ( ) => {
53+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://github.com'
54+ expect ( urlHelper . isGhes ( ) ) . toBeFalsy ( )
55+ } )
56+
57+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL' , async ( ) => {
58+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://contoso.ghe.com'
59+ expect ( urlHelper . isGhes ( ) ) . toBeFalsy ( )
60+ } )
61+
62+ it ( 'returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix' , async ( ) => {
63+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://mock-github.localhost'
64+ expect ( urlHelper . isGhes ( ) ) . toBeFalsy ( )
65+ } )
66+
67+ it ( 'returns true when the GITHUB_SERVER_URL environment variable is set to some other URL' , async ( ) => {
68+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://src.onpremise.fabrikam.com'
69+ expect ( urlHelper . isGhes ( ) ) . toBeTruthy ( )
70+ } )
3471} )
3572
3673describe ( 'getServerApiUrl tests' , ( ) => {
0 commit comments