]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: improve matcher add/remove tests
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 24 May 2020 13:59:30 +0000 (15:59 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 24 May 2020 13:59:30 +0000 (15:59 +0200)
__tests__/matcher/addingRemoving.spec.ts

index d6b313a3aae7529df768120488e4eb2f823bdc44..5fe3d8414c9fa29314964d2ed17f9f008959242b 100644 (file)
@@ -158,6 +158,7 @@ describe('Matcher: adding and removing records', () => {
     const matcher = createRouterMatcher([], {})
     matcher.addRoute({ path: '/', component, name: 'home' })
     matcher.removeRoute('home')
+    expect(matcher.getRoutes()).toHaveLength(0)
     expect(matcher.resolve({ path: '/' }, currentLocation)).toMatchObject({
       name: undefined,
       matched: [],
@@ -200,7 +201,9 @@ describe('Matcher: adding and removing records', () => {
       ],
     })
 
+    expect(matcher.getRoutes()).toHaveLength(2)
     matcher.removeRoute('child')
+    expect(matcher.getRoutes()).toHaveLength(1)
 
     expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
       name: undefined,
@@ -230,6 +233,7 @@ describe('Matcher: adding and removing records', () => {
     })
 
     matcher.removeRoute('home')
+    expect(matcher.getRoutes()).toHaveLength(0)
 
     expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
       name: undefined,
@@ -249,6 +253,7 @@ describe('Matcher: adding and removing records', () => {
     })
 
     matcher.removeRoute('home')
+    expect(matcher.getRoutes()).toHaveLength(0)
 
     expect(matcher.resolve({ path: '/start' }, currentLocation)).toMatchObject({
       name: undefined,
@@ -283,6 +288,7 @@ describe('Matcher: adding and removing records', () => {
     })
 
     matcher.removeRoute('home')
+    expect(matcher.getRoutes()).toHaveLength(0)
     ;[
       '/',
       '/start',
@@ -325,6 +331,8 @@ describe('Matcher: adding and removing records', () => {
 
     matcher.removeRoute('child')
 
+    expect(matcher.getRoutes()).toHaveLength(2)
+
     expect(matcher.resolve({ path: '/about' }, currentLocation)).toMatchObject({
       name: undefined,
       matched: [],