@@ -233,7 +233,44 @@ function activeStateTests(setup: ReturnType<typeof createRouterTestSetup>) {
233233 expect ( anchor ?. getAttribute ( 'style' ) ) . toContain ( 'color: red' ) ;
234234 } ) ;
235235
236- test ( "Should set aria-current when route is active." , async ( ) => {
236+ test ( "Should set any aria- attributes from activeState when route is active." , ( ) => {
237+ // Arrange.
238+ const { hash, router, context } = setup ;
239+ const href = "/test/path" ;
240+ const activeKey = "test-route" ;
241+
242+ // Mock active route status
243+ if ( router ) {
244+ Object . defineProperty ( router , 'routeStatus' , {
245+ value : { [ activeKey ] : { match : false } } ,
246+ configurable : true
247+ } ) ;
248+ }
249+
250+ // Act.
251+ const { container } = render ( Link , {
252+ props : {
253+ hash,
254+ href,
255+ activeState : {
256+ key : activeKey ,
257+ aria : {
258+ 'aria-selected' : 'true' ,
259+ 'aria-current' : 'page'
260+ }
261+ } ,
262+ children : content
263+ } ,
264+ context
265+ } ) ;
266+ const anchor = container . querySelector ( 'a' ) ;
267+
268+ // Assert.
269+ expect ( anchor ?. getAttribute ( 'aria-selected' ) ) . toBeNull ( ) ;
270+ expect ( anchor ?. getAttribute ( 'aria-current' ) ) . toBeNull ( ) ;
271+ } ) ;
272+
273+ test ( "Should not set any aria- attributes when route is not active." , async ( ) => {
237274 // Arrange.
238275 const { hash, router, context } = setup ;
239276 const href = "/test/path" ;
@@ -252,14 +289,21 @@ function activeStateTests(setup: ReturnType<typeof createRouterTestSetup>) {
252289 props : {
253290 hash,
254291 href,
255- activeState : { key : activeKey , ariaCurrent : "page" } ,
292+ activeState : {
293+ key : activeKey ,
294+ aria : {
295+ 'aria-selected' : 'true' ,
296+ 'aria-current' : 'page'
297+ }
298+ } ,
256299 children : content
257300 } ,
258301 context
259302 } ) ;
260303 const anchor = container . querySelector ( 'a' ) ;
261304
262305 // Assert.
306+ expect ( anchor ?. getAttribute ( 'aria-selected' ) ) . toBe ( 'true' ) ;
263307 expect ( anchor ?. getAttribute ( 'aria-current' ) ) . toBe ( 'page' ) ;
264308 } ) ;
265309
@@ -678,15 +722,15 @@ describe("Routing Mode Assertions", () => {
678722 ] ) ( "Should throw error when $description and hash=$hash ." , ( { options, hash } ) => {
679723 // Arrange
680724 setRoutingOptions ( options ) ;
681-
725+
682726 // Act & Assert
683727 expect ( ( ) => {
684- render ( Link , {
685- props : {
686- href : "/test" ,
687- hash,
688- children : content
689- } ,
728+ render ( Link , {
729+ props : {
730+ href : "/test" ,
731+ hash,
732+ children : content
733+ } ,
690734 } ) ;
691735 } ) . toThrow ( ) ;
692736 } ) ;
0 commit comments