@testing-library/react-native 9.2.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/build/index.flow.js +105 -95
  2. package/build/{helpers → queries}/a11yAPI.d.ts +0 -0
  3. package/build/{helpers → queries}/a11yAPI.js +0 -0
  4. package/build/{helpers → queries}/a11yAPI.js.map +1 -1
  5. package/build/queries/displayValue.d.ts +13 -0
  6. package/build/{helpers/byDisplayValue.js → queries/displayValue.js} +23 -18
  7. package/build/queries/displayValue.js.map +1 -0
  8. package/build/{helpers → queries}/makeA11yQuery.d.ts +0 -0
  9. package/build/{helpers → queries}/makeA11yQuery.js +1 -1
  10. package/build/{helpers → queries}/makeA11yQuery.js.map +1 -1
  11. package/build/queries/makeQueries.d.ts +19 -0
  12. package/build/{helpers → queries}/makeQueries.js +17 -16
  13. package/build/queries/makeQueries.js.map +1 -0
  14. package/build/queries/placeholderText.d.ts +13 -0
  15. package/build/{helpers/byPlaceholderText.js → queries/placeholderText.js} +23 -18
  16. package/build/queries/placeholderText.js.map +1 -0
  17. package/build/queries/testId.d.ts +13 -0
  18. package/build/{helpers/byTestId.js → queries/testId.js} +19 -14
  19. package/build/queries/testId.js.map +1 -0
  20. package/build/queries/text.d.ts +17 -0
  21. package/build/{helpers/byText.js → queries/text.js} +25 -20
  22. package/build/queries/text.js.map +1 -0
  23. package/build/queries/unsafeProps.d.ts +16 -0
  24. package/build/queries/unsafeProps.js +58 -0
  25. package/build/queries/unsafeProps.js.map +1 -0
  26. package/build/queries/unsafeType.d.ts +9 -0
  27. package/build/queries/unsafeType.js +54 -0
  28. package/build/queries/unsafeType.js.map +1 -0
  29. package/build/render.d.ts +34 -44
  30. package/build/render.js +3 -12
  31. package/build/render.js.map +1 -1
  32. package/build/within.d.ts +34 -44
  33. package/build/within.js +16 -7
  34. package/build/within.js.map +1 -1
  35. package/package.json +1 -1
  36. package/typings/index.flow.js +105 -95
  37. package/build/helpers/byDisplayValue.d.ts +0 -6
  38. package/build/helpers/byDisplayValue.js.map +0 -1
  39. package/build/helpers/byPlaceholderText.d.ts +0 -6
  40. package/build/helpers/byPlaceholderText.js.map +0 -1
  41. package/build/helpers/byTestId.d.ts +0 -6
  42. package/build/helpers/byTestId.js.map +0 -1
  43. package/build/helpers/byText.d.ts +0 -10
  44. package/build/helpers/byText.js.map +0 -1
  45. package/build/helpers/findByAPI.d.ts +0 -17
  46. package/build/helpers/findByAPI.js +0 -33
  47. package/build/helpers/findByAPI.js.map +0 -1
  48. package/build/helpers/getByAPI.d.ts +0 -31
  49. package/build/helpers/getByAPI.js +0 -83
  50. package/build/helpers/getByAPI.js.map +0 -1
  51. package/build/helpers/makeQueries.d.ts +0 -20
  52. package/build/helpers/makeQueries.js.map +0 -1
  53. package/build/helpers/queryByAPI.d.ts +0 -39
  54. package/build/helpers/queryByAPI.js +0 -87
  55. package/build/helpers/queryByAPI.js.map +0 -1
package/build/within.d.ts CHANGED
@@ -73,55 +73,45 @@ export declare function within(instance: ReactTestInstance): {
73
73
  now?: number | undefined;
74
74
  text?: string | undefined;
75
75
  }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
