From: Eduardo San Martin Morote Date: Mon, 6 May 2019 16:17:46 +0000 (+0200) Subject: test: add test for params with nested routes X-Git-Tag: v4.0.0-alpha.0~385 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23f028b26ba0405f37f8c2733683004cc8feb6c9;p=thirdparty%2Fvuejs%2Frouter.git test: add test for params with nested routes --- diff --git a/__tests__/matcher.spec.js b/__tests__/matcher.spec.js index 47e65e76..6907b15e 100644 --- a/__tests__/matcher.spec.js +++ b/__tests__/matcher.spec.js @@ -450,6 +450,11 @@ describe('Router Matcher', () => { const ChildA = { path: 'a', name: 'child-a', component } const ChildB = { path: 'b', name: 'child-b', component } const ChildC = { path: 'c', name: 'child-c', component } + const ChildWithParam = { path: ':p', name: 'child-params', component } + const NestedChildWithParam = { + ...ChildWithParam, + name: 'nested-child-params', + } const NestedChildA = { ...ChildA, name: 'nested-child-a' } const NestedChildB = { ...ChildB, name: 'nested-child-b' } const NestedChildC = { ...ChildC, name: 'nested-child-c' } @@ -459,6 +464,12 @@ describe('Router Matcher', () => { component, children: [NestedChildA, NestedChildB, NestedChildC], } + const NestedWithParam = { + path: 'nested/:n', + name: 'nested', + component, + children: [NestedChildWithParam], + } it('resolves children', () => { const Foo = { @@ -562,6 +573,37 @@ describe('Router Matcher', () => { } ) }) + + it('resolves nested children with params', () => { + const Foo = { + path: '/foo', + name: 'Foo', + component, + children: [NestedWithParam], + } + assertRecordMatch( + Foo, + { path: '/foo/nested/a/b' }, + { + name: 'nested-child-params', + path: '/foo/nested/a/b', + params: { p: 'b', n: 'a' }, + matched: [ + Foo, + { + ...NestedWithParam, + path: `${Foo.path}/${NestedWithParam.path}`, + }, + { + ...NestedChildWithParam, + path: `${Foo.path}/${NestedWithParam.path}/${ + NestedChildWithParam.path + }`, + }, + ], + } + ) + }) }) }) })