1
+ import config from "@/api/config" ;
1
2
import bootstrap from "@/bootstrap" ;
2
- import { getOptions } from "@/install" ;
3
+ import { getRouter , getOptions } from "@/install" ;
3
4
import flushPromises from "flush-promises" ;
4
5
import pageTracker from "@/page-tracker" ;
5
6
import optOut from "@/api/opt-out" ;
@@ -159,6 +160,7 @@ describe("bootstrap", () => {
159
160
} ) ;
160
161
161
162
it ( "should start tracking pages when enabled" , ( ) => {
163
+ getRouter . mockReturnValueOnce ( { } ) ;
162
164
getOptions . mockReturnValueOnce ( {
163
165
globalObjectName : "gtag" ,
164
166
pageTrackerEnabled : true ,
@@ -170,11 +172,12 @@ describe("bootstrap", () => {
170
172
bootstrap ( ) ;
171
173
172
174
expect ( pageTracker ) . toHaveBeenCalled ( ) ;
175
+ expect ( config ) . not . toHaveBeenCalled ( ) ;
173
176
174
177
flushPromises ( ) ;
175
178
} ) ;
176
179
177
- it ( "should not start tracking pages when enabled " , ( ) => {
180
+ it ( "should not start tracking pages when disabled " , ( ) => {
178
181
getOptions . mockReturnValueOnce ( {
179
182
globalObjectName : "gtag" ,
180
183
pageTrackerEnabled : false ,
@@ -190,6 +193,21 @@ describe("bootstrap", () => {
190
193
flushPromises ( ) ;
191
194
} ) ;
192
195
196
+ it ( "should fire a config when pageTracker is not enabled" , ( ) => {
197
+ getOptions . mockReturnValueOnce ( {
198
+ globalObjectName : "gtag" ,
199
+ config : {
200
+ id : 1
201
+ }
202
+ } ) ;
203
+
204
+ bootstrap ( ) ;
205
+
206
+ expect ( config ) . toHaveBeenCalled ( ) ;
207
+
208
+ flushPromises ( ) ;
209
+ } ) ;
210
+
193
211
it ( "should return an error when script loading fails" , done => {
194
212
util . warn = jest . fn ( ) ;
195
213
util . loadScript = jest . fn ( ( ) => Promise . reject ( new Error ( ) ) ) ;
0 commit comments