]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
test: add more tests for 756f755
authorEduardo San Martin Morote <posva13@gmail.com>
Tue, 8 Nov 2022 13:15:20 +0000 (14:15 +0100)
committerEduardo San Martin Morote <posva13@gmail.com>
Tue, 8 Nov 2022 13:15:20 +0000 (14:15 +0100)
packages/router/__tests__/matcher/resolve.spec.ts
packages/router/__tests__/router.spec.ts

index af5392a42c7852aeb1067950f15241be35f010ae..d51622d4d549f1fba5ab6f34b24f15de0741bd2a 100644 (file)
@@ -1015,7 +1015,7 @@ describe('RouterMatcher.resolve', () => {
       )
     })
 
-    it('avoids nested records with children without a component nor name', () => {
+    it('avoid deeply nested records with children without a component nor name', () => {
       assertErrorMatch(
         {
           path: '/app',
index 340b8c00f44319f74bed2bcc140add872f69e6ba..9e68711126143b1a38161a20f35ed1e0855d3087 100644 (file)
@@ -204,6 +204,30 @@ describe('Router', () => {
     })
   })
 
+  it('merges meta properties from component-less route records', async () => {
+    const { router } = await newRouter()
+    router.addRoute({
+      meta: { parent: true },
+      path: '/app',
+      children: [
+        { path: '', component: components.Foo, meta: { child: true } },
+        {
+          path: 'nested',
+          component: components.Foo,
+          children: [
+            { path: 'a', children: [{ path: 'b', component: components.Foo }] },
+          ],
+        },
+      ],
+    })
+    expect(router.resolve('/app')).toMatchObject({
+      meta: { parent: true, child: true },
+    })
+    expect(router.resolve('/app/nested/a/b')).toMatchObject({
+      meta: { parent: true },
+    })
+  })
+
   it('can do initial navigation to /', async () => {
     const router = createRouter({
       history: createMemoryHistory(),