@@ -46,6 +46,27 @@ describe('getRole', function () {
46
46
expect ( getRole ( { } , node ) ) . to . equal ( 'link' )
47
47
} )
48
48
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
+
49
70
it ( 'returns region role for <section> with aria-label' , function ( ) {
50
71
const node = mockJSXOpeningElement ( 'section' , [ mockJSXAttribute ( 'aria-label' , 'something' ) ] )
51
72
expect ( getRole ( { } , node ) ) . to . equal ( 'region' )
0 commit comments