]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: add missing test cases
authorEduardo San Martin Morote <posva13@gmail.com>
Mon, 28 Feb 2022 14:34:08 +0000 (15:34 +0100)
committerEduardo San Martin Morote <posva@users.noreply.github.com>
Mon, 28 Feb 2022 14:37:47 +0000 (15:37 +0100)
__tests__/matcher/addingRemoving.spec.ts

index 7e72193777ee44908d2838eebeee0825b971140b..4819ff2e1c5c21cdf12a7afa9649489f14ba6b74 100644 (file)
@@ -388,6 +388,36 @@ describe('Matcher: adding and removing records', () => {
     })
   })
 
+  it('adds empty paths as children', () => {
+    const matcher = createRouterMatcher([], {})
+    matcher.addRoute({ path: '/', component, name: 'parent' })
+    const parent = matcher.getRecordMatcher('parent')
+    expect(matcher.resolve({ path: '/' }, currentLocation)).toMatchObject({
+      name: 'parent',
+    })
+    matcher.addRoute({ path: '', component, name: 'child' }, parent)
+    expect(matcher.resolve({ path: '/' }, currentLocation)).toMatchObject({
+      name: 'child',
+    })
+  })
+
+  it('adding dynamic child with root path', () => {
+    const matcher = createRouterMatcher([], {})
+    matcher.addRoute({ path: '/parent', component, name: 'parent' })
+    const parent = matcher.getRecordMatcher('parent')
+    expect(matcher.resolve({ path: '/parent' }, currentLocation)).toMatchObject(
+      {
+        name: 'parent',
+      }
+    )
+    matcher.addRoute({ path: '/:id', component, name: 'child' }, parent)
+    expect(matcher.resolve({ path: '/parent' }, currentLocation)).toMatchObject(
+      {
+        name: 'parent',
+      }
+    )
+  })
+
   describe('warnings', () => {
     mockWarn()