Skip to content

Commit 1cd0387

Browse files
sammy-SCmeta-codesync[bot]
authored andcommitted
Add tests for aria- props (#55851)
Summary: Pull Request resolved: #55851 Changelog: [Internal] just missing tests Reviewed By: javache Differential Revision: D94904120 fbshipit-source-id: fb73fc92e0ea30b3e37a1fd5725d3bec1b89fb1f
1 parent e131561 commit 1cd0387

File tree

1 file changed

+125
-0
lines changed
  • packages/react-native/Libraries/Components/View/__tests__

1 file changed

+125
-0
lines changed

packages/react-native/Libraries/Components/View/__tests__/View-itest.js

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,115 @@ describe('<View>', () => {
522522
).toEqual(null);
523523
});
524524
});
525+
describe('aria-label', () => {
526+
it('is mapped to accessibilityLabel', () => {
527+
const root = Fantom.createRoot();
528+
529+
Fantom.runTask(() => {
530+
root.render(<View aria-label="custom label" accessible={true} />);
531+
});
532+
533+
expect(
534+
root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(),
535+
).toEqual(<rn-view accessibilityLabel="custom label" />);
536+
});
537+
});
538+
539+
describe('aria-live', () => {
540+
it('is mapped to accessibilityLiveRegion', () => {
541+
const root = Fantom.createRoot();
542+
543+
Fantom.runTask(() => {
544+
root.render(<View aria-live="polite" accessible={true} />);
545+
});
546+
547+
expect(
548+
root
549+
.getRenderedOutput({props: ['accessibilityLiveRegion']})
550+
.toJSX(),
551+
).toEqual(<rn-view accessibilityLiveRegion="polite" />);
552+
});
553+
});
554+
555+
describe('aria-busy', () => {
556+
it('is mapped to accessibilityState', () => {
557+
const root = Fantom.createRoot();
558+
559+
Fantom.runTask(() => {
560+
root.render(<View aria-busy={true} accessible={true} />);
561+
});
562+
563+
expect(
564+
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
565+
).toEqual(
566+
<rn-view accessibilityState="{disabled:false,selected:false,checked:None,busy:true,expanded:null}" />,
567+
);
568+
});
569+
});
570+
571+
describe('aria-disabled', () => {
572+
it('is mapped to accessibilityState', () => {
573+
const root = Fantom.createRoot();
574+
575+
Fantom.runTask(() => {
576+
root.render(<View aria-disabled={true} accessible={true} />);
577+
});
578+
579+
expect(
580+
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
581+
).toEqual(
582+
<rn-view accessibilityState="{disabled:true,selected:false,checked:None,busy:false,expanded:null}" />,
583+
);
584+
});
585+
});
586+
587+
describe('aria-expanded', () => {
588+
it('is mapped to accessibilityState', () => {
589+
const root = Fantom.createRoot();
590+
591+
Fantom.runTask(() => {
592+
root.render(<View aria-expanded={true} accessible={true} />);
593+
});
594+
595+
expect(
596+
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
597+
).toEqual(
598+
<rn-view accessibilityState="{disabled:false,selected:false,checked:None,busy:false,expanded:true}" />,
599+
);
600+
});
601+
});
602+
603+
describe('aria-selected', () => {
604+
it('is mapped to accessibilityState', () => {
605+
const root = Fantom.createRoot();
606+
607+
Fantom.runTask(() => {
608+
root.render(<View aria-selected={true} accessible={true} />);
609+
});
610+
611+
expect(
612+
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
613+
).toEqual(
614+
<rn-view accessibilityState="{disabled:false,selected:true,checked:None,busy:false,expanded:null}" />,
615+
);
616+
});
617+
});
618+
619+
describe('aria-checked', () => {
620+
it('is mapped to accessibilityState', () => {
621+
const root = Fantom.createRoot();
622+
623+
Fantom.runTask(() => {
624+
root.render(<View aria-checked={true} accessible={true} />);
625+
});
626+
627+
expect(
628+
root.getRenderedOutput({props: ['accessibilityState']}).toJSX(),
629+
).toEqual(
630+
<rn-view accessibilityState="{disabled:false,selected:false,checked:Checked,busy:false,expanded:null}" />,
631+
);
632+
});
633+
});
525634
});
526635

527636
describe('accessible', () => {
@@ -547,6 +656,22 @@ describe('<View>', () => {
547656
});
548657
});
549658

659+
describe('web compat props', () => {
660+
describe('id', () => {
661+
it('is mapped to nativeID', () => {
662+
const root = Fantom.createRoot();
663+
664+
Fantom.runTask(() => {
665+
root.render(<View id="my-id" collapsable={false} />);
666+
});
667+
668+
expect(root.getRenderedOutput({props: ['nativeID']}).toJSX()).toEqual(
669+
<rn-view nativeID="my-id" />,
670+
);
671+
});
672+
});
673+
});
674+
550675
describe('ref', () => {
551676
it('is an element node', () => {
552677
const elementRef = createRef<HostInstance>();

0 commit comments

Comments
 (0)