Skip to content

Commit de8da88

Browse files
committed
test(router-link): add test regarding aria-current
1 parent 23e6e9c commit de8da88

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

__tests__/RouterLink.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { mount, createMockedRoute } from './mount'
1313
import { nextTick } from 'vue'
1414
import { RouteRecordNormalized } from '../src/matcher/types'
1515
import { routerKey } from '../src/injectionSymbols'
16+
import { tick } from './utils'
1617

1718
const records = {
1819
home: {} as RouteRecordNormalized,
@@ -422,6 +423,27 @@ describe('RouterLink', () => {
422423
expect(wrapper.find('a')!.className).toContain('router-link-active')
423424
})
424425

426+
it('sets aria-current to page by default when exact active', async () => {
427+
const { wrapper, route } = await factory(
428+
locations.parent.normalized,
429+
{ to: locations.parent.string },
430+
locations.parent.normalized
431+
)
432+
expect(wrapper.find('a')!.getAttribute('aria-current')).toBe('page')
433+
route.set(locations.child.normalized)
434+
await tick()
435+
expect(wrapper.find('a')!.getAttribute('aria-current')).not.toBe('page')
436+
})
437+
438+
it('can customize aria-current value', async () => {
439+
const { wrapper } = await factory(
440+
locations.basic.normalized,
441+
{ to: locations.basic.string, ariaCurrentValue: 'time' },
442+
locations.basic.normalized
443+
)
444+
expect(wrapper.find('a')!.getAttribute('aria-current')).toBe('time')
445+
})
446+
425447
it('can customize active class', async () => {
426448
const { wrapper } = await factory(
427449
locations.basic.normalized,

0 commit comments

Comments
 (0)