@@ -13,68 +13,68 @@ const getNodeByText = (node, text) =>
13
13
? text === node . props . children
14
14
: text . test ( node . props . children ) ) ;
15
15
16
- export const getByName = ( instance : ReactTestInstance ) => (
17
- name : string | React . ComponentType < * >
18
- ) => {
19
- try {
20
- return instance . find ( node => getNodeByName ( node , name ) ) ;
21
- } catch ( error ) {
22
- throw new ErrorWithStack ( `Error: Component not found.` , getByName ) ;
23
- }
24
- } ;
16
+ export const getByName = ( instance : ReactTestInstance ) =>
17
+ function getByNameFn ( name : string | React . ComponentType < * > ) {
18
+ try {
19
+ return instance . find ( node => getNodeByName ( node , name ) ) ;
20
+ } catch ( error ) {
21
+ throw new ErrorWithStack ( `Component not found.` , getByNameFn ) ;
22
+ }
23
+ } ;
25
24
26
- export const getByText = ( instance : ReactTestInstance ) => (
27
- text : string | RegExp
28
- ) => {
29
- try {
30
- return instance . find ( node => getNodeByText ( node , text ) ) ;
31
- } catch ( error ) {
32
- throw new ErrorWithStack ( `Error: Component not found.` , getByText ) ;
33
- }
34
- } ;
25
+ export const getByText = ( instance : ReactTestInstance ) =>
26
+ function getByTextFn ( text : string | RegExp ) {
27
+ try {
28
+ return instance . find ( node => getNodeByText ( node , text ) ) ;
29
+ } catch ( error ) {
30
+ throw new ErrorWithStack ( `Component not found.` , getByTextFn ) ;
31
+ }
32
+ } ;
35
33
36
- export const getByProps = ( instance : ReactTestInstance ) => ( props : {
37
- [ propName : string ] : any ,
38
- } ) => {
39
- try {
40
- return instance . findByProps ( props ) ;
41
- } catch ( error ) {
42
- throw new ErrorWithStack ( `Error: Component not found.` , getByProps ) ;
43
- }
44
- } ;
34
+ export const getByProps = ( instance : ReactTestInstance ) =>
35
+ function getByPropsFn ( props : { [ propName : string ] : any } ) {
36
+ try {
37
+ return instance . findByProps ( props ) ;
38
+ } catch ( error ) {
39
+ throw new ErrorWithStack ( `Component not found.` , getByPropsFn ) ;
40
+ }
41
+ } ;
45
42
46
- export const getByTestId = ( instance : ReactTestInstance ) => ( testID : string ) =>
47
- getByProps ( instance ) ( { testID } ) ;
43
+ export const getByTestId = ( instance : ReactTestInstance ) =>
44
+ function getByTestIdFn ( testID : string ) {
45
+ try {
46
+ return instance . findByProps ( { testID } ) ;
47
+ } catch ( error ) {
48
+ throw new ErrorWithStack ( `Component not found.` , getByTestIdFn ) ;
49
+ }
50
+ } ;
48
51
49
- export const getAllByName = ( instance : ReactTestInstance ) => (
50
- name : string | React . ComponentType < * >
51
- ) => {
52
- const results = instance . findAll ( node => getNodeByName ( node , name ) ) ;
53
- if ( results . length === 0 ) {
54
- throw new ErrorWithStack ( `Error: Components not found.` , getAllByName ) ;
55
- }
56
- return results ;
57
- } ;
52
+ export const getAllByName = ( instance : ReactTestInstance ) =>
53
+ function getAllByNameFn ( name : string | React . ComponentType < * > ) {
54
+ const results = instance . findAll ( node => getNodeByName ( node , name ) ) ;
55
+ if ( results . length === 0 ) {
56
+ throw new ErrorWithStack ( `Components not found.` , getAllByNameFn ) ;
57
+ }
58
+ return results ;
59
+ } ;
58
60
59
- export const getAllByText = ( instance : ReactTestInstance ) => (
60
- text : string | RegExp
61
- ) => {
62
- const results = instance . findAll ( node => getNodeByText ( node , text ) ) ;
63
- if ( results . length === 0 ) {
64
- throw new ErrorWithStack ( `Error: Components not found.` , getAllByText ) ;
65
- }
66
- return results ;
67
- } ;
61
+ export const getAllByText = ( instance : ReactTestInstance ) =>
62
+ function getAllByTextFn ( text : string | RegExp ) {
63
+ const results = instance . findAll ( node => getNodeByText ( node , text ) ) ;
64
+ if ( results . length === 0 ) {
65
+ throw new ErrorWithStack ( `Components not found.` , getAllByTextFn ) ;
66
+ }
67
+ return results ;
68
+ } ;
68
69
69
- export const getAllByProps = ( instance : ReactTestInstance ) => ( props : {
70
- [ propName : string ] : any ,
71
- } ) => {
72
- const results = instance . findAllByProps ( props ) ;
73
- if ( results . length === 0 ) {
74
- throw new ErrorWithStack ( `Error: Components not found.` , getAllByProps ) ;
75
- }
76
- return results ;
77
- } ;
70
+ export const getAllByProps = ( instance : ReactTestInstance ) =>
71
+ function getAllByPropsFn ( props : { [ propName : string ] : any } ) {
72
+ const results = instance . findAllByProps ( props ) ;
73
+ if ( results . length === 0 ) {
74
+ throw new ErrorWithStack ( `Components not found.` , getAllByPropsFn ) ;
75
+ }
76
+ return results ;
77
+ } ;
78
78
79
79
export const getByAPI = ( instance : ReactTestInstance ) => ( {
80
80
getByTestId : getByTestId ( instance ) ,
0 commit comments