@@ -152,4 +152,68 @@ describe("pageview", () => {
152
152
} ) ;
153
153
} ) ;
154
154
} ) ;
155
+
156
+ describe ( "router base path" , ( ) => {
157
+ test ( "use with router installed" , async ( ) => {
158
+ const localVue = createLocalVue ( ) ;
159
+ const router = new VueRouter ( {
160
+ mode : "abstract" ,
161
+ base : "/app/" ,
162
+ routes : [ { path : "/" } , { path : "/about" } ] ,
163
+ } ) ;
164
+
165
+ localVue . use ( VueRouter ) ;
166
+ localVue . use (
167
+ VueGtag ,
168
+ {
169
+ pageTrackerPrependBase : true ,
170
+ config : {
171
+ id : 1 ,
172
+ } ,
173
+ } ,
174
+ router
175
+ ) ;
176
+
177
+ router . push ( "/about" ) ;
178
+
179
+ await flushPromises ( ) ;
180
+
181
+ pageview ( router . currentRoute ) ;
182
+
183
+ expect ( event ) . toHaveBeenCalledWith ( "page_view" , {
184
+ send_page_view : true ,
185
+ page_path : "/app/about" ,
186
+ page_location : "window_location_href_value" ,
187
+ } ) ;
188
+ } ) ;
189
+
190
+ test ( "use without router installed" , async ( ) => {
191
+ const localVue = createLocalVue ( ) ;
192
+ const router = new VueRouter ( {
193
+ mode : "abstract" ,
194
+ base : "/app/" ,
195
+ routes : [ { path : "/" } , { path : "/about" } ] ,
196
+ } ) ;
197
+
198
+ localVue . use ( VueRouter ) ;
199
+ localVue . use ( VueGtag , {
200
+ pageTrackerPrependBase : true ,
201
+ config : {
202
+ id : 1 ,
203
+ } ,
204
+ } ) ;
205
+
206
+ router . push ( "/about" ) ;
207
+
208
+ await flushPromises ( ) ;
209
+
210
+ pageview ( router . currentRoute ) ;
211
+
212
+ expect ( event ) . toHaveBeenCalledWith ( "page_view" , {
213
+ send_page_view : true ,
214
+ page_path : "/about" ,
215
+ page_location : "window_location_href_value" ,
216
+ } ) ;
217
+ } ) ;
218
+ } ) ;
155
219
} ) ;
0 commit comments