From bdbc85e89bb1c357005bd1841d9410d7dd80943c Mon Sep 17 00:00:00 2001 From: Ruslan Shestopalyuk Date: Mon, 11 Aug 2025 22:55:27 -0700 Subject: [PATCH] Add accessibility props test to the component Summary: # Changelog: [Internal] - Uses the existing generalized accessibility props test suite, recently created by andrewdacenko, to test the corresponding props in the component. Reviewed By: andrewdacenko Differential Revision: D80000693 --- .../Libraries/Text/__tests__/Text-itest.js | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packages/react-native/Libraries/Text/__tests__/Text-itest.js b/packages/react-native/Libraries/Text/__tests__/Text-itest.js index b7c10c8b01ea..45891a5454dc 100644 --- a/packages/react-native/Libraries/Text/__tests__/Text-itest.js +++ b/packages/react-native/Libraries/Text/__tests__/Text-itest.js @@ -12,13 +12,14 @@ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import type {Role} from '../../Components/View/ViewAccessibility'; -import type {HostInstance} from 'react-native'; +import type {AccessibilityProps, HostInstance} from 'react-native'; import ensureInstance from '../../../src/private/__tests__/utilities/ensureInstance'; import * as Fantom from '@react-native/fantom'; import * as React from 'react'; import {createRef} from 'react'; import {Text} from 'react-native'; +import accessibilityPropsSuite from 'react-native/src/private/__tests__/utilities/accessibilityPropsSuite'; import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement'; import ReadOnlyText from 'react-native/src/private/webapis/dom/nodes/ReadOnlyText'; @@ -423,38 +424,38 @@ describe('', () => { Fantom.runTask(() => { root.render( - dummy text, + {TEST_TEXT}, ); }); expect( root.getRenderedOutput({props: ['writingDirection']}).toJSX(), ).toEqual( - dummy text, + {TEST_TEXT}, ); Fantom.runTask(() => { root.render( - dummy text, + {TEST_TEXT}, ); }); expect( root.getRenderedOutput({props: ['writingDirection']}).toJSX(), ).toEqual( - dummy text, + {TEST_TEXT}, ); Fantom.runTask(() => { root.render( - dummy text, + {TEST_TEXT}, ); }); expect( root.getRenderedOutput({props: ['writingDirection']}).toJSX(), ).toEqual( - dummy text, + {TEST_TEXT}, ); }); }); @@ -468,7 +469,7 @@ describe('', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { - root.render(Some text); + root.render({TEST_TEXT}); }); const element = ensureInstance(elementRef.current, ReactNativeElement); @@ -481,14 +482,14 @@ describe('', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { - root.render(Some text); + root.render({TEST_TEXT}); }); const element = ensureInstance(elementRef.current, ReactNativeElement); expect(element.childNodes.length).toBe(1); const textChild = ensureInstance(element.childNodes[0], ReadOnlyText); - expect(textChild.textContent).toBe('Some text'); + expect(textChild.textContent).toBe(TEST_TEXT); }); it('has text and element child nodes when nested', () => { @@ -524,4 +525,9 @@ describe('', () => { expect(secondChildText.textContent).toBe('also in bold'); }); }); + + component ComponentWithAccessibilityProps(...props: AccessibilityProps) { + return {TEST_TEXT}; + } + accessibilityPropsSuite(ComponentWithAccessibilityProps, false); });