hash: '',
matched: [records.home],
redirectedFrom: undefined,
- name: undefined,
+ name: 'home',
},
},
foo: {
hash: '',
matched: [records.homeAlias],
redirectedFrom: undefined,
- name: undefined,
+ name: 'home',
},
},
wrapper.find('a')!.click()
await nextTick()
expect(router.push).toHaveBeenCalledTimes(1)
- expect(router.push).toHaveBeenCalledWith(locations.basic.normalized)
+ })
+
+ it('calls router.push with the correct location for aliases', async () => {
+ const { router, wrapper } = await factory(
+ START_LOCATION_NORMALIZED,
+ { to: locations.alias.string },
+ locations.alias.normalized
+ )
+ wrapper.find('a')!.click()
+ await nextTick()
+ expect(router.push).toHaveBeenCalledTimes(1)
+ expect(router.push).not.toHaveBeenCalledWith(
+ expect.objectContaining({
+ // this is the original name but if we push with this location, we will
+ // not have the alias on the url
+ name: 'home',
+ })
+ )
})
describe('v-slot', () => {
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`RouterLink v-slot provides information on v-slot 1`] = `"<a aria-current=\\"page\\" href=\\"/home\\" class=\\"router-link-active router-link-exact-active\\"><span> route: {\\"href\\":\\"/home\\",\\"fullPath\\":\\"/home\\",\\"path\\":\\"/home\\",\\"params\\":{},\\"meta\\":{},\\"query\\":{},\\"hash\\":\\"\\",\\"matched\\":[{}]} href: \\"/home\\" isActive: \\"true\\" isExactActive: \\"true\\" </span></a>"`;
+exports[`RouterLink v-slot provides information on v-slot 1`] = `"<a aria-current=\\"page\\" href=\\"/home\\" class=\\"router-link-active router-link-exact-active\\"><span> route: {\\"href\\":\\"/home\\",\\"fullPath\\":\\"/home\\",\\"path\\":\\"/home\\",\\"params\\":{},\\"meta\\":{},\\"query\\":{},\\"hash\\":\\"\\",\\"matched\\":[{}],\\"name\\":\\"home\\"} href: \\"/home\\" isActive: \\"true\\" isExactActive: \\"true\\" </span></a>"`;
function navigate(e: MouseEvent = {} as MouseEvent) {
// TODO: handle navigate with empty parameters for scoped slot and composition api
- if (guardEvent(e)) router.push(route.value)
+ if (guardEvent(e)) router.push(unref(props.to))
}
return {