11import { TestBed } from '@angular/core/testing' ;
2+
3+ import { environment } from '../../../environments/environment' ;
24import { BrowserHardRedirectService } from './browser-hard-redirect.service' ;
35
46describe ( 'BrowserHardRedirectService' , ( ) => {
57 let origin : string ;
68 let mockLocation : Location ;
79 let service : BrowserHardRedirectService ;
10+ let originalBaseUrl ;
811
912 beforeEach ( ( ) => {
1013 origin = 'https://test-host.com:4000' ;
@@ -19,11 +22,22 @@ describe('BrowserHardRedirectService', () => {
1922 } as Location ;
2023 spyOn ( mockLocation , 'replace' ) ;
2124
25+ // Store original environment variable to restore after tests
26+ originalBaseUrl = environment . ui . baseUrl ;
27+
28+ // Set environment variable to match our mock location origin for testing
29+ environment . ui . baseUrl = origin ;
30+
2231 service = new BrowserHardRedirectService ( mockLocation ) ;
2332
2433 TestBed . configureTestingModule ( { } ) ;
2534 } ) ;
2635
36+ afterEach ( ( ) => {
37+ // Restore original environment variable after tests
38+ environment . ui . baseUrl = originalBaseUrl ;
39+ } ) ;
40+
2741 it ( 'should be created' , ( ) => {
2842 expect ( service ) . toBeTruthy ( ) ;
2943 } ) ;
@@ -51,7 +65,7 @@ describe('BrowserHardRedirectService', () => {
5165 describe ( 'when requesting the origin' , ( ) => {
5266
5367 it ( 'should return the location origin' , ( ) => {
54- expect ( service . getCurrentOrigin ( ) ) . toEqual ( origin ) ;
68+ expect ( service . getBaseUrl ( ) ) . toEqual ( origin ) ;
5569 } ) ;
5670 } ) ;
5771
0 commit comments