From: Eduardo San Martin Morote Date: Wed, 5 Aug 2020 08:26:40 +0000 (+0200) Subject: test(router-link): add test regarding aria-current X-Git-Tag: v4.0.0-beta.6~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de8da88711191524a62f3240c7fd18aa03d8b6fb;p=thirdparty%2Fvuejs%2Frouter.git test(router-link): add test regarding aria-current --- 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,