@@ -648,6 +648,66 @@ describe('<Image>', () => {
648648 } ) ;
649649 } ) ;
650650
651+ describe ( 'aria-* accessibility state' , ( ) => {
652+ (
653+ [
654+ [ < Image aria-busy = { true } accessible = { true } /> , 'busy:true' ] ,
655+ [ < Image aria-disabled = { true } accessible = { true } /> , 'disabled:true' ] ,
656+ [ < Image aria-expanded = { true } accessible = { true } /> , 'expanded:true' ] ,
657+ [ < Image aria-selected = { true } accessible = { true } /> , 'selected:true' ] ,
658+ [ < Image aria-checked = { true } accessible = { true } /> , 'checked:Checked' ] ,
659+ ] as const
660+ ) . forEach ( ( [ element , expected ] ) => {
661+ it ( `maps ${ expected . split ( ':' ) [ 0 ] } into accessibilityState` , ( ) => {
662+ const root = Fantom . createRoot ( ) ;
663+
664+ Fantom . runTask ( ( ) => {
665+ root . render ( element ) ;
666+ } ) ;
667+
668+ expect (
669+ root
670+ . getRenderedOutput ( { props : [ 'accessibilityState' ] } )
671+ . toJSONObject ( ) . props . accessibilityState ,
672+ ) . toContain ( expected ) ;
673+ } ) ;
674+ } ) ;
675+
676+ it ( 'takes precedence over the matching accessibilityState field' , ( ) => {
677+ const root = Fantom . createRoot ( ) ;
678+
679+ Fantom . runTask ( ( ) => {
680+ root . render (
681+ < Image
682+ accessibilityState = { { busy : false , disabled : true } }
683+ aria-busy = { true }
684+ accessible = { true }
685+ /> ,
686+ ) ;
687+ } ) ;
688+
689+ const accessibilityState = root
690+ . getRenderedOutput ( { props : [ 'accessibilityState' ] } )
691+ . toJSONObject ( ) . props . accessibilityState ;
692+
693+ expect ( accessibilityState ) . toContain ( 'busy:true' ) ;
694+ // Fields not covered by an `aria-*` prop are preserved.
695+ expect ( accessibilityState ) . toContain ( 'disabled:true' ) ;
696+ } ) ;
697+
698+ it ( 'is not set when no state props are provided' , ( ) => {
699+ const root = Fantom . createRoot ( ) ;
700+
701+ Fantom . runTask ( ( ) => {
702+ root . render ( < Image accessible = { true } /> ) ;
703+ } ) ;
704+
705+ expect (
706+ root . getRenderedOutput ( { props : [ 'accessibilityState' ] } ) . toJSX ( ) ,
707+ ) . toEqual ( < rn-image /> ) ;
708+ } ) ;
709+ } ) ;
710+
651711 component TestComponent ( testID ?: ?string , ...props : AccessibilityProps ) {
652712 return < Image { ...props } testID = { testID } source = { LOGO_SOURCE } /> ;
653713 }
0 commit comments