@@ -13,6 +13,7 @@ import { mount, createMockedRoute } from './mount'
13
13
import { nextTick } from 'vue'
14
14
import { RouteRecordNormalized } from '../src/matcher/types'
15
15
import { routerKey } from '../src/injectionSymbols'
16
+ import { tick } from './utils'
16
17
17
18
const records = {
18
19
home : { } as RouteRecordNormalized ,
@@ -422,6 +423,27 @@ describe('RouterLink', () => {
422
423
expect ( wrapper . find ( 'a' ) ! . className ) . toContain ( 'router-link-active' )
423
424
} )
424
425
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
+
425
447
it ( 'can customize active class' , async ( ) => {
426
448
const { wrapper } = await factory (
427
449
locations . basic . normalized ,
0 commit comments