Skip to content

Commit 8b0ea66

Browse files
committed
test: improve matcher add/remove tests
1 parent 4b2bfa8 commit 8b0ea66

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

__tests__/matcher/addingRemoving.spec.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ describe('Matcher: adding and removing records', () => {
158158
const matcher = createRouterMatcher([], {})
159159
matcher.addRoute({ path: '/', component, name: 'home' })
160160
matcher.removeRoute('home')
161+
expect(matcher.getRoutes()).toHaveLength(0)
161162
expect(matcher.resolve({ path: '/' }, currentLocation)).toMatchObject({
162163
name: undefined,
163164
matched: [],
@@ -200,7 +201,9 @@ describe('Matcher: adding and removing records', () => {
200201
],
201202
})
202203

204+
expect(matcher.getRoutes()).toHaveLength(2)
203205
matcher.removeRoute('child')
206+
expect(matcher.getRoutes()).toHaveLength(1)
204207

205208
expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
206209
name: undefined,
@@ -230,6 +233,7 @@ describe('Matcher: adding and removing records', () => {
230233
})
231234

232235
matcher.removeRoute('home')
236+
expect(matcher.getRoutes()).toHaveLength(0)
233237

234238
expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
235239
name: undefined,
@@ -249,6 +253,7 @@ describe('Matcher: adding and removing records', () => {
249253
})
250254

251255
matcher.removeRoute('home')
256+
expect(matcher.getRoutes()).toHaveLength(0)
252257

253258
expect(matcher.resolve({ path: '/start' }, currentLocation)).toMatchObject({
254259
name: undefined,
@@ -283,6 +288,7 @@ describe('Matcher: adding and removing records', () => {
283288
})
284289

285290
matcher.removeRoute('home')
291+
expect(matcher.getRoutes()).toHaveLength(0)
286292
;[
287293
'/',
288294
'/start',
@@ -325,6 +331,8 @@ describe('Matcher: adding and removing records', () => {
325331

326332
matcher.removeRoute('child')
327333

334+
expect(matcher.getRoutes()).toHaveLength(2)
335+
328336
expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
329337
name: undefined,
330338
matched: [],

0 commit comments

Comments
 (0)