mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
Add tests for aria- props (#55851)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/55851 Changelog: [Internal] just missing tests Reviewed By: javache Differential Revision: D94904120 fbshipit-source-id: fb73fc92e0ea30b3e37a1fd5725d3bec1b89fb1f
This commit is contained in:
1 parent
e131561e98
commit
1cd0387d97
1 file changed
+125
@@ -522,6 +522,115 @@ describe('<View>', () => {
|
||||
).toEqual(null);
|
||||
});
|
||||
});
|
||||
describe('aria-label', () => {
|
||||
it('is mapped to accessibilityLabel', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-label="custom label" accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(),
|
||||
).toEqual(<rn-view accessibilityLabel="custom label" />);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-live', () => {
|
||||
it('is mapped to accessibilityLiveRegion', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-live="polite" accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root
|
||||
.getRenderedOutput({props: ['accessibilityLiveRegion']})
|
||||
.toJSX(),
|
||||
).toEqual(<rn-view accessibilityLiveRegion="polite" />);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-busy', () => {
|
||||
it('is mapped to accessibilityState', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-busy={true} accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
|
||||
).toEqual(
|
||||
<rn-view accessibilityState="{disabled:false,selected:false,checked:None,busy:true,expanded:null}" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-disabled', () => {
|
||||
it('is mapped to accessibilityState', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-disabled={true} accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
|
||||
).toEqual(
|
||||
<rn-view accessibilityState="{disabled:true,selected:false,checked:None,busy:false,expanded:null}" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-expanded', () => {
|
||||
it('is mapped to accessibilityState', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-expanded={true} accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
|
||||
).toEqual(
|
||||
<rn-view accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:true}" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-selected', () => {
|
||||
it('is mapped to accessibilityState', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-selected={true} accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
|
||||
).toEqual(
|
||||
<rn-view accessibilityState="{disabled:false,selected:true,checked:None,busy:false,expanded:null}" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('aria-checked', () => {
|
||||
it('is mapped to accessibilityState', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View aria-checked={true} accessible={true} />);
|
||||
});
|
||||
|
||||
expect(
|
||||
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
|
||||
).toEqual(
|
||||
<rn-view accessibilityState="{disabled:false,selected:false,checked:Checked,busy:false,expanded:null}" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('accessible', () => {
|
||||
@@ -547,6 +656,22 @@ describe('<View>', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('web compat props', () => {
|
||||
describe('id', () => {
|
||||
it('is mapped to nativeID', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(<View id="my-id" collapsable={false} />);
|
||||
});
|
||||
|
||||
expect(root.getRenderedOutput({props: ['nativeID']}).toJSX()).toEqual(
|
||||
<rn-view nativeID="my-id" />,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('ref', () => {
|
||||
it('is an element node', () => {
|
||||
const elementRef = createRef<HostInstance>();
|
||||
|
||||
Reference in new issue
Block a user