mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
e2e test for Text.role (#53176)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53176 # Changelog: [Internal] - As in the title Reviewed By: andrewdacenko Differential Revision: D79891116 fbshipit-source-id: 13042a9b82373b8e0073c8421e532e6e463d60f8
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3d37d2d2ce
commit
0aeb26bdfc
@@ -11,6 +11,7 @@
|
||||
|
||||
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
|
||||
|
||||
import type {Role} from '../../Components/View/ViewAccessibility';
|
||||
import type {HostInstance} from 'react-native';
|
||||
|
||||
import ensureInstance from '../../../src/private/__tests__/utilities/ensureInstance';
|
||||
@@ -244,6 +245,115 @@ describe('<Text>', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('role', () => {
|
||||
it(`has none by default`, () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<Text>{TEST_TEXT}</Text>);
|
||||
});
|
||||
|
||||
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
|
||||
<rn-paragraph>{TEST_TEXT}</rn-paragraph>,
|
||||
);
|
||||
});
|
||||
|
||||
it(`maps invalid values to 'none'`, () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
// $FlowExpectedError[incompatible-type]
|
||||
root.render(<Text role="__some_invalid_value">{TEST_TEXT}</Text>);
|
||||
});
|
||||
|
||||
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
|
||||
<rn-paragraph role="none">{TEST_TEXT}</rn-paragraph>,
|
||||
);
|
||||
});
|
||||
|
||||
it(`propagates correctly all possible values`, () => {
|
||||
const root = Fantom.createRoot();
|
||||
(
|
||||
[
|
||||
'alert',
|
||||
'alertdialog',
|
||||
'application',
|
||||
'article',
|
||||
'banner',
|
||||
'button',
|
||||
'cell',
|
||||
'checkbox',
|
||||
'columnheader',
|
||||
'combobox',
|
||||
'complementary',
|
||||
'contentinfo',
|
||||
'definition',
|
||||
'dialog',
|
||||
'directory',
|
||||
'document',
|
||||
'feed',
|
||||
'figure',
|
||||
'form',
|
||||
'grid',
|
||||
'group',
|
||||
'heading',
|
||||
'img',
|
||||
'link',
|
||||
'list',
|
||||
'listitem',
|
||||
'log',
|
||||
'main',
|
||||
'marquee',
|
||||
'math',
|
||||
'menu',
|
||||
'menubar',
|
||||
'menuitem',
|
||||
'meter',
|
||||
'navigation',
|
||||
'none',
|
||||
'note',
|
||||
'option',
|
||||
'presentation',
|
||||
'progressbar',
|
||||
'radio',
|
||||
'radiogroup',
|
||||
'region',
|
||||
'row',
|
||||
'rowgroup',
|
||||
'rowheader',
|
||||
'scrollbar',
|
||||
'searchbox',
|
||||
'separator',
|
||||
'slider',
|
||||
'spinbutton',
|
||||
'status',
|
||||
'summary',
|
||||
'switch',
|
||||
'tab',
|
||||
'table',
|
||||
'tablist',
|
||||
'tabpanel',
|
||||
'term',
|
||||
'timer',
|
||||
'toolbar',
|
||||
'tooltip',
|
||||
'tree',
|
||||
'treegrid',
|
||||
'treeitem',
|
||||
'treeitem',
|
||||
] as Array<Role>
|
||||
).forEach(propVal => {
|
||||
Fantom.runTask(() => {
|
||||
root.render(<Text role={propVal}>{TEST_TEXT}</Text>);
|
||||
});
|
||||
|
||||
expect(root.getRenderedOutput({props: ['role']}).toJSX()).toEqual(
|
||||
<rn-paragraph role={propVal}>{TEST_TEXT}</rn-paragraph>,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('selectable', () => {
|
||||
it(`can be set to "true"`, () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Reference in New Issue
Block a user