Skip to content

Commit f339429

Browse files
andrewdacenkofacebook-github-bot
authored andcommitted
Add base test for TouchableWithoutFeedback (react#53178)
Summary: Changelog: [Internal] Add base integration test for TouchableWithoutFeedback Reviewed By: zeyap Differential Revision: D79889935
1 parent 4c570b5 commit f339429

1 file changed

Lines changed: 97 additions & 0 deletions

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
13+
import * as Fantom from '@react-native/fantom';
14+
import * as React from 'react';
15+
import {Text, TouchableWithoutFeedback, View} from 'react-native';
16+
import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance';
17+
import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement';
18+
19+
describe('<TouchableWithoutFeedback>', () => {
20+
describe('props', () => {
21+
describe('empty props', () => {
22+
it('renders without any props', () => {
23+
const root = Fantom.createRoot();
24+
25+
Fantom.runTask(() => {
26+
root.render(
27+
<TouchableWithoutFeedback>
28+
<Text>Touchable</Text>
29+
</TouchableWithoutFeedback>,
30+
);
31+
});
32+
33+
expect(
34+
root.getRenderedOutput({props: ['isPressable']}).toJSX(),
35+
).toEqual(<rn-paragraph isPressable="true">Touchable</rn-paragraph>);
36+
});
37+
});
38+
39+
describe('accessibility', () => {
40+
it('is accessible by default', () => {
41+
const root = Fantom.createRoot();
42+
43+
Fantom.runTask(() => {
44+
root.render(
45+
<TouchableWithoutFeedback>
46+
<Text>Touchable</Text>
47+
</TouchableWithoutFeedback>,
48+
);
49+
});
50+
51+
expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual(
52+
<rn-paragraph accessible="true">Touchable</rn-paragraph>,
53+
);
54+
});
55+
});
56+
});
57+
58+
describe('ref', () => {
59+
describe('instance', () => {
60+
it('is backed by its child', () => {
61+
const root = Fantom.createRoot();
62+
63+
Fantom.runTask(() => {
64+
root.render(
65+
<TouchableWithoutFeedback>
66+
<Text>Touchable</Text>
67+
</TouchableWithoutFeedback>,
68+
);
69+
});
70+
71+
expect(
72+
ensureInstance(
73+
root.document.documentElement.firstElementChild,
74+
ReactNativeElement,
75+
).tagName,
76+
).toBe('RN:Paragraph');
77+
78+
Fantom.runTask(() => {
79+
root.render(
80+
<TouchableWithoutFeedback>
81+
<View>
82+
<Text>Touchable</Text>
83+
</View>
84+
</TouchableWithoutFeedback>,
85+
);
86+
});
87+
88+
expect(
89+
ensureInstance(
90+
root.document.documentElement.firstElementChild,
91+
ReactNativeElement,
92+
).tagName,
93+
).toBe('RN:View');
94+
});
95+
});
96+
});
97+
});

0 commit comments

Comments
 (0)