@@ -13,6 +13,7 @@ import {
1313 getVersionInputFromPlainFile ,
1414 getVersionInputFromTomlFile ,
1515 getNextPageUrl ,
16+ isGhes ,
1617 IS_WINDOWS ,
1718 getDownloadFileName
1819} from '../src/utils' ;
@@ -195,3 +196,41 @@ describe('getDownloadFileName', () => {
195196 }
196197 } ) ;
197198} ) ;
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