55 TBlock
66} from '@native-html/transient-render-engine' ;
77import { render } from '@testing-library/react-native' ;
8- import AccessibilityEngine from 'react-native-accessibility-engine' ;
98import RenderHTML from '../RenderHTML' ;
109import { CustomRendererProps } from '../shared-types' ;
1110
@@ -14,9 +13,9 @@ describe('RenderHTML a11y', () => {
1413 describe ( 'should add accessibility features to anchors when href is non-empty' , ( ) => {
1514 const snippets = [
1615 // Block
17- ` <a href="https://domain.com">test</a>` ,
16+ ' <a href="https://domain.com">test</a>' ,
1817 // Inline
19- ` <span><a href="https://domain.com">test</a> other text</span>`
18+ ' <span><a href="https://domain.com">test</a> other text</span>'
2019 ] ;
2120 for ( const snippet of snippets ) {
2221 it ( `should pas snippet "${ snippet } "` , ( ) => {
@@ -33,15 +32,15 @@ describe('RenderHTML a11y', () => {
3332 const anchor = getByTestId ( 'a' ) ;
3433 expect ( anchor ) . toHaveProp ( 'accessibilityRole' , 'link' ) ;
3534 expect ( anchor ) . toHaveProp ( 'accessible' , true ) ;
36- expect ( ( ) => AccessibilityEngine . check ( element ) ) . not . toThrow ( ) ;
35+ expect ( element ) . toBeAccessible ( ) ;
3736 } ) ;
3837 }
3938 } ) ;
4039 it ( 'should not add accessibility features to anchors when href is empty' , ( ) => {
4140 const element = (
4241 < RenderHTML
4342 source = { {
44- html : ` <a href="">test</a>`
43+ html : ' <a href="">test</a>'
4544 } }
4645 debug = { false }
4746 contentWidth = { 0 }
@@ -51,7 +50,7 @@ describe('RenderHTML a11y', () => {
5150 const anchor = getByTestId ( 'a' ) ;
5251 expect ( anchor ) . not . toHaveProp ( 'accessibilityRole' ) ;
5352 expect ( anchor ) . not . toHaveProp ( 'accessible' ) ;
54- expect ( ( ) => AccessibilityEngine . check ( element ) ) . not . toThrow ( ) ;
53+ expect ( element ) . toBeAccessible ( ) ;
5554 } ) ;
5655 } ) ;
5756 describe ( 'regarding headings' , ( ) => {
@@ -68,7 +67,7 @@ describe('RenderHTML a11y', () => {
6867 ) ;
6968 const { getByTestId } = render ( element ) ;
7069 expect ( getByTestId ( header ) ) . toHaveProp ( 'accessibilityRole' , 'header' ) ;
71- expect ( ( ) => AccessibilityEngine . check ( element ) ) . not . toThrow ( ) ;
70+ expect ( element ) . toBeAccessible ( ) ;
7271 }
7372 } ) ;
7473 } ) ;
@@ -83,9 +82,9 @@ describe('RenderHTML a11y', () => {
8382 contentWidth = { 200 }
8483 />
8584 ) ;
86- const { getByA11yRole , findByTestId } = render ( element ) ;
85+ const { getByTestId , findByTestId } = render ( element ) ;
8786 await findByTestId ( 'image-success' ) ;
88- const image = getByA11yRole ( 'image ') ;
87+ const image = getByTestId ( 'img ') ;
8988 expect ( image ) . toHaveProp ( 'accessibilityRole' , 'image' ) ;
9089 expect ( image ) . toHaveProp ( 'accessibilityLabel' , 'An image' ) ;
9190
@@ -143,10 +142,10 @@ describe('RenderHTML a11y', () => {
143142 contentWidth = { 200 }
144143 />
145144 ) ;
146- const { getByA11yRole } = render ( element ) ;
147- const button = getByA11yRole ( 'button' ) ;
145+ const { getByRole } = render ( element ) ;
146+ const button = getByRole ( 'button' ) ;
148147 expect ( button ) . toHaveProp ( 'accessibilityRole' , 'button' ) ;
149- expect ( ( ) => AccessibilityEngine . check ( element ) ) . not . toThrow ( ) ;
148+ expect ( element ) . toBeAccessible ( ) ;
150149 } ) ;
151150 it ( 'should add a button role if onPress is defined for custom renderers with a textual content model' , ( ) => {
152151 const element = (
@@ -170,10 +169,10 @@ describe('RenderHTML a11y', () => {
170169 contentWidth = { 200 }
171170 />
172171 ) ;
173- const { getByA11yRole } = render ( element ) ;
174- const button = getByA11yRole ( 'link' ) ;
172+ const { getByRole } = render ( element ) ;
173+ const button = getByRole ( 'link' ) ;
175174 expect ( button ) . toHaveProp ( 'accessibilityRole' , 'link' ) ;
176- expect ( ( ) => AccessibilityEngine . check ( element ) ) . not . toThrow ( ) ;
175+ expect ( element ) . toBeAccessible ( ) ;
177176 } ) ;
178177 } ) ;
179178} ) ;
0 commit comments