Skip to content

Commit

Permalink
test(resolve): test resolved for child route
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Mar 28, 2019
1 parent 324ed75 commit f0c5ebd
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/unit/specs/api.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,46 @@ describe('router.onReady', () => {
})
})

describe('route matching', () => {
it('resolves parent params when using current route', () => {
const router = new Router({
mode: 'abstract',
routes: [
{
path: '/a/:id',
component: { name: 'A' },
children: [{ name: 'b', path: 'b', component: { name: 'B' }}]
}
]
})

router.push('/a/1')

const { route, resolved } = router.resolve({ name: 'b' })
expect(route.params).toEqual({ id: '1' })
expect(resolved.params).toEqual({ id: '1' })
})

it('can override currentRoute', () => {
const router = new Router({
mode: 'abstract',
routes: [
{
path: '/a/:id',
component: { name: 'A' },
children: [{ name: 'b', path: 'b', component: { name: 'B' }}]
}
]
})

router.push('/a/1')

const { route, resolved } = router.resolve({ name: 'b' }, { params: { id: '2' }, path: '/a/2' })
expect(route.params).toEqual({ id: '2' })
expect(resolved.params).toEqual({ id: '2' })
})
})

describe('router.addRoutes', () => {
it('should work', () => {
const router = new Router({
Expand Down

0 comments on commit f0c5ebd

Please sign in to comment.