|
| 1 | +/** |
| 2 | + * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | + * |
| 4 | + * This source code is licensed under the MIT license found in the |
| 5 | + * LICENSE file in the root directory of this source tree. |
| 6 | + * |
| 7 | + * @flow strict-local |
| 8 | + * @format |
| 9 | + */ |
| 10 | + |
| 11 | +import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; |
| 12 | +import type {HostInstance} from 'react-native'; |
| 13 | + |
| 14 | +import * as Fantom from '@react-native/fantom'; |
| 15 | +import * as React from 'react'; |
| 16 | +import {createRef} from 'react'; |
| 17 | +import {Switch} from 'react-native'; |
| 18 | +import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance'; |
| 19 | +import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement'; |
| 20 | + |
| 21 | +describe('<ExampleComponent>', () => { |
| 22 | + describe('props', () => { |
| 23 | + describe('exampleProp', () => { |
| 24 | + // more describe('<context>') or tests with it('<behaviour>') |
| 25 | + }); |
| 26 | + // ... more props |
| 27 | + }); |
| 28 | + describe('ref', () => { |
| 29 | + describe('exampleMethod()', () => { |
| 30 | + // more describe('<context>') or tests with it('<behaviour>') |
| 31 | + }); |
| 32 | + // ... more methods |
| 33 | + describe('instance', () => { |
| 34 | + it('uses the "RN:Switch" tag name', () => { |
| 35 | + const elementRef = createRef<HostInstance>(); |
| 36 | + const root = Fantom.createRoot(); |
| 37 | + Fantom.runTask(() => { |
| 38 | + root.render(<Switch ref={elementRef} />); |
| 39 | + }); |
| 40 | + |
| 41 | + expect(elementRef.current).toBeInstanceOf(ReactNativeElement); |
| 42 | + const element = ensureInstance(elementRef.current, ReactNativeElement); |
| 43 | + expect(element.tagName).toBe('RN:Switch'); |
| 44 | + }); |
| 45 | + }); |
| 46 | + }); |
| 47 | +}); |
0 commit comments