@@ -46,6 +46,27 @@ describe('getRole', function () {
4646 expect ( getRole ( { } , node ) ) . to . equal ( 'link' )
4747 } )
4848
49+ it ( 'returns link role for <Foo> with polymorphic prop set to "a" and conditional href' , function ( ) {
50+ const node = mockJSXOpeningElement ( 'Foo' , [
51+ mockJSXAttribute ( 'as' , 'a' ) ,
52+ mockJSXConditionalAttribute ( 'href' , 'getUrl' , '#' , 'https://github.com/' ) ,
53+ ] )
54+ expect ( getRole ( { } , node ) ) . to . equal ( 'link' )
55+ } )
56+
57+ it ( 'returns link role for <Foo> with polymorphic prop set to "a" and literal href' , function ( ) {
58+ const node = mockJSXOpeningElement ( 'Foo' , [
59+ mockJSXAttribute ( 'as' , 'a' ) ,
60+ mockJSXAttribute ( 'href' , 'https://github.com/' ) ,
61+ ] )
62+ expect ( getRole ( { } , node ) ) . to . equal ( 'link' )
63+ } )
64+
65+ it ( 'returns generic role for <Foo> with polymorphic prop set to "a" and no href' , function ( ) {
66+ const node = mockJSXOpeningElement ( 'Foo' , [ mockJSXAttribute ( 'as' , 'a' ) ] )
67+ expect ( getRole ( { } , node ) ) . to . equal ( 'generic' )
68+ } )
69+
4970 it ( 'returns region role for <section> with aria-label' , function ( ) {
5071 const node = mockJSXOpeningElement ( 'section' , [ mockJSXAttribute ( 'aria-label' , 'something' ) ] )
5172 expect ( getRole ( { } , node ) ) . to . equal ( 'region' )
0 commit comments