@@ -8,7 +8,7 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
88import { By } from '@angular/platform-browser' ;
99import { NavigationEnd , Router } from '@angular/router' ;
1010
11- import { OSFConfigService } from '@core/services/osf-config.service ' ;
11+ import { ENVIRONMENT } from '@core/provider/environment.provider ' ;
1212import { GetCurrentUser , UserState } from '@core/store/user' ;
1313import { UserEmailsState } from '@core/store/user-emails' ;
1414
@@ -22,7 +22,6 @@ import { GoogleTagManagerService } from 'angular-google-tag-manager';
2222describe ( 'Component: App' , ( ) => {
2323 let routerEvents$ : Subject < any > ;
2424 let gtmServiceMock : jest . Mocked < GoogleTagManagerService > ;
25- let osfConfigServiceMock : OSFConfigService ;
2625 let fixture : ComponentFixture < AppComponent > ;
2726
2827 beforeEach ( async ( ) => {
@@ -48,16 +47,9 @@ describe('Component: App', () => {
4847 events : routerEvents$ . asObservable ( ) ,
4948 } ,
5049 } ,
51- {
52- provide : OSFConfigService ,
53- useValue : {
54- has : jest . fn ( ) ,
55- } ,
56- } ,
5750 ] ,
5851 } ) . compileComponents ( ) ;
5952
60- osfConfigServiceMock = TestBed . inject ( OSFConfigService ) ;
6153 fixture = TestBed . createComponent ( AppComponent ) ;
6254 } ) ;
6355
@@ -81,7 +73,6 @@ describe('Component: App', () => {
8173
8274 describe ( 'Google Tag Manager' , ( ) => {
8375 it ( 'should push GTM tag on NavigationEnd with google tag id' , ( ) => {
84- jest . spyOn ( osfConfigServiceMock , 'has' ) . mockReturnValue ( true ) ;
8576 fixture . detectChanges ( ) ;
8677 const event = new NavigationEnd ( 1 , '/previous' , '/current' ) ;
8778
@@ -93,8 +84,9 @@ describe('Component: App', () => {
9384 } ) ;
9485 } ) ;
9586
96- it ( 'should not push GTM tag on NavigationEnd with google tag id' , ( ) => {
97- jest . spyOn ( osfConfigServiceMock , 'has' ) . mockReturnValue ( false ) ;
87+ it ( 'should not push GTM tag on NavigationEnd without google tag id' , ( ) => {
88+ const environment = TestBed . inject ( ENVIRONMENT ) ;
89+ environment . googleTagManagerId = '' ;
9890 fixture . detectChanges ( ) ;
9991 const event = new NavigationEnd ( 1 , '/previous' , '/current' ) ;
10092
0 commit comments