76
- findAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
77
- findAllByPlaceholder: () => void;
78
- findAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
79
- findAllByTestId: (testId: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
80
- findAllByText: (text: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
81
- findByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
82
- findByPlaceholder: () => void;
83
- findByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
84
- findByTestId: (testId: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
85
- findByText: (text: import("./matches").TextMatch, queryOptions?: (import("./helpers/byText").TextMatchOptions & import("./waitFor").WaitForOptions) | undefined, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
86
- queryByText: (name: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
87
- queryAllByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
88
- queryByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
89
- queryAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
90
- queryByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance | null;
91
- queryAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
92
- queryByTestId: (testID: import("./matches").TextMatch) => ReactTestInstance | null;
93
- queryAllByTestId: (testID: import("./matches").TextMatch) => ReactTestInstance[];
94
- UNSAFE_queryByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance | null;
95
- UNSAFE_queryAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
96
- UNSAFE_queryByProps: (props: {
97
- [key: string]: any;
98
- }) => ReactTestInstance | null;
99
- UNSAFE_queryAllByProps: (props: {
100
- [key: string]: any;
101
- }) => ReactTestInstance[];
102
- queryByName: () => void;
103
- queryByType: () => void;
104
- queryByProps: () => void;
105
- queryAllByName: () => void;
106
- queryAllByType: () => void;
107
- queryAllByProps: () => void;
108
- queryByPlaceholder: () => void;
109
- queryAllByPlaceholder: () => void;
110
- getByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
111
- getByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
112
- getByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
113
- getByTestId: (testID: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance;
114
- getAllByTestId: (testID: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
115
- getAllByText: (text: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
116
- getAllByPlaceholderText: (placeholder: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
117
- getAllByDisplayValue: (value: import("./matches").TextMatch, queryOptions?: import("./helpers/byText").TextMatchOptions | undefined) => ReactTestInstance[];
118
- UNSAFE_getByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance;
119
- UNSAFE_getAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
120
76
  UNSAFE_getByProps: (props: {
121
77
  [key: string]: any;
122
78
  }) => ReactTestInstance;
123
79
  UNSAFE_getAllByProps: (props: {
124
80
  [key: string]: any;
125
81
  }) => ReactTestInstance[];
82
+ UNSAFE_queryByProps: (props: {
83
+ [key: string]: any;
84
+ }) => ReactTestInstance | null;
85
+ UNSAFE_queryAllByProps: (props: {
86
+ [key: string]: any;
87
+ }) => ReactTestInstance[];
88
+ UNSAFE_getByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance;
89
+ UNSAFE_getAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
90
+ UNSAFE_queryByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance | null;
91
+ UNSAFE_queryAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
92
+ getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
93
+ getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
94
+ queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
95
+ queryAllByPlaceholderText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
96
+ findByPlaceholderText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
97
+ findAllByPlaceholderText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
98
+ getByDisplayValue: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
99
+ getAllByDisplayValue: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
100
+ queryByDisplayValue: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
101
+ queryAllByDisplayValue: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
102
+ findByDisplayValue: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
103
+ findAllByDisplayValue: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
104
+ getByTestId: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
105
+ getAllByTestId: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
106
+ queryByTestId: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
107
+ queryAllByTestId: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
108
+ findByTestId: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
109
+ findAllByTestId: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
110
+ getByText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
111
+ getAllByText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
112
+ queryByText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
113
+ queryAllByText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
114
+ findByText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
115
+ findAllByText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
126
116
  };
127
117
  export declare const getQueriesForElement: typeof within;
package/build/within.js CHANGED
@@ -6,18 +6,27 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getQueriesForElement = void 0;
7
7
  exports.within = within;
8
8
 
9
- var _getByAPI = require("./helpers/getByAPI");
9
+ var _a11yAPI = require("./queries/a11yAPI");
10
10
 
11
- var _queryByAPI = require("./helpers/queryByAPI");
11
+ var _text = require("./queries/text");
12
12
 
13
- var _findByAPI = require("./helpers/findByAPI");
13
+ var _testId = require("./queries/testId");
14
14
 
15
- var _a11yAPI = require("./helpers/a11yAPI");
15
+ var _displayValue = require("./queries/displayValue");
16
+
17
+ var _placeholderText = require("./queries/placeholderText");
18
+
19
+ var _unsafeType = require("./queries/unsafeType");
20
+
21
+ var _unsafeProps = require("./queries/unsafeProps");
16
22
 
17
23
  function within(instance) {
18
- return { ...(0, _getByAPI.getByAPI)(instance),
19
- ...(0, _queryByAPI.queryByAPI)(instance),
20
- ...(0, _findByAPI.findByAPI)(instance),
24
+ return { ...(0, _text.bindByTextQueries)(instance),
25
+ ...(0, _testId.bindByTestIdQueries)(instance),
26
+ ...(0, _displayValue.bindByDisplayValueQueries)(instance),
27
+ ...(0, _placeholderText.bindByPlaceholderTextQueries)(instance),
28
+ ...(0, _unsafeType.bindUnsafeByTypeQueries)(instance),
29
+ ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance),
21
30
  ...(0, _a11yAPI.a11yAPI)(instance)
22
31
  };
23
32
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,wBAASA,QAAT,CADE;AAEL,OAAG,4BAAWA,QAAX,CAFE;AAGL,OAAG,0BAAUA,QAAV,CAHE;AAIL,OAAG,sBAAQA,QAAR;AAJE,GAAP;AAMD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { getByAPI } from './helpers/getByAPI';\nimport { queryByAPI } from './helpers/queryByAPI';\nimport { findByAPI } from './helpers/findByAPI';\nimport { a11yAPI } from './helpers/a11yAPI';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...getByAPI(instance),\n ...queryByAPI(instance),\n ...findByAPI(instance),\n ...a11yAPI(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
1
+ {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,6BAAkBA,QAAlB,CADE;AAEL,OAAG,iCAAoBA,QAApB,CAFE;AAGL,OAAG,6CAA0BA,QAA1B,CAHE;AAIL,OAAG,mDAA6BA,QAA7B,CAJE;AAKL,OAAG,yCAAwBA,QAAxB,CALE;AAML,OAAG,2CAAyBA,QAAzB,CANE;AAOL,OAAG,sBAAQA,QAAR;AAPE,GAAP;AASD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { a11yAPI } from './queries/a11yAPI';\nimport { bindByTextQueries } from './queries/text';\nimport { bindByTestIdQueries } from './queries/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\nimport { bindUnsafeByTypeQueries } from './queries/unsafeType';\nimport { bindUnsafeByPropsQueries } from './queries/unsafeProps';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...bindByTextQueries(instance),\n ...bindByTestIdQueries(instance),\n ...bindByDisplayValueQueries(instance),\n ...bindByPlaceholderTextQueries(instance),\n ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n ...a11yAPI(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "9.2.0",
3
+ "version": "10.0.0",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -73,140 +73,144 @@ declare type A11yValue = {
73
73
  text?: string,
74
74
  };
75
75
 
76
- interface GetByAPI {
76
+ type WaitForOptions = {
77
+ timeout?: number,
78
+ interval?: number,
79
+ onTimeout?: (error: mixed) => Error,
80
+ };
81
+ type WaitForFunction = <T = any>(
82
+ expectation: () => T,
83
+ options?: WaitForOptions
84
+ ) => Promise<T>;
85
+
86
+ interface ByTextQueries {
77
87
  getByText: (text: TextMatch, options?: TextMatchOptions) => ReactTestInstance;
78
- getByPlaceholderText: (
79
- placeholder: TextMatch,
80
- options?: TextMatchOptions
81
- ) => ReactTestInstance;
82
- getByDisplayValue: (
83
- value: TextMatch,
84
- options?: TextMatchOptions
85
- ) => ReactTestInstance;
86
- getByTestId: (
87
- testID: TextMatch,
88
- options?: TextMatchOptions
89
- ) => ReactTestInstance;
90
- getAllByTestId: (
91
- testID: TextMatch,
92
- options?: TextMatchOptions
93
- ) => Array<ReactTestInstance>;
94
88
  getAllByText: (
95
89
  text: TextMatch,
96
90
  options?: TextMatchOptions
97
91
  ) => Array<ReactTestInstance>;
98
- getAllByPlaceholderText: (
99
- placeholder: TextMatch,
100
- options?: TextMatchOptions
101
- ) => Array<ReactTestInstance>;
102
- getAllByDisplayValue: (
103
- value: TextMatch,
104
- options?: TextMatchOptions
105
- ) => Array<ReactTestInstance>;
106
-
107
- // Unsafe aliases
108
- UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
109
- UNSAFE_getAllByType: <P>(
110
- type: React.ComponentType<P>
111
- ) => Array<ReactTestInstance>;
112
- UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
113
- UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
114
- }
115
-
116
- interface QueryByAPI {
117
92
  queryByText: (
118
93
  name: TextMatch,
119
94
  options?: TextMatchOptions
120
95
  ) => ReactTestInstance | null;
121
- queryByPlaceholderText: (
122
- placeholder: TextMatch,
123
- options?: TextMatchOptions
124
- ) => ReactTestInstance | null;
125
- queryByDisplayValue: (
126
- value: TextMatch,
127
- options?: TextMatchOptions
128
- ) => ReactTestInstance | null;
129
- queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
130
- queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
131
96
  queryAllByText: (
132
97
  text: TextMatch,
133
98
  options?: TextMatchOptions
134
99
  ) => Array<ReactTestInstance> | [];
135
- queryAllByPlaceholderText: (
136
- placeholder: TextMatch,
137
- options?: TextMatchOptions
138
- ) => Array<ReactTestInstance> | [];
139
- queryAllByDisplayValue: (
140
- value: TextMatch,
141
- options?: TextMatchOptions
142
- ) => Array<ReactTestInstance> | [];
143
-
144
- // Unsafe aliases
145
- UNSAFE_queryByType: <P>(
146
- type: React.ComponentType<P>
147
- ) => ReactTestInstance | null;
148
- UNSAFE_queryAllByType: <P>(
149
- type: React.ComponentType<P>
150
- ) => Array<ReactTestInstance> | [];
151
- UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
152
- UNSAFE_queryAllByProps: (props: { [string]: any }) =>
153
- | Array<ReactTestInstance>
154
- | [];
155
- }
156
-
157
- type WaitForOptions = {
158
- timeout?: number,
159
- interval?: number,
160
- onTimeout?: (error: mixed) => Error,
161
- };
162
- type WaitForFunction = <T = any>(
163
- expectation: () => T,
164
- options?: WaitForOptions
165
- ) => Promise<T>;
166
-
167
- interface FindByAPI {
168
100
  findByText: (
169
101
  text: TextMatch,
170
102
  queryOptions?: TextMatchOptions,
171
103
  waitForOptions?: WaitForOptions
172
104
  ) => FindReturn;
173
- findByPlaceholderText: (
174
- placeholder: TextMatch,
175
- queryOptions?: TextMatchOptions,
176
- waitForOptions?: WaitForOptions
177
- ) => FindReturn;
178
- findByDisplayValue: (
179
- value: TextMatch,
105
+ findAllByText: (
106
+ text: TextMatch,
180
107
  queryOptions?: TextMatchOptions,
181
108
  waitForOptions?: WaitForOptions
182
- ) => FindReturn;
109
+ ) => FindAllReturn;
110
+ }
111
+
112
+ interface ByTestIdQueries {
113
+ getByTestId: (
114
+ testID: TextMatch,
115
+ options?: TextMatchOptions
116
+ ) => ReactTestInstance;
117
+ getAllByTestId: (
118
+ testID: TextMatch,
119
+ options?: TextMatchOptions
120
+ ) => Array<ReactTestInstance>;
121
+ queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
122
+ queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance> | [];
183
123
  findByTestId: (
184
124
  testID: TextMatch,
185
125
  queryOptions?: TextMatchOptions,
186
126
  waitForOptions?: WaitForOptions
187
127
  ) => FindReturn;
188
- findAllByText: (
189
- text: TextMatch,
128
+ findAllByTestId: (
129
+ testID: TextMatch,
190
130
  queryOptions?: TextMatchOptions,
191
131
  waitForOptions?: WaitForOptions
192
132
  ) => FindAllReturn;
193
- findAllByPlaceholderText: (
194
- placeholder: TextMatch,
133
+ }
134
+
135
+ interface ByDisplayValueQueries {
136
+ getByDisplayValue: (
137
+ value: TextMatch,
138
+ options?: TextMatchOptions
139
+ ) => ReactTestInstance;
140
+ getAllByDisplayValue: (
141
+ value: TextMatch,
142
+ options?: TextMatchOptions
143
+ ) => Array<ReactTestInstance>;
144
+ queryByDisplayValue: (
145
+ value: TextMatch,
146
+ options?: TextMatchOptions
147
+ ) => ReactTestInstance | null;
148
+ queryAllByDisplayValue: (
149
+ value: TextMatch,
150
+ options?: TextMatchOptions
151
+ ) => Array<ReactTestInstance> | [];
152
+ findByDisplayValue: (
153
+ value: TextMatch,
195
154
  queryOptions?: TextMatchOptions,
196
155
  waitForOptions?: WaitForOptions
197
- ) => FindAllReturn;
156
+ ) => FindReturn;
198
157
  findAllByDisplayValue: (
199
158
  value: TextMatch,
200
159
  queryOptions?: TextMatchOptions,
201
160
  waitForOptions?: WaitForOptions
202
161
  ) => FindAllReturn;
203
- findAllByTestId: (
204
- testID: TextMatch,
162
+ }
163
+
164
+ interface ByPlaceholderTextQueries {
165
+ getByPlaceholderText: (
166
+ placeholder: TextMatch,
167
+ options?: TextMatchOptions
168
+ ) => ReactTestInstance;
169
+ getAllByPlaceholderText: (
170
+ placeholder: TextMatch,
171
+ options?: TextMatchOptions
172
+ ) => Array<ReactTestInstance>;
173
+ queryByPlaceholderText: (
174
+ placeholder: TextMatch,
175
+ options?: TextMatchOptions
176
+ ) => ReactTestInstance | null;
177
+ queryAllByPlaceholderText: (
178
+ placeholder: TextMatch,
179
+ options?: TextMatchOptions
180
+ ) => Array<ReactTestInstance> | [];
181
+ findByPlaceholderText: (
182
+ placeholder: TextMatch,
183
+ queryOptions?: TextMatchOptions,
184
+ waitForOptions?: WaitForOptions
185
+ ) => FindReturn;
186
+ findAllByPlaceholderText: (
187
+ placeholder: TextMatch,
205
188
  queryOptions?: TextMatchOptions,
206
189
  waitForOptions?: WaitForOptions
207
190
  ) => FindAllReturn;
208
191
  }
209
192
 
193
+ interface UnsafeByTypeQueries {
194
+ UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
195
+ UNSAFE_getAllByType: <P>(
196
+ type: React.ComponentType<P>
197
+ ) => Array<ReactTestInstance>;
198
+ UNSAFE_queryByType: <P>(
199
+ type: React.ComponentType<P>
200
+ ) => ReactTestInstance | null;
201
+ UNSAFE_queryAllByType: <P>(
202
+ type: React.ComponentType<P>
203
+ ) => Array<ReactTestInstance> | [];
204
+ }
205
+
206
+ interface UnsafeByPropsQueries {
207
+ UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
208
+ UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
209
+ UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
210
+ UNSAFE_queryAllByProps: (props: { [string]: any }) =>
211
+ | Array<ReactTestInstance>
212
+ | [];
213
+ }
210
214
  interface A11yAPI {
211
215
  // Label
212
216
  getByLabelText: (matcher: TextMatch) => GetReturn;
@@ -313,7 +317,13 @@ type Debug = {
313
317
  shallow: (message?: string) => void,
314
318
  };
315
319
 
316
- type Queries = GetByAPI & QueryByAPI & FindByAPI & A11yAPI;
320
+ type Queries = ByTextQueries &
321
+ ByTestIdQueries &
322
+ ByDisplayValueQueries &
323
+ ByPlaceholderTextQueries &
324
+ UnsafeByTypeQueries &
325
+ UnsafeByPropsQueries &
326
+ A11yAPI;
317
327
 
318
328
  interface RenderAPI extends Queries {
319
329
  update(nextElement: React.Element<any>): void;
@@ -1,6 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
3
- import type { TextMatchOptions } from './byText';
4
- declare const queryAllByDisplayValue: (instance: ReactTestInstance) => (displayValue: TextMatch, queryOptions?: TextMatchOptions | undefined) => Array<ReactTestInstance>;
5
- declare const getByDisplayValue: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance, getAllByDisplayValue: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance[], queryByDisplayValue: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance | null, findByDisplayValue: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>, findAllByDisplayValue: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
6
- export { findAllByDisplayValue, findByDisplayValue, getAllByDisplayValue, getByDisplayValue, queryAllByDisplayValue, queryByDisplayValue, };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/byDisplayValue.ts"],"names":["getTextInputNodeByDisplayValue","node","value","options","TextInput","require","exact","normalizer","nodeValue","props","undefined","defaultValue","error","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getByDisplayValue","getAllBy","getAllByDisplayValue","queryBy","queryByDisplayValue","findBy","findByDisplayValue","findAllBy","findAllByDisplayValue"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;AAGA,MAAMA,8BAA8B,GAAG,CACrCC,IADqC,EAErCC,KAFqC,EAGrCC,OAAyB,GAAG,EAHS,KAIlC;AACH,MAAI;AACF,UAAM;AAAEC,MAAAA;AAAF,QAAgBC,OAAO,CAAC,cAAD,CAA7B;;AACA,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAwBJ,OAA9B;AACA,UAAMK,SAAS,GACbP,IAAI,CAACQ,KAAL,CAAWP,KAAX,KAAqBQ,SAArB,GACIT,IAAI,CAACQ,KAAL,CAAWP,KADf,GAEID,IAAI,CAACQ,KAAL,CAAWE,YAHjB;AAIA,WACE,wCAAiBV,IAAjB,EAAuBG,SAAvB,KACA,sBAAQF,KAAR,EAAeM,SAAf,EAA0BD,UAA1B,EAAsCD,KAAtC,CAFF;AAID,GAXD,CAWE,OAAOM,KAAP,EAAc;AACd,UAAM,4CAA+BA,KAA/B,CAAN;AACD;AACF,CAnBD;;AAqBA,MAAMC,sBAAsB,GAC1BC,QAD6B,IAM7B,SAASC,wBAAT,CAAkCC,YAAlC,EAAgDC,YAAhD,EAA8D;AAC5D,SAAOH,QAAQ,CAACI,OAAT,CAAkBjB,IAAD,IACtBD,8BAA8B,CAACC,IAAD,EAAOe,YAAP,EAAqBC,YAArB,CADzB,CAAP;AAGD,CAVH;;;;AAYA,MAAME,gBAAgB,GAAIH,YAAD,IACtB,+CAA8CI,MAAM,CAACJ,YAAD,CAAe,GADtE;;AAEA,MAAMK,eAAe,GAAIL,YAAD,IACrB,gDAA+CI,MAAM,CAACJ,YAAD,CAAe,EADvE;;AAGA,MAAM;AACJM,EAAAA,KAAK,EAAEC,iBADH;AAEJC,EAAAA,QAAQ,EAAEC,oBAFN;AAGJC,EAAAA,OAAO,EAAEC,mBAHL;AAIJC,EAAAA,MAAM,EAAEC,kBAJJ;AAKJC,EAAAA,SAAS,EAAEC;AALP,IAMkB,8BACtBlB,sBADsB,EAEtBQ,eAFsB,EAGtBF,gBAHsB,CANxB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type { Queries } from './makeQueries';\nimport { filterNodeByType } from './filterNodeByType';\nimport { createLibraryNotSupportedError } from './errors';\nimport type { TextMatchOptions } from './byText';\n\nconst getTextInputNodeByDisplayValue = (\n node: ReactTestInstance,\n value: TextMatch,\n options: TextMatchOptions = {}\n) => {\n try {\n const { TextInput } = require('react-native');\n const { exact, normalizer } = options;\n const nodeValue =\n node.props.value !== undefined\n ? node.props.value\n : node.props.defaultValue;\n return (\n filterNodeByType(node, TextInput) &&\n matches(value, nodeValue, normalizer, exact)\n );\n } catch (error) {\n throw createLibraryNotSupportedError(error);\n }\n};\n\nconst queryAllByDisplayValue = (\n instance: ReactTestInstance\n): ((\n displayValue: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByDisplayValueFn(displayValue, queryOptions) {\n return instance.findAll((node) =>\n getTextInputNodeByDisplayValue(node, displayValue, queryOptions)\n );\n };\n\nconst getMultipleError = (displayValue: TextMatch) =>\n `Found multiple elements with display value: ${String(displayValue)} `;\nconst getMissingError = (displayValue: TextMatch) =>\n `Unable to find an element with displayValue: ${String(displayValue)}`;\n\nconst {\n getBy: getByDisplayValue,\n getAllBy: getAllByDisplayValue,\n queryBy: queryByDisplayValue,\n findBy: findByDisplayValue,\n findAllBy: findAllByDisplayValue,\n}: Queries<TextMatch> = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError\n);\n\nexport {\n findAllByDisplayValue,\n findByDisplayValue,\n getAllByDisplayValue,\n getByDisplayValue,\n queryAllByDisplayValue,\n queryByDisplayValue,\n};\n"],"file":"byDisplayValue.js"}
@@ -1,6 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
3
- import type { TextMatchOptions } from './byText';
4
- declare const queryAllByPlaceholderText: (instance: ReactTestInstance) => (placeholder: TextMatch, queryOptions?: TextMatchOptions | undefined) => Array<ReactTestInstance>;
5
- declare const getByPlaceholderText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance, getAllByPlaceholderText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance[], queryByPlaceholderText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance | null, findByPlaceholderText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>, findAllByPlaceholderText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
6
- export { findAllByPlaceholderText, findByPlaceholderText, getAllByPlaceholderText, getByPlaceholderText, queryAllByPlaceholderText, queryByPlaceholderText, };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/byPlaceholderText.ts"],"names":["getTextInputNodeByPlaceholderText","node","placeholder","options","TextInput","require","exact","normalizer","props","error","queryAllByPlaceholderText","instance","queryAllByPlaceholderFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getByPlaceholderText","getAllBy","getAllByPlaceholderText","queryBy","queryByPlaceholderText","findBy","findByPlaceholderText","findAllBy","findAllByPlaceholderText"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AACA;;AAGA,MAAMA,iCAAiC,GAAG,CACxCC,IADwC,EAExCC,WAFwC,EAGxCC,OAAyB,GAAG,EAHY,KAIrC;AACH,MAAI;AACF,UAAM;AAAEC,MAAAA;AAAF,QAAgBC,OAAO,CAAC,cAAD,CAA7B;;AACA,UAAM;AAAEC,MAAAA,KAAF;AAASC,MAAAA;AAAT,QAAwBJ,OAA9B;AACA,WACE,wCAAiBF,IAAjB,EAAuBG,SAAvB,KACA,sBAAQF,WAAR,EAAqBD,IAAI,CAACO,KAAL,CAAWN,WAAhC,EAA6CK,UAA7C,EAAyDD,KAAzD,CAFF;AAID,GAPD,CAOE,OAAOG,KAAP,EAAc;AACd,UAAM,4CAA+BA,KAA/B,CAAN;AACD;AACF,CAfD;;AAiBA,MAAMC,yBAAyB,GAC7BC,QADgC,IAMhC,SAASC,uBAAT,CAAiCV,WAAjC,EAA8CW,YAA9C,EAA4D;AAC1D,SAAOF,QAAQ,CAACG,OAAT,CAAkBb,IAAD,IACtBD,iCAAiC,CAACC,IAAD,EAAOC,WAAP,EAAoBW,YAApB,CAD5B,CAAP;AAGD,CAVH;;;;AAYA,MAAME,gBAAgB,GAAIb,WAAD,IACtB,6CAA4Cc,MAAM,CAACd,WAAD,CAAc,GADnE;;AAEA,MAAMe,eAAe,GAAIf,WAAD,IACrB,+CAA8Cc,MAAM,CAACd,WAAD,CAAc,EADrE;;AAGA,MAAM;AACJgB,EAAAA,KAAK,EAAEC,oBADH;AAEJC,EAAAA,QAAQ,EAAEC,uBAFN;AAGJC,EAAAA,OAAO,EAAEC,sBAHL;AAIJC,EAAAA,MAAM,EAAEC,qBAJJ;AAKJC,EAAAA,SAAS,EAAEC;AALP,IAMkB,8BACtBjB,yBADsB,EAEtBO,eAFsB,EAGtBF,gBAHsB,CANxB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type { Queries } from './makeQueries';\nimport { filterNodeByType } from './filterNodeByType';\nimport { createLibraryNotSupportedError } from './errors';\nimport type { TextMatchOptions } from './byText';\n\nconst getTextInputNodeByPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n try {\n const { TextInput } = require('react-native');\n const { exact, normalizer } = options;\n return (\n filterNodeByType(node, TextInput) &&\n matches(placeholder, node.props.placeholder, normalizer, exact)\n );\n } catch (error) {\n throw createLibraryNotSupportedError(error);\n }\n};\n\nconst queryAllByPlaceholderText = (\n instance: ReactTestInstance\n): ((\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return instance.findAll((node) =>\n getTextInputNodeByPlaceholderText(node, placeholder, queryOptions)\n );\n };\n\nconst getMultipleError = (placeholder: TextMatch) =>\n `Found multiple elements with placeholder: ${String(placeholder)} `;\nconst getMissingError = (placeholder: TextMatch) =>\n `Unable to find an element with placeholder: ${String(placeholder)}`;\n\nconst {\n getBy: getByPlaceholderText,\n getAllBy: getAllByPlaceholderText,\n queryBy: queryByPlaceholderText,\n findBy: findByPlaceholderText,\n findAllBy: findAllByPlaceholderText,\n}: Queries<TextMatch> = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError\n);\n\nexport {\n findAllByPlaceholderText,\n findByPlaceholderText,\n getAllByPlaceholderText,\n getByPlaceholderText,\n queryAllByPlaceholderText,\n queryByPlaceholderText,\n};\n"],"file":"byPlaceholderText.js"}
@@ -1,6 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
3
- import type { TextMatchOptions } from './byText';
4
- declare const queryAllByTestId: (instance: ReactTestInstance) => (testId: TextMatch, queryOptions?: TextMatchOptions | undefined) => Array<ReactTestInstance>;
5
- declare const getByTestId: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance, getAllByTestId: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance[], queryByTestId: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance | null, findByTestId: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>, findAllByTestId: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
6
- export { findAllByTestId, findByTestId, getAllByTestId, getByTestId, queryAllByTestId, queryByTestId, };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/byTestId.ts"],"names":["getNodeByTestId","node","testID","options","exact","normalizer","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","results","findAll","filter","element","type","getMultipleError","String","getMissingError","getBy","getByTestId","getAllBy","getAllByTestId","queryBy","queryByTestId","findBy","findByTestId","findAllBy","findAllByTestId"],"mappings":";;;;;;;AACA;;AACA;;AAIA,MAAMA,eAAe,GAAG,CACtBC,IADsB,EAEtBC,MAFsB,EAGtBC,OAAyB,GAAG,EAHN,KAInB;AACH,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAAwBF,OAA9B;AACA,SAAO,sBAAQD,MAAR,EAAgBD,IAAI,CAACK,KAAL,CAAWJ,MAA3B,EAAmCG,UAAnC,EAA+CD,KAA/C,CAAP;AACD,CAPD;;AASA,MAAMG,gBAAgB,GACpBC,QADuB,IAMvB,SAASC,kBAAT,CAA4BC,MAA5B,EAAoCC,YAApC,EAAkD;AAChD,QAAMC,OAAO,GAAGJ,QAAQ,CACrBK,OADa,CACJZ,IAAD,IAAUD,eAAe,CAACC,IAAD,EAAOS,MAAP,EAAeC,YAAf,CADpB,EAEbG,MAFa,CAELC,OAAD,IAAa,OAAOA,OAAO,CAACC,IAAf,KAAwB,QAF/B,CAAhB;AAIA,SAAOJ,OAAP;AACD,CAZH;;;;AAcA,MAAMK,gBAAgB,GAAIP,MAAD,IACtB,wCAAuCQ,MAAM,CAACR,MAAD,CAAS,EADzD;;AAEA,MAAMS,eAAe,GAAIT,MAAD,IACrB,0CAAyCQ,MAAM,CAACR,MAAD,CAAS,EAD3D;;AAGA,MAAM;AACJU,EAAAA,KAAK,EAAEC,WADH;AAEJC,EAAAA,QAAQ,EAAEC,cAFN;AAGJC,EAAAA,OAAO,EAAEC,aAHL;AAIJC,EAAAA,MAAM,EAAEC,YAJJ;AAKJC,EAAAA,SAAS,EAAEC;AALP,IAMkB,8BACtBtB,gBADsB,EAEtBY,eAFsB,EAGtBF,gBAHsB,CANxB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type { Queries } from './makeQueries';\nimport type { TextMatchOptions } from './byText';\n\nconst getNodeByTestId = (\n node: ReactTestInstance,\n testID: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(testID, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (\n instance: ReactTestInstance\n): ((\n testId: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTestIdFn(testId, queryOptions) {\n const results = instance\n .findAll((node) => getNodeByTestId(node, testId, queryOptions))\n .filter((element) => typeof element.type === 'string');\n\n return results;\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst {\n getBy: getByTestId,\n getAllBy: getAllByTestId,\n queryBy: queryByTestId,\n findBy: findByTestId,\n findAllBy: findAllByTestId,\n}: Queries<TextMatch> = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError\n);\n\nexport {\n findAllByTestId,\n findByTestId,\n getAllByTestId,\n getByTestId,\n queryAllByTestId,\n queryByTestId,\n};\n"],"file":"byTestId.js"}
@@ -1,10 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
3
- import type { NormalizerFn } from '../matches';
4
- export declare type TextMatchOptions = {
5
- exact?: boolean;
6
- normalizer?: NormalizerFn;
7
- };
8
- declare const queryAllByText: (instance: ReactTestInstance) => (text: TextMatch, queryOptions?: TextMatchOptions | undefined) => Array<ReactTestInstance>;
9
- declare const getByText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance, getAllByText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance[], queryByText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: TextMatchOptions | undefined) => ReactTestInstance | null, findByText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>, findAllByText: (instance: ReactTestInstance) => (args: TextMatch, queryOptions?: (TextMatchOptions & import("../waitFor").WaitForOptions) | undefined, waitForOptions?: import("../waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
10
- export { findAllByText, findByText, getAllByText, getByText, queryAllByText, queryByText, };
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/byText.ts"],"names":["getChildrenAsText","children","TextComponent","textContent","React","Children","forEach","child","push","toString","props","Fragment","getNodeByText","node","text","options","Text","require","isTextComponent","textChildren","textToTest","join","exact","normalizer","error","queryAllByText","instance","queryAllByTextFn","queryOptions","results","findAll","getMultipleError","String","getMissingError","getBy","getByText","getAllBy","getAllByText","queryBy","queryByText","findBy","findByText","findAllBy","findAllByText"],"mappings":";;;;;;;AACA;;AACA;;AAEA;;AAEA;;AACA;;;;;;AAOA,MAAMA,iBAAiB,GAAG,CACxBC,QADwB,EAExBC,aAFwB,KAGrB;AACH,QAAMC,WAAqB,GAAG,EAA9B;AACAC,EAAAA,KAAK,CAACC,QAAN,CAAeC,OAAf,CAAuBL,QAAvB,EAAkCM,KAAD,IAAW;AAAA;;AAC1C,QAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7BJ,MAAAA,WAAW,CAACK,IAAZ,CAAiBD,KAAjB;AACA;AACD;;AAED,QAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;AAC7BJ,MAAAA,WAAW,CAACK,IAAZ,CAAiBD,KAAK,CAACE,QAAN,EAAjB;AACA;AACD;;AAED,QAAIF,KAAJ,aAAIA,KAAJ,+BAAIA,KAAK,CAAEG,KAAX,yCAAI,aAAcT,QAAlB,EAA4B;AAC1B;AACA;AACA;AACA;AACA,UAAI,wCAAiBM,KAAjB,EAAwBL,aAAxB,CAAJ,EAA4C;AAC1C;AACD;;AAED,UAAI,wCAAiBK,KAAjB,EAAwBH,KAAK,CAACO,QAA9B,CAAJ,EAA6C;AAC3CR,QAAAA,WAAW,CAACK,IAAZ,CACE,GAAGR,iBAAiB,CAACO,KAAK,CAACG,KAAN,CAAYT,QAAb,EAAuBC,aAAvB,CADtB;AAGD;AACF;AACF,GA1BD;AA4BA,SAAOC,WAAP;AACD,CAlCD;;AAoCA,MAAMS,aAAa,GAAG,CACpBC,IADoB,EAEpBC,IAFoB,EAGpBC,OAAyB,GAAG,EAHR,KAIjB;AACH,MAAI;AACF,UAAM;AAAEC,MAAAA;AAAF,QAAWC,OAAO,CAAC,cAAD,CAAxB;;AACA,UAAMC,eAAe,GAAG,wCAAiBL,IAAjB,EAAuBG,IAAvB,CAAxB;;AACA,QAAIE,eAAJ,EAAqB;AACnB,YAAMC,YAAY,GAAGnB,iBAAiB,CAACa,IAAI,CAACH,KAAL,CAAWT,QAAZ,EAAsBe,IAAtB,CAAtC;;AACA,UAAIG,YAAJ,EAAkB;AAChB,cAAMC,UAAU,GAAGD,YAAY,CAACE,IAAb,CAAkB,EAAlB,CAAnB;AACA,cAAM;AAAEC,UAAAA,KAAF;AAASC,UAAAA;AAAT,YAAwBR,OAA9B;AACA,eAAO,sBAAQD,IAAR,EAAcM,UAAd,EAA0BG,UAA1B,EAAsCD,KAAtC,CAAP;AACD;AACF;;AACD,WAAO,KAAP;AACD,GAZD,CAYE,OAAOE,KAAP,EAAc;AACd,UAAM,4CAA+BA,KAA/B,CAAN;AACD;AACF,CApBD;;AAsBA,MAAMC,cAAc,GAClBC,QADqB,IAMrB,SAASC,gBAAT,CAA0Bb,IAA1B,EAAgCc,YAAhC,EAA8C;AAC5C,QAAMC,OAAO,GAAGH,QAAQ,CAACI,OAAT,CAAkBjB,IAAD,IAC/BD,aAAa,CAACC,IAAD,EAAOC,IAAP,EAAac,YAAb,CADC,CAAhB;AAIA,SAAOC,OAAP;AACD,CAZH;;;;AAcA,MAAME,gBAAgB,GAAIjB,IAAD,IACtB,sCAAqCkB,MAAM,CAAClB,IAAD,CAAO,EADrD;;AAEA,MAAMmB,eAAe,GAAInB,IAAD,IACrB,wCAAuCkB,MAAM,CAAClB,IAAD,CAAO,EADvD;;AAGA,MAAM;AACJoB,EAAAA,KAAK,EAAEC,SADH;AAEJC,EAAAA,QAAQ,EAAEC,YAFN;AAGJC,EAAAA,OAAO,EAAEC,WAHL;AAIJC,EAAAA,MAAM,EAAEC,UAJJ;AAKJC,EAAAA,SAAS,EAAEC;AALP,IAMkB,8BACtBlB,cADsB,EAEtBQ,eAFsB,EAGtBF,gBAHsB,CANxB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\nimport { matches, TextMatch } from '../matches';\nimport type { NormalizerFn } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type { Queries } from './makeQueries';\nimport { filterNodeByType } from './filterNodeByType';\nimport { createLibraryNotSupportedError } from './errors';\n\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n\nconst getChildrenAsText = (\n children: React.ReactChild[],\n TextComponent: React.ComponentType\n) => {\n const textContent: string[] = [];\n React.Children.forEach(children, (child) => {\n if (typeof child === 'string') {\n textContent.push(child);\n return;\n }\n\n if (typeof child === 'number') {\n textContent.push(child.toString());\n return;\n }\n\n if (child?.props?.children) {\n // Bail on traversing text children down the tree if current node (child)\n // has no text. In such situations, react-test-renderer will traverse down\n // this tree in a separate call and run this query again. As a result, the\n // query will match the deepest text node that matches requested text.\n if (filterNodeByType(child, TextComponent)) {\n return;\n }\n\n if (filterNodeByType(child, React.Fragment)) {\n textContent.push(\n ...getChildrenAsText(child.props.children, TextComponent)\n );\n }\n }\n });\n\n return textContent;\n};\n\nconst getNodeByText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n try {\n const { Text } = require('react-native');\n const isTextComponent = filterNodeByType(node, Text);\n if (isTextComponent) {\n const textChildren = getChildrenAsText(node.props.children, Text);\n if (textChildren) {\n const textToTest = textChildren.join('');\n const { exact, normalizer } = options;\n return matches(text, textToTest, normalizer, exact);\n }\n }\n return false;\n } catch (error) {\n throw createLibraryNotSupportedError(error);\n }\n};\n\nconst queryAllByText = (\n instance: ReactTestInstance\n): ((\n text: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, queryOptions) {\n const results = instance.findAll((node) =>\n getNodeByText(node, text, queryOptions)\n );\n\n return results;\n };\n\nconst getMultipleError = (text: TextMatch) =>\n `Found multiple elements with text: ${String(text)}`;\nconst getMissingError = (text: TextMatch) =>\n `Unable to find an element with text: ${String(text)}`;\n\nconst {\n getBy: getByText,\n getAllBy: getAllByText,\n queryBy: queryByText,\n findBy: findByText,\n findAllBy: findAllByText,\n}: Queries<TextMatch> = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport {\n findAllByText,\n findByText,\n getAllByText,\n getByText,\n queryAllByText,\n queryByText,\n};\n"],"file":"byText.js"}
@@ -1,17 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import type { WaitForOptions } from '../waitFor';
3
- import type { TextMatch } from '../matches';
4
- import type { TextMatchOptions } from './byText';
5
- export declare type FindByAPI = {
6
- findAllByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<Array<ReactTestInstance>>;
7
- findAllByPlaceholder: () => void;
8
- findAllByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<Array<ReactTestInstance>>;
9
- findAllByTestId: (testId: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<Array<ReactTestInstance>>;
10
- findAllByText: (text: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<Array<ReactTestInstance>>;
11
- findByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
12
- findByPlaceholder: () => void;
13
- findByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
14
- findByTestId: (testId: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
15
- findByText: (text: TextMatch, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
16
- };
17
- export declare const findByAPI: (instance: ReactTestInstance) => FindByAPI;
@@ -1,33 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.findByAPI = void 0;
7
-
8
- var _byTestId = require("./byTestId");
9
-
10
- var _byText = require("./byText");
11
-
12
- var _byPlaceholderText = require("./byPlaceholderText");
13
-
14
- var _byDisplayValue = require("./byDisplayValue");
15
-
16
- var _errors = require("./errors");
17
-
18
- const findByAPI = instance => ({
19
- findByTestId: (0, _byTestId.findByTestId)(instance),
20
- findByText: (0, _byText.findByText)(instance),
21
- findByPlaceholderText: (0, _byPlaceholderText.findByPlaceholderText)(instance),
22
- findByDisplayValue: (0, _byDisplayValue.findByDisplayValue)(instance),
23
- findAllByTestId: (0, _byTestId.findAllByTestId)(instance),
24
- findAllByText: (0, _byText.findAllByText)(instance),
25
- findAllByPlaceholderText: (0, _byPlaceholderText.findAllByPlaceholderText)(instance),
26
- findAllByDisplayValue: (0, _byDisplayValue.findAllByDisplayValue)(instance),
27
- // Renamed
28
- findByPlaceholder: () => (0, _errors.throwRenamedFunctionError)('findByPlaceholder', 'findByPlaceholderText'),
29
- findAllByPlaceholder: () => (0, _errors.throwRenamedFunctionError)('findAllByPlaceholder', 'findAllByPlaceholderText')
30
- });
31
-
32
- exports.findByAPI = findByAPI;
33
- //# sourceMappingURL=findByAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/findByAPI.ts"],"names":["findByAPI","instance","findByTestId","findByText","findByPlaceholderText","findByDisplayValue","findAllByTestId","findAllByText","findAllByPlaceholderText","findAllByDisplayValue","findByPlaceholder","findAllByPlaceholder"],"mappings":";;;;;;;AAIA;;AACA;;AACA;;AAIA;;AACA;;AA+CO,MAAMA,SAAS,GAAIC,QAAD,KAA6C;AACpEC,EAAAA,YAAY,EAAE,4BAAaD,QAAb,CADsD;AAEpEE,EAAAA,UAAU,EAAE,wBAAWF,QAAX,CAFwD;AAGpEG,EAAAA,qBAAqB,EAAE,8CAAsBH,QAAtB,CAH6C;AAIpEI,EAAAA,kBAAkB,EAAE,wCAAmBJ,QAAnB,CAJgD;AAKpEK,EAAAA,eAAe,EAAE,+BAAgBL,QAAhB,CALmD;AAMpEM,EAAAA,aAAa,EAAE,2BAAcN,QAAd,CANqD;AAOpEO,EAAAA,wBAAwB,EAAE,iDAAyBP,QAAzB,CAP0C;AAQpEQ,EAAAA,qBAAqB,EAAE,2CAAsBR,QAAtB,CAR6C;AAUpE;AACAS,EAAAA,iBAAiB,EAAE,MACjB,uCAA0B,mBAA1B,EAA+C,uBAA/C,CAZkE;AAapEC,EAAAA,oBAAoB,EAAE,MACpB,uCACE,sBADF,EAEE,0BAFF;AAdkE,CAA7C,CAAlB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { WaitForOptions } from '../waitFor';\nimport type { TextMatch } from '../matches';\nimport type { TextMatchOptions } from './byText';\nimport { findAllByTestId, findByTestId } from './byTestId';\nimport { findAllByText, findByText } from './byText';\nimport {\n findAllByPlaceholderText,\n findByPlaceholderText,\n} from './byPlaceholderText';\nimport { findAllByDisplayValue, findByDisplayValue } from './byDisplayValue';\nimport { throwRenamedFunctionError } from './errors';\n\nexport type FindByAPI = {\n findAllByDisplayValue: (\n value: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<Array<ReactTestInstance>>;\n findAllByPlaceholder: () => void;\n findAllByPlaceholderText: (\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<Array<ReactTestInstance>>;\n findAllByTestId: (\n testId: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<Array<ReactTestInstance>>;\n findAllByText: (\n text: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<Array<ReactTestInstance>>;\n findByDisplayValue: (\n value: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<ReactTestInstance>;\n findByPlaceholder: () => void;\n findByPlaceholderText: (\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<ReactTestInstance>;\n findByTestId: (\n testId: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<ReactTestInstance>;\n findByText: (\n text: TextMatch,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n ) => Promise<ReactTestInstance>;\n};\n\nexport const findByAPI = (instance: ReactTestInstance): FindByAPI => ({\n findByTestId: findByTestId(instance),\n findByText: findByText(instance),\n findByPlaceholderText: findByPlaceholderText(instance),\n findByDisplayValue: findByDisplayValue(instance),\n findAllByTestId: findAllByTestId(instance),\n findAllByText: findAllByText(instance),\n findAllByPlaceholderText: findAllByPlaceholderText(instance),\n findAllByDisplayValue: findAllByDisplayValue(instance),\n\n // Renamed\n findByPlaceholder: () =>\n throwRenamedFunctionError('findByPlaceholder', 'findByPlaceholderText'),\n findAllByPlaceholder: () =>\n throwRenamedFunctionError(\n 'findAllByPlaceholder',\n 'findAllByPlaceholderText'\n ),\n});\n"],"file":"findByAPI.js"}
@@ -1,31 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import * as React from 'react';
3
- import type { TextMatch } from '../matches';
4
- import type { TextMatchOptions } from './byText';
5
- export declare type GetByAPI = {
6
- getByText: (text: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance;
7
- getByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance;
8
- getByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance;
9
- getByTestId: (testID: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance;
10
- getAllByTestId: (testID: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
11
- getAllByText: (text: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
12
- getAllByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
13
- getAllByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
14
- UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
15
- UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
16
- UNSAFE_getByProps: (props: {
17
- [key: string]: any;
18
- }) => ReactTestInstance;
19
- UNSAFE_getAllByProps: (props: {
20
- [key: string]: any;
21
- }) => Array<ReactTestInstance>;
22
- };
23
- export declare const UNSAFE_getByType: (instance: ReactTestInstance) => (type: React.ComponentType<any>) => ReactTestInstance;
24
- export declare const UNSAFE_getByProps: (instance: ReactTestInstance) => (props: {
25
- [propName: string]: any;
26
- }) => ReactTestInstance;
27
- export declare const UNSAFE_getAllByType: (instance: ReactTestInstance) => (type: React.ComponentType<any>) => Array<ReactTestInstance>;
28
- export declare const UNSAFE_getAllByProps: (instance: ReactTestInstance) => (props: {
29
- [propName: string]: any;
30
- }) => Array<ReactTestInstance>;
31
- export declare const getByAPI: (instance: ReactTestInstance) => GetByAPI;