Skip to content

Commit 37bdade

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Add tests for Modal.supportedOrientations prop
Summary: Add Fantom tests for Modal.supportedOrientations prop ## Changelog: [Internal] - Reviewed By: andrewdacenko Differential Revision: D79888424
1 parent e89fa59 commit 37bdade

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

packages/react-native/Libraries/Modal/__tests__/Modal-itest.js

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,95 @@ describe('<Modal>', () => {
346346
});
347347
});
348348
});
349+
350+
describe('supportedOrientations', () => {
351+
const supportedOrientations = [
352+
'portrait',
353+
'portrait-upside-down',
354+
'landscape',
355+
'landscape-left',
356+
'landscape-right',
357+
] as const;
358+
359+
const orientationMap = {
360+
portrait: 1,
361+
'portrait-upside-down': 2,
362+
landscape: 4,
363+
'landscape-left': 8,
364+
'landscape-right': 16,
365+
};
366+
it('renders a Modal with no supportedOrientations', () => {
367+
const root = Fantom.createRoot();
368+
369+
Fantom.runTask(() => {
370+
root.render(<Modal supportedOrientations={[]} />);
371+
});
372+
373+
expect(
374+
root.getRenderedOutput({props: ['supportedOrientations']}).toJSX(),
375+
).toEqual(
376+
<rn-modalHostView supportedOrientations="0">
377+
<rn-view />
378+
</rn-modalHostView>,
379+
);
380+
});
381+
382+
it(`renders a Modal with supportedOrientations="portait"`, () => {
383+
const root = Fantom.createRoot();
384+
385+
Fantom.runTask(() => {
386+
root.render(<Modal supportedOrientations={['portrait']} />);
387+
});
388+
389+
expect(
390+
root.getRenderedOutput({props: ['supportedOrientations']}).toJSX(),
391+
).toEqual(
392+
<rn-modalHostView>
393+
<rn-view />
394+
</rn-modalHostView>,
395+
);
396+
});
397+
398+
supportedOrientations
399+
.filter(orientation => orientation !== 'portrait')
400+
.forEach(orientation => {
401+
it(`renders a Modal with supportedOrientations="[${orientation}]"`, () => {
402+
const root = Fantom.createRoot();
403+
404+
Fantom.runTask(() => {
405+
root.render(<Modal supportedOrientations={[orientation]} />);
406+
});
407+
408+
const expectedOrientationValue = `${orientationMap[orientation]}`;
409+
expect(
410+
root
411+
.getRenderedOutput({props: ['supportedOrientations']})
412+
.toJSX(),
413+
).toEqual(
414+
<rn-modalHostView
415+
supportedOrientations={expectedOrientationValue}>
416+
<rn-view />
417+
</rn-modalHostView>,
418+
);
419+
});
420+
});
421+
422+
it(`renders a Modal with all the supportedOrientations`, () => {
423+
const root = Fantom.createRoot();
424+
425+
Fantom.runTask(() => {
426+
root.render(<Modal supportedOrientations={supportedOrientations} />);
427+
});
428+
429+
expect(
430+
root.getRenderedOutput({props: ['supportedOrientations']}).toJSX(),
431+
).toEqual(
432+
<rn-modalHostView supportedOrientations="31">
433+
<rn-view />
434+
</rn-modalHostView>,
435+
);
436+
});
437+
});
349438
// ... more props
350439
});
351440
describe('ref', () => {

0 commit comments

Comments
 (0)