@@ -13,6 +13,7 @@ import {
13
13
getVersionInputFromPlainFile ,
14
14
getVersionInputFromTomlFile ,
15
15
getNextPageUrl ,
16
+ isGhes ,
16
17
IS_WINDOWS ,
17
18
getDownloadFileName
18
19
} from '../src/utils' ;
@@ -195,3 +196,41 @@ describe('getDownloadFileName', () => {
195
196
}
196
197
} ) ;
197
198
} ) ;
199
+
200
+ describe ( 'isGhes' , ( ) => {
201
+ const pristineEnv = process . env ;
202
+
203
+ beforeEach ( ( ) => {
204
+ jest . resetModules ( ) ;
205
+ process . env = { ...pristineEnv } ;
206
+ } ) ;
207
+
208
+ afterAll ( ( ) => {
209
+ process . env = pristineEnv ;
210
+ } ) ;
211
+
212
+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is not defined' , async ( ) => {
213
+ delete process . env [ 'GITHUB_SERVER_URL' ] ;
214
+ expect ( isGhes ( ) ) . toBeFalsy ( ) ;
215
+ } ) ;
216
+
217
+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to github.com' , async ( ) => {
218
+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://github.com' ;
219
+ expect ( isGhes ( ) ) . toBeFalsy ( ) ;
220
+ } ) ;
221
+
222
+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL' , async ( ) => {
223
+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://contoso.ghe.com' ;
224
+ expect ( isGhes ( ) ) . toBeFalsy ( ) ;
225
+ } ) ;
226
+
227
+ it ( 'returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix' , async ( ) => {
228
+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://mock-github.localhost' ;
229
+ expect ( isGhes ( ) ) . toBeFalsy ( ) ;
230
+ } ) ;
231
+
232
+ it ( 'returns true when the GITHUB_SERVER_URL environment variable is set to some other URL' , async ( ) => {
233
+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://src.onpremise.fabrikam.com' ;
234
+ expect ( isGhes ( ) ) . toBeTruthy ( ) ;
235
+ } ) ;
236
+ } ) ;
0 commit comments