@@ -21,6 +21,7 @@ import '../testing/setup';
21
21
import { getFullApp } from '../testing/get-fake-firebase-services' ;
22
22
import {
23
23
getAnalytics ,
24
+ getGoogleAnalyticsClientId ,
24
25
initializeAnalytics ,
25
26
setConsent ,
26
27
setDefaultEventParameters
@@ -35,6 +36,8 @@ import {
35
36
defaultEventParametersForInit
36
37
} from './functions' ;
37
38
import { ConsentSettings } from './public-types' ;
39
+ import { GtagCommand } from './constants' ;
40
+ import * as util from '@firebase/util' ;
38
41
39
42
describe ( 'FirebaseAnalytics API tests' , ( ) => {
40
43
let initStub : SinonStub = stub ( ) ;
@@ -154,4 +157,19 @@ describe('FirebaseAnalytics API tests', () => {
154
157
consentParametersForInit
155
158
) ;
156
159
} ) ;
160
+ it ( 'getGoogleAnalyticsClientId() calls gtag "get" through wrappedGtagFunction' , ( ) => {
161
+ stub ( factory , 'wrappedGtagFunction' ) . get ( ( ) => wrappedGtag ) ;
162
+ stub ( util , 'getModularInstance' ) . returns ( {
163
+ app : { options : { measurementId : 'measurement-id-1' } }
164
+ } ) ;
165
+ app = getFullApp ( { ...fakeAppParams , measurementId : 'measurement-id-1' } ) ;
166
+ const analyticsInstance = initializeAnalytics ( app ) ;
167
+ const id = getGoogleAnalyticsClientId ( analyticsInstance ) ;
168
+ console . log ( { didWeGetTheId : id } ) ;
169
+ expect ( wrappedGtag ) . to . have . been . calledWith (
170
+ GtagCommand . GET ,
171
+ 'measurement-id-1' ,
172
+ 'client_id'
173
+ ) ;
174
+ } ) ;
157
175
} ) ;
0 commit comments