|
1 | 1 | import * as React from 'react'; |
2 | 2 | import { ReactTestInstance } from 'react-test-renderer'; |
3 | | -import { Switch, Text, TextInput, View } from 'react-native'; |
| 3 | +import { Modal, Switch, Text, TextInput, View } from 'react-native'; |
4 | 4 | import { configureInternal, getConfig, HostComponentNames } from '../config'; |
5 | 5 | import { renderWithAct } from '../render-act'; |
6 | 6 | import { HostTestInstance } from './component-tree'; |
@@ -35,13 +35,15 @@ function detectHostComponentNames(): HostComponentNames { |
35 | 35 | <Text testID="text">Hello</Text> |
36 | 36 | <TextInput testID="textInput" /> |
37 | 37 | <Switch testID="switch" /> |
| 38 | + <Modal testID="modal" /> |
38 | 39 | </View> |
39 | 40 | ); |
40 | 41 |
|
41 | 42 | return { |
42 | 43 | text: getByTestId(renderer.root, 'text').type as string, |
43 | 44 | textInput: getByTestId(renderer.root, 'textInput').type as string, |
44 | 45 | switch: getByTestId(renderer.root, 'switch').type as string, |
| 46 | + modal: getByTestId(renderer.root, 'modal').type as string, |
45 | 47 | }; |
46 | 48 | } catch (error) { |
47 | 49 | const errorMessage = |
@@ -86,3 +88,13 @@ export function isHostTextInput( |
86 | 88 | ): element is HostTestInstance { |
87 | 89 | return element?.type === getHostComponentNames().textInput; |
88 | 90 | } |
| 91 | + |
| 92 | +/** |
| 93 | + * Checks if the given element is a host Modal. |
| 94 | + * @param element The element to check. |
| 95 | + */ |
| 96 | +export function isHostModal( |
| 97 | + element?: ReactTestInstance | null |
| 98 | +): element is HostTestInstance { |
| 99 | + return element?.type === getHostComponentNames().modal; |
| 100 | +} |
0 commit comments