@@ -3,54 +3,6 @@ import React from 'react';
3
3
import { View , Text , TextInput , Button } from 'react-native' ;
4
4
import { render , getDefaultNormalizer } from '..' ;
5
5
6
- const MyComponent = ( ) => {
7
- return < Text > My Component</ Text > ;
8
- } ;
9
-
10
- test ( 'getByTestId returns only native elements' , ( ) => {
11
- const { getByTestId, getAllByTestId } = render (
12
- < View >
13
- < Text testID = "text" > Text</ Text >
14
- < TextInput testID = "textInput" />
15
- < View testID = "view" />
16
- < Button testID = "button" title = "Button" onPress = { jest . fn ( ) } />
17
- < MyComponent testID = "myComponent" />
18
- </ View >
19
- ) ;
20
-
21
- expect ( getByTestId ( 'text' ) ) . toBeTruthy ( ) ;
22
- expect ( getByTestId ( 'textInput' ) ) . toBeTruthy ( ) ;
23
- expect ( getByTestId ( 'view' ) ) . toBeTruthy ( ) ;
24
- expect ( getByTestId ( 'button' ) ) . toBeTruthy ( ) ;
25
-
26
- expect ( getAllByTestId ( 'text' ) ) . toHaveLength ( 1 ) ;
27
- expect ( getAllByTestId ( 'textInput' ) ) . toHaveLength ( 1 ) ;
28
- expect ( getAllByTestId ( 'view' ) ) . toHaveLength ( 1 ) ;
29
- expect ( getAllByTestId ( 'button' ) ) . toHaveLength ( 1 ) ;
30
-
31
- expect ( ( ) => getByTestId ( 'myComponent' ) ) . toThrowError (
32
- 'Unable to find an element with testID: myComponent'
33
- ) ;
34
- expect ( ( ) => getAllByTestId ( 'myComponent' ) ) . toThrowError (
35
- 'Unable to find an element with testID: myComponent'
36
- ) ;
37
- } ) ;
38
-
39
- test ( 'supports a regex matcher' , ( ) => {
40
- const { getByTestId, getAllByTestId } = render (
41
- < View >
42
- < Text testID = "text" > Text</ Text >
43
- < TextInput testID = "textInput" />
44
- < View testID = "view" />
45
- < Button testID = "button" title = "Button" onPress = { jest . fn ( ) } />
46
- < MyComponent testID = "myComponent" />
47
- </ View >
48
- ) ;
49
-
50
- expect ( getByTestId ( / v i e w / ) ) . toBeTruthy ( ) ;
51
- expect ( getAllByTestId ( / t e x t / ) ) . toHaveLength ( 2 ) ;
52
- } ) ;
53
-
54
6
describe ( 'Supports a TextMatch options' , ( ) => {
55
7
test ( 'getByText, getAllByText' , ( ) => {
56
8
const { getByText, getAllByText } = render (
0 commit comments