@@ -88,8 +88,9 @@ describe('FirebaseAnalytics instance tests', () => {
88
88
currency : 'USD'
89
89
} ) ;
90
90
// Clear event stack of async FID call.
91
- // For IE: Need to wrap it in another function as FID fetch is wrapped in initializeGAId.
92
- await ( ( ) => fidDeferred . promise ) ;
91
+ // For IE: Need then() or else "expect" runs immediately on FID resolve
92
+ // before the other statements in initializeGAId.
93
+ await fidDeferred . promise . then ( ) ;
93
94
expect ( gtagStub ) . to . have . been . calledWith ( 'js' ) ;
94
95
expect ( gtagStub ) . to . have . been . calledWith (
95
96
GtagCommand . CONFIG ,
@@ -159,8 +160,9 @@ describe('FirebaseAnalytics instance tests', () => {
159
160
currency : 'USD'
160
161
} ) ;
161
162
// Clear event stack of async FID call.
162
- // For IE: Need to wrap it in another function as FID fetch is wrapped in initializeGAId.
163
- await ( ( ) => fidDeferred . promise ) ;
163
+ // For IE: Need then() or else "expect" runs immediately on FID resolve
164
+ // before the other statements in initializeGAId.
165
+ await fidDeferred . promise . then ( ) ;
164
166
expect ( gtagStub ) . to . have . been . calledWith ( 'js' ) ;
165
167
expect ( gtagStub ) . to . have . been . calledWith (
166
168
GtagCommand . CONFIG ,
@@ -197,8 +199,12 @@ describe('FirebaseAnalytics instance tests', () => {
197
199
delete window [ 'dataLayer' ] ;
198
200
removeGtagScript ( ) ;
199
201
} ) ;
200
- it ( 'Adds the script tag to the page' , ( ) => {
202
+ it ( 'Adds the script tag to the page' , async ( ) => {
203
+ const { initializedIdPromisesMap } = getGlobalVars ( ) ;
204
+ await initializedIdPromisesMap [ analyticsId ] ;
201
205
expect ( findGtagScriptOnPage ( ) ) . to . not . be . null ;
206
+ expect ( typeof window [ 'gtag' ] ) . to . equal ( 'function' ) ;
207
+ expect ( Array . isArray ( window [ 'dataLayer' ] ) ) . to . be . true ;
202
208
} ) ;
203
209
} ) ;
204
210
} ) ;
0 commit comments