@@ -12,12 +12,15 @@ const component = {
1212describe ( 'beforeRouteLeave' , ( ) => {
1313 it ( 'invokes with the component context' , async ( ) => {
1414 expect . assertions ( 2 )
15- const spy = vi
16- . fn ( )
17- . mockImplementationOnce ( function ( this : any , to , from , next ) {
18- expect ( typeof this . counter ) . toBe ( 'number' )
19- next ( )
20- } )
15+ const spy = vi . fn ( ) . mockImplementationOnce ( function (
16+ this : any ,
17+ to ,
18+ from ,
19+ next
20+ ) {
21+ expect ( typeof this . counter ) . toBe ( 'number' )
22+ next ( )
23+ } )
2124 const WithLeave = defineComponent ( {
2225 template : `text` ,
2326 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
@@ -54,23 +57,29 @@ describe('beforeRouteLeave', () => {
5457 template : `text` ,
5558 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
5659 data : ( ) => ( { counter : 0 } ) ,
57- beforeRouteLeave : vi
58- . fn ( )
59- . mockImplementationOnce ( function ( this : any , to , from , next ) {
60- expect ( typeof this . counter ) . toBe ( 'number' )
61- next ( )
62- } ) ,
60+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
61+ this : any ,
62+ to ,
63+ from ,
64+ next
65+ ) {
66+ expect ( typeof this . counter ) . toBe ( 'number' )
67+ next ( )
68+ } ) ,
6369 } )
6470 const WithLeaveTwo = defineComponent ( {
6571 template : `text` ,
6672 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
6773 data : ( ) => ( { counter : 0 } ) ,
68- beforeRouteLeave : vi
69- . fn ( )
70- . mockImplementationOnce ( function ( this : any , to , from , next ) {
71- expect ( typeof this . counter ) . toBe ( 'number' )
72- next ( )
73- } ) ,
74+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
75+ this : any ,
76+ to ,
77+ from ,
78+ next
79+ ) {
80+ expect ( typeof this . counter ) . toBe ( 'number' )
81+ next ( )
82+ } ) ,
7483 } )
7584
7685 const router = createRouter ( {
@@ -108,23 +117,29 @@ describe('beforeRouteLeave', () => {
108117 template : `<router-view/>` ,
109118 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
110119 data : ( ) => ( { counter : 0 } ) ,
111- beforeRouteLeave : vi
112- . fn ( )
113- . mockImplementationOnce ( function ( this : any , to , from , next ) {
114- expect ( typeof this . counter ) . toBe ( 'number' )
115- next ( )
116- } ) ,
120+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
121+ this : any ,
122+ to ,
123+ from ,
124+ next
125+ ) {
126+ expect ( typeof this . counter ) . toBe ( 'number' )
127+ next ( )
128+ } ) ,
117129 } )
118130 const WithLeave = defineComponent ( {
119131 template : `text` ,
120132 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
121133 data : ( ) => ( { counter : 0 } ) ,
122- beforeRouteLeave : vi
123- . fn ( )
124- . mockImplementationOnce ( function ( this : any , to , from , next ) {
125- expect ( typeof this . counter ) . toBe ( 'number' )
126- next ( )
127- } ) ,
134+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
135+ this : any ,
136+ to ,
137+ from ,
138+ next
139+ ) {
140+ expect ( typeof this . counter ) . toBe ( 'number' )
141+ next ( )
142+ } ) ,
128143 } )
129144
130145 const router = createRouter ( {
@@ -167,34 +182,43 @@ describe('beforeRouteLeave', () => {
167182 ` ,
168183 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
169184 data : ( ) => ( { counter : 0 } ) ,
170- beforeRouteLeave : vi
171- . fn ( )
172- . mockImplementationOnce ( function ( this : any , to , from , next ) {
173- expect ( typeof this . counter ) . toBe ( 'number' )
174- next ( )
175- } ) ,
185+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
186+ this : any ,
187+ to ,
188+ from ,
189+ next
190+ ) {
191+ expect ( typeof this . counter ) . toBe ( 'number' )
192+ next ( )
193+ } ) ,
176194 } )
177195 const WithLeaveOne = defineComponent ( {
178196 template : `text` ,
179197 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
180198 data : ( ) => ( { counter : 0 } ) ,
181- beforeRouteLeave : vi
182- . fn ( )
183- . mockImplementationOnce ( function ( this : any , to , from , next ) {
184- expect ( typeof this . counter ) . toBe ( 'number' )
185- next ( )
186- } ) ,
199+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
200+ this : any ,
201+ to ,
202+ from ,
203+ next
204+ ) {
205+ expect ( typeof this . counter ) . toBe ( 'number' )
206+ next ( )
207+ } ) ,
187208 } )
188209 const WithLeaveTwo = defineComponent ( {
189210 template : `text` ,
190211 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
191212 data : ( ) => ( { counter : 0 } ) ,
192- beforeRouteLeave : vi
193- . fn ( )
194- . mockImplementationOnce ( function ( this : any , to , from , next ) {
195- expect ( typeof this . counter ) . toBe ( 'number' )
196- next ( )
197- } ) ,
213+ beforeRouteLeave : vi . fn ( ) . mockImplementationOnce ( function (
214+ this : any ,
215+ to ,
216+ from ,
217+ next
218+ ) {
219+ expect ( typeof this . counter ) . toBe ( 'number' )
220+ next ( )
221+ } ) ,
198222 } )
199223
200224 const router = createRouter ( {
@@ -235,12 +259,15 @@ describe('beforeRouteLeave', () => {
235259describe ( 'beforeRouteUpdate' , ( ) => {
236260 it ( 'invokes with the component context' , async ( ) => {
237261 expect . assertions ( 2 )
238- const spy = vi
239- . fn ( )
240- . mockImplementationOnce ( function ( this : any , to , from , next ) {
241- expect ( typeof this . counter ) . toBe ( 'number' )
242- next ( )
243- } )
262+ const spy = vi . fn ( ) . mockImplementationOnce ( function (
263+ this : any ,
264+ to ,
265+ from ,
266+ next
267+ ) {
268+ expect ( typeof this . counter ) . toBe ( 'number' )
269+ next ( )
270+ } )
244271 const WithParam = defineComponent ( {
245272 template : `text` ,
246273 // we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
0 commit comments