@@ -12,12 +12,15 @@ const component = {
12
12
describe ( 'beforeRouteLeave' , ( ) => {
13
13
it ( 'invokes with the component context' , async ( ) => {
14
14
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
+ } )
21
24
const WithLeave = defineComponent ( {
22
25
template : `text` ,
23
26
// 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', () => {
54
57
template : `text` ,
55
58
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
56
59
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
+ } ) ,
63
69
} )
64
70
const WithLeaveTwo = defineComponent ( {
65
71
template : `text` ,
66
72
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
67
73
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
+ } ) ,
74
83
} )
75
84
76
85
const router = createRouter ( {
@@ -108,23 +117,29 @@ describe('beforeRouteLeave', () => {
108
117
template : `<router-view/>` ,
109
118
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
110
119
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
+ } ) ,
117
129
} )
118
130
const WithLeave = defineComponent ( {
119
131
template : `text` ,
120
132
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
121
133
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
+ } ) ,
128
143
} )
129
144
130
145
const router = createRouter ( {
@@ -167,34 +182,43 @@ describe('beforeRouteLeave', () => {
167
182
` ,
168
183
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
169
184
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
+ } ) ,
176
194
} )
177
195
const WithLeaveOne = defineComponent ( {
178
196
template : `text` ,
179
197
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
180
198
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
+ } ) ,
187
208
} )
188
209
const WithLeaveTwo = defineComponent ( {
189
210
template : `text` ,
190
211
// we use data to check if the context is the right one because saving `this` in a variable logs a few warnings
191
212
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
+ } ) ,
198
222
} )
199
223
200
224
const router = createRouter ( {
@@ -235,12 +259,15 @@ describe('beforeRouteLeave', () => {
235
259
describe ( 'beforeRouteUpdate' , ( ) => {
236
260
it ( 'invokes with the component context' , async ( ) => {
237
261
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
+ } )
244
271
const WithParam = defineComponent ( {
245
272
template : `text` ,
246
273
// 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