From de8da88711191524a62f3240c7fd18aa03d8b6fb Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 5 Aug 2020 10:26:40 +0200 Subject: [PATCH] test(router-link): add test regarding aria-current --- __tests__/RouterLink.spec.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/__tests__/RouterLink.spec.ts b/__tests__/RouterLink.spec.ts index 5dbc426f..1b7606c4 100644 --- a/__tests__/RouterLink.spec.ts +++ b/__tests__/RouterLink.spec.ts @@ -13,6 +13,7 @@ import { mount, createMockedRoute } from './mount' import { nextTick } from 'vue' import { RouteRecordNormalized } from '../src/matcher/types' import { routerKey } from '../src/injectionSymbols' +import { tick } from './utils' const records = { home: {} as RouteRecordNormalized, @@ -422,6 +423,27 @@ describe('RouterLink', () => { expect(wrapper.find('a')!.className).toContain('router-link-active') }) + it('sets aria-current to page by default when exact active', async () => { + const { wrapper, route } = await factory( + locations.parent.normalized, + { to: locations.parent.string }, + locations.parent.normalized + ) + expect(wrapper.find('a')!.getAttribute('aria-current')).toBe('page') + route.set(locations.child.normalized) + await tick() + expect(wrapper.find('a')!.getAttribute('aria-current')).not.toBe('page') + }) + + it('can customize aria-current value', async () => { + const { wrapper } = await factory( + locations.basic.normalized, + { to: locations.basic.string, ariaCurrentValue: 'time' }, + locations.basic.normalized + ) + expect(wrapper.find('a')!.getAttribute('aria-current')).toBe('time') + }) + it('can customize active class', async () => { const { wrapper } = await factory( locations.basic.normalized, -- 2.47.2