@@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => {
209209 expect ( warningSpy ) . toHaveBeenCalledWith ( warningMessage ) ;
210210 } ) ;
211211} ) ;
212+
213+ describe ( 'isGhes' , ( ) => {
214+ const pristineEnv = process . env ;
215+
216+ beforeEach ( ( ) => {
217+ jest . resetModules ( ) ;
218+ process . env = { ...pristineEnv } ;
219+ } ) ;
220+
221+ afterAll ( ( ) => {
222+ process . env = pristineEnv ;
223+ } ) ;
224+
225+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is not defined' , async ( ) => {
226+ delete process . env [ 'GITHUB_SERVER_URL' ] ;
227+ expect ( cacheUtils . isGhes ( ) ) . toBeFalsy ( ) ;
228+ } ) ;
229+
230+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to github.com' , async ( ) => {
231+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://github.com' ;
232+ expect ( cacheUtils . isGhes ( ) ) . toBeFalsy ( ) ;
233+ } ) ;
234+
235+ it ( 'returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL' , async ( ) => {
236+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://contoso.ghe.com' ;
237+ expect ( cacheUtils . isGhes ( ) ) . toBeFalsy ( ) ;
238+ } ) ;
239+
240+ it ( 'returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix' , async ( ) => {
241+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://mock-github.localhost' ;
242+ expect ( cacheUtils . isGhes ( ) ) . toBeFalsy ( ) ;
243+ } ) ;
244+
245+ it ( 'returns true when the GITHUB_SERVER_URL environment variable is set to some other URL' , async ( ) => {
246+ process . env [ 'GITHUB_SERVER_URL' ] = 'https://src.onpremise.fabrikam.com' ;
247+ expect ( cacheUtils . isGhes ( ) ) . toBeTruthy ( ) ;
248+ } ) ;
249+ } ) ;
0 commit comments