name: undefined,
},
},
+ childAsAbsolute: {
+ string: '/absolute-child',
+ normalized: {
+ fullPath: '/absolute-child',
+ path: '/absolute-child',
+ params: {},
+ meta: {},
+ query: {},
+ hash: '',
+ matched: [records.parent, records.child],
+ redirectedFrom: undefined,
+ name: undefined,
+ },
+ },
childParentAlias: {
string: '/p/child',
normalized: {
)
})
- it.todo('parent is active if the child is an absolute path')
- it.todo('alias parent is active if the child is an absolute path')
+ it('parent is active if the child is an absolute path', () => {
+ const { el } = factory(
+ locations.childAsAbsolute.normalized,
+ { to: locations.parent.string },
+ locations.parent.normalized
+ )
+ expect(el.querySelector('a')!.className).toContain('router-link-active')
+ expect(el.querySelector('a')!.className).not.toContain(
+ 'router-link-exact-active'
+ )
+ })
+
+ it('alias parent is active if the child is an absolute path', () => {
+ const { el } = factory(
+ locations.childAsAbsolute.normalized,
+ { to: locations.parentAlias.string },
+ locations.parentAlias.normalized
+ )
+ expect(el.querySelector('a')!.className).toContain('router-link-active')
+ expect(el.querySelector('a')!.className).not.toContain(
+ 'router-link-exact-active'
+ )
+ })
it('alias parent is active when a child is active', () => {
let { el } = factory(
router.resolve.mockReturnValueOnce(resolvedLocation)
const { app, el } = mount(router as any, {
- template: `<RouterLink :to="to" v-slot="data">
- route: {{ JSON.stringify(data.route) }}
- href: "{{ data.href }}"
- isActive: "{{ data.isActive }}"
- isExactActive: "{{ data.isExactActive }}"
+ template: `<RouterLink v-bind="propsData" v-slot="data">
+ <span>
+ route: {{ JSON.stringify(data.route) }}
+ href: "{{ data.href }}"
+ isActive: "{{ data.isActive }}"
+ isExactActive: "{{ data.isExactActive }}"
+ </span>
</RouterLink>`,
components: { RouterLink } as any,
setup() {
- const to = ref(propsData.to)
-
- return { to }
+ return { propsData }
},
})
// 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\\"> route: {\\"fullPath\\":\\"/home\\",\\"path\\":\\"/home\\",\\"params\\":{},\\"meta\\":{},\\"query\\":{},\\"hash\\":\\"\\",\\"matched\\":[{}]} href: \\"/home\\" isActive: \\"true\\" isExactActive: \\"true\\" </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: {\\"fullPath\\":\\"/home\\",\\"path\\":\\"/home\\",\\"params\\":{},\\"meta\\":{},\\"query\\":{},\\"hash\\":\\"\\",\\"matched\\":[{}]} href: \\"/home\\" isActive: \\"true\\" isExactActive: \\"true\\" </span></a>"`;