From 7035391b04489c78fc796a820ef4a364a61af33e Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Fri, 8 Aug 2025 06:47:23 -0700 Subject: [PATCH] Add basic test for Modal (#53140) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/53140 As per title, this change adds the boilerplate code for a Fantom test on Modal ## Changelog: [Internal] - Reviewed By: andrewdacenko Differential Revision: D79805808 fbshipit-source-id: c8c77e576a09b346cf29b290d68c75e540d5f146 --- .../Libraries/Modal/__tests__/Modal-itest.js | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 packages/react-native/Libraries/Modal/__tests__/Modal-itest.js diff --git a/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js b/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js new file mode 100644 index 00000000000..d59f2348286 --- /dev/null +++ b/packages/react-native/Libraries/Modal/__tests__/Modal-itest.js @@ -0,0 +1,41 @@ +/** + * Copyright (c) Meta Platforms, Inc. and affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @flow strict-local + * @format + */ + +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; +import type {HostInstance} from 'react-native'; + +import * as Fantom from '@react-native/fantom'; +import * as React from 'react'; +import {createRef} from 'react'; +import {Modal} from 'react-native'; +import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance'; +import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement'; + +describe('', () => { + describe('ref', () => { + describe('exampleMethod()', () => { + // more describe('') or tests with it('') + }); + // ... more methods + describe('instance', () => { + it('uses the "RN:ModalHostView" tag name', () => { + const elementRef = createRef(); + const root = Fantom.createRoot(); + Fantom.runTask(() => { + root.render(); + }); + + expect(elementRef.current).toBeInstanceOf(ReactNativeElement); + const element = ensureInstance(elementRef.current, ReactNativeElement); + expect(element.tagName).toBe('RN:ModalHostView'); + }); + }); + }); +});