Skip to content

Commit 076b8a5

Browse files
suezzothymikee
authored andcommitted
test: add test for nested views
1 parent 04125cc commit 076b8a5

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/__tests__/fireEvent.test.js

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ test('should not fire on non-editable TextInput with nested Text', () => {
234234
expect(onChangeTextMock).not.toHaveBeenCalled();
235235
});
236236

237-
test.only('should not fire on non-targetable View', () => {
237+
test('should not fire on none pointerEvents View', () => {
238238
const handlePress = jest.fn();
239239

240240
const screen = render(
@@ -249,6 +249,38 @@ test.only('should not fire on non-targetable View', () => {
249249
expect(handlePress).not.toHaveBeenCalled();
250250
});
251251

252+
test('should not fire on box-only pointerEvents View', () => {
253+
const handlePress = jest.fn();
254+
255+
const screen = render(
256+
<View pointerEvents="box-only">
257+
<Pressable onPress={handlePress}>
258+
<Text>Trigger</Text>
259+
</Pressable>
260+
</View>
261+
);
262+
263+
fireEvent.press(screen.getByText('Trigger'));
264+
expect(handlePress).not.toHaveBeenCalled();
265+
});
266+
267+
test('should not fire on none pointerEvents View with nested elements', () => {
268+
const handlePress = jest.fn();
269+
270+
const screen = render(
271+
<View pointerEvents="box-only">
272+
<View>
273+
<Pressable onPress={handlePress}>
274+
<Text>Trigger</Text>
275+
</Pressable>
276+
</View>
277+
</View>
278+
);
279+
280+
fireEvent.press(screen.getByText('Trigger'));
281+
expect(handlePress).not.toHaveBeenCalled();
282+
});
283+
252284
test('should pass event up on disabled TouchableOpacity', () => {
253285
const handleInnerPress = jest.fn();
254286
const handleOuterPress = jest.fn();

0 commit comments

Comments
 (0)