Skip to content

Commit 0af4a1c

Browse files
cipolleschifacebook-github-bot
authored andcommitted
Set up Switch Fantom test (#53134)
Summary: Pull Request resolved: #53134 This change sets up the Fanto test for the Switch component ## Changelog: [Internal] - Reviewed By: rubennorte Differential Revision: D79719683 fbshipit-source-id: d8a5d127296e3448faf5f841baa98bc34f4f43cb
1 parent 749dbe0 commit 0af4a1c

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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

Comments
 (0)