@testing-library/react-native 9.2.0 → 10.1.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 (64) hide show
  1. package/README.md +4 -6
  2. package/build/cleanup.js +4 -0
  3. package/build/cleanup.js.map +1 -1
  4. package/build/index.flow.js +107 -95
  5. package/build/pure.d.ts +5 -1
  6. package/build/pure.js +8 -0
  7. package/build/pure.js.map +1 -1
  8. package/build/{helpers → queries}/a11yAPI.d.ts +0 -0
  9. package/build/{helpers → queries}/a11yAPI.js +0 -0
  10. package/build/{helpers → queries}/a11yAPI.js.map +1 -1
  11. package/build/queries/displayValue.d.ts +13 -0
  12. package/build/{helpers/byDisplayValue.js → queries/displayValue.js} +23 -18
  13. package/build/queries/displayValue.js.map +1 -0
  14. package/build/{helpers → queries}/makeA11yQuery.d.ts +0 -0
  15. package/build/{helpers → queries}/makeA11yQuery.js +1 -1
  16. package/build/{helpers → queries}/makeA11yQuery.js.map +1 -1
  17. package/build/queries/makeQueries.d.ts +19 -0
  18. package/build/{helpers → queries}/makeQueries.js +17 -16
  19. package/build/queries/makeQueries.js.map +1 -0
  20. package/build/queries/placeholderText.d.ts +13 -0
  21. package/build/{helpers/byPlaceholderText.js → queries/placeholderText.js} +23 -18
  22. package/build/queries/placeholderText.js.map +1 -0
  23. package/build/queries/testId.d.ts +13 -0
  24. package/build/{helpers/byTestId.js → queries/testId.js} +19 -14
  25. package/build/queries/testId.js.map +1 -0
  26. package/build/queries/text.d.ts +17 -0
  27. package/build/{helpers/byText.js → queries/text.js} +25 -20
  28. package/build/queries/text.js.map +1 -0
  29. package/build/queries/unsafeProps.d.ts +16 -0
  30. package/build/queries/unsafeProps.js +58 -0
  31. package/build/queries/unsafeProps.js.map +1 -0
  32. package/build/queries/unsafeType.d.ts +9 -0
  33. package/build/queries/unsafeType.js +54 -0
  34. package/build/queries/unsafeType.js.map +1 -0
  35. package/build/render.d.ts +35 -44
  36. package/build/render.js +7 -12
  37. package/build/render.js.map +1 -1
  38. package/build/screen.d.ts +4 -0
  39. package/build/screen.js +115 -0
  40. package/build/screen.js.map +1 -0
  41. package/build/within.d.ts +34 -44
  42. package/build/within.js +16 -7
  43. package/build/within.js.map +1 -1
  44. package/package.json +1 -1
  45. package/typings/index.flow.js +107 -95
  46. package/build/helpers/byDisplayValue.d.ts +0 -6
  47. package/build/helpers/byDisplayValue.js.map +0 -1
  48. package/build/helpers/byPlaceholderText.d.ts +0 -6
  49. package/build/helpers/byPlaceholderText.js.map +0 -1
  50. package/build/helpers/byTestId.d.ts +0 -6
  51. package/build/helpers/byTestId.js.map +0 -1
  52. package/build/helpers/byText.d.ts +0 -10
  53. package/build/helpers/byText.js.map +0 -1
  54. package/build/helpers/findByAPI.d.ts +0 -17
  55. package/build/helpers/findByAPI.js +0 -33
  56. package/build/helpers/findByAPI.js.map +0 -1
  57. package/build/helpers/getByAPI.d.ts +0 -31
  58. package/build/helpers/getByAPI.js +0 -83
  59. package/build/helpers/getByAPI.js.map +0 -1
  60. package/build/helpers/makeQueries.d.ts +0 -20
  61. package/build/helpers/makeQueries.js.map +0 -1
  62. package/build/helpers/queryByAPI.d.ts +0 -39
  63. package/build/helpers/queryByAPI.js +0 -87
  64. package/build/helpers/queryByAPI.js.map +0 -1
@@ -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;
@@ -353,6 +363,8 @@ declare module '@testing-library/react-native' {
353
363
  options?: RenderOptions
354
364
  ) => RenderAPI;
355
365
 
366
+ declare export var screen: RenderAPI;
367
+
356
368
  declare export var cleanup: () => void;
357
369
  declare export var fireEvent: FireEventAPI;
358
370
 
@@ -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;
@@ -1,83 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getByAPI = exports.UNSAFE_getByType = exports.UNSAFE_getByProps = exports.UNSAFE_getAllByType = exports.UNSAFE_getAllByProps = void 0;
7
-
8
- var _prettyFormat = _interopRequireDefault(require("pretty-format"));
9
-
10
- var _errors = require("./errors");
11
-
12
- var _byTestId = require("./byTestId");
13
-
14
- var _byText = require("./byText");
15
-
16
- var _byPlaceholderText = require("./byPlaceholderText");
17
-
18
- var _byDisplayValue = require("./byDisplayValue");
19
-
20
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- const UNSAFE_getByType = instance => function getByTypeFn(type) {
23
- try {
24
- return instance.findByType(type);
25
- } catch (error) {
26
- throw new _errors.ErrorWithStack((0, _errors.prepareErrorMessage)(error), getByTypeFn);
27
- }
28
- };
29
-
30
- exports.UNSAFE_getByType = UNSAFE_getByType;
31
-
32
- const UNSAFE_getByProps = instance => function getByPropsFn(props) {
33
- try {
34
- return instance.findByProps(props);
35
- } catch (error) {
36
- throw new _errors.ErrorWithStack((0, _errors.prepareErrorMessage)(error), getByPropsFn);
37
- }
38
- };
39
-
40
- exports.UNSAFE_getByProps = UNSAFE_getByProps;
41
-
42
- const UNSAFE_getAllByType = instance => function getAllByTypeFn(type) {
43
- const results = instance.findAllByType(type);
44
-
45
- if (results.length === 0) {
46
- throw new _errors.ErrorWithStack('No instances found', getAllByTypeFn);
47
- }
48
-
49
- return results;
50
- };
51
-
52
- exports.UNSAFE_getAllByType = UNSAFE_getAllByType;
53
-
54
- const UNSAFE_getAllByProps = instance => function getAllByPropsFn(props) {
55
- const results = instance.findAllByProps(props);
56
-
57
- if (results.length === 0) {
58
- throw new _errors.ErrorWithStack(`No instances found with props:\n${(0, _prettyFormat.default)(props)}`, getAllByPropsFn);
59
- }
60
-
61
- return results;
62
- };
63
-
64
- exports.UNSAFE_getAllByProps = UNSAFE_getAllByProps;
65
-
66
- const getByAPI = instance => ({
67
- getByText: (0, _byText.getByText)(instance),
68
- getByPlaceholderText: (0, _byPlaceholderText.getByPlaceholderText)(instance),
69
- getByDisplayValue: (0, _byDisplayValue.getByDisplayValue)(instance),
70
- getByTestId: (0, _byTestId.getByTestId)(instance),
71
- getAllByText: (0, _byText.getAllByText)(instance),
72
- getAllByPlaceholderText: (0, _byPlaceholderText.getAllByPlaceholderText)(instance),
73
- getAllByDisplayValue: (0, _byDisplayValue.getAllByDisplayValue)(instance),
74
- getAllByTestId: (0, _byTestId.getAllByTestId)(instance),
75
- // Unsafe
76
- UNSAFE_getByType: UNSAFE_getByType(instance),
77
- UNSAFE_getAllByType: UNSAFE_getAllByType(instance),
78
- UNSAFE_getByProps: UNSAFE_getByProps(instance),
79
- UNSAFE_getAllByProps: UNSAFE_getAllByProps(instance)
80
- });
81
-
82
- exports.getByAPI = getByAPI;
83
- //# sourceMappingURL=getByAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/getByAPI.ts"],"names":["UNSAFE_getByType","instance","getByTypeFn","type","findByType","error","ErrorWithStack","UNSAFE_getByProps","getByPropsFn","props","findByProps","UNSAFE_getAllByType","getAllByTypeFn","results","findAllByType","length","UNSAFE_getAllByProps","getAllByPropsFn","findAllByProps","getByAPI","getByText","getByPlaceholderText","getByDisplayValue","getByTestId","getAllByText","getAllByPlaceholderText","getAllByDisplayValue","getAllByTestId"],"mappings":";;;;;;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AAIA;;;;AAgDO,MAAMA,gBAAgB,GAC3BC,QAD8B,IAG9B,SAASC,WAAT,CAAqBC,IAArB,EAAqD;AACnD,MAAI;AACF,WAAOF,QAAQ,CAACG,UAAT,CAAoBD,IAApB,CAAP;AACD,GAFD,CAEE,OAAOE,KAAP,EAAc;AACd,UAAM,IAAIC,sBAAJ,CAAmB,iCAAoBD,KAApB,CAAnB,EAA+CH,WAA/C,CAAN;AACD;AACF,CATI;;;;AAWA,MAAMK,iBAAiB,GAC5BN,QAD+B,IAG/B,SAASO,YAAT,CAAsBC,KAAtB,EAA0D;AACxD,MAAI;AACF,WAAOR,QAAQ,CAACS,WAAT,CAAqBD,KAArB,CAAP;AACD,GAFD,CAEE,OAAOJ,KAAP,EAAc;AACd,UAAM,IAAIC,sBAAJ,CAAmB,iCAAoBD,KAApB,CAAnB,EAA+CG,YAA/C,CAAN;AACD;AACF,CATI;;;;AAWA,MAAMG,mBAAmB,GAC9BV,QADiC,IAGjC,SAASW,cAAT,CAAwBT,IAAxB,EAAwD;AACtD,QAAMU,OAAO,GAAGZ,QAAQ,CAACa,aAAT,CAAuBX,IAAvB,CAAhB;;AACA,MAAIU,OAAO,CAACE,MAAR,KAAmB,CAAvB,EAA0B;AACxB,UAAM,IAAIT,sBAAJ,CAAmB,oBAAnB,EAAyCM,cAAzC,CAAN;AACD;;AACD,SAAOC,OAAP;AACD,CATI;;;;AAWA,MAAMG,oBAAoB,GAC/Bf,QADkC,IAGlC,SAASgB,eAAT,CAAyBR,KAAzB,EAA6D;AAC3D,QAAMI,OAAO,GAAGZ,QAAQ,CAACiB,cAAT,CAAwBT,KAAxB,CAAhB;;AACA,MAAII,OAAO,CAACE,MAAR,KAAmB,CAAvB,EAA0B;AACxB,UAAM,IAAIT,sBAAJ,CACH,mCAAkC,2BAAaG,KAAb,CAAoB,EADnD,EAEJQ,eAFI,CAAN;AAID;;AACD,SAAOJ,OAAP;AACD,CAZI;;;;AAcA,MAAMM,QAAQ,GAAIlB,QAAD,KAA4C;AAClEmB,EAAAA,SAAS,EAAE,uBAAUnB,QAAV,CADuD;AAElEoB,EAAAA,oBAAoB,EAAE,6CAAqBpB,QAArB,CAF4C;AAGlEqB,EAAAA,iBAAiB,EAAE,uCAAkBrB,QAAlB,CAH+C;AAIlEsB,EAAAA,WAAW,EAAE,2BAAYtB,QAAZ,CAJqD;AAKlEuB,EAAAA,YAAY,EAAE,0BAAavB,QAAb,CALoD;AAMlEwB,EAAAA,uBAAuB,EAAE,gDAAwBxB,QAAxB,CANyC;AAOlEyB,EAAAA,oBAAoB,EAAE,0CAAqBzB,QAArB,CAP4C;AAQlE0B,EAAAA,cAAc,EAAE,8BAAe1B,QAAf,CARkD;AAUlE;AACAD,EAAAA,gBAAgB,EAAEA,gBAAgB,CAACC,QAAD,CAXgC;AAYlEU,EAAAA,mBAAmB,EAAEA,mBAAmB,CAACV,QAAD,CAZ0B;AAalEM,EAAAA,iBAAiB,EAAEA,iBAAiB,CAACN,QAAD,CAb8B;AAclEe,EAAAA,oBAAoB,EAAEA,oBAAoB,CAACf,QAAD;AAdwB,CAA5C,CAAjB","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\nimport prettyFormat from 'pretty-format';\nimport type { TextMatch } from '../matches';\nimport { ErrorWithStack, prepareErrorMessage } from './errors';\nimport { getAllByTestId, getByTestId } from './byTestId';\nimport { getAllByText, getByText } from './byText';\nimport {\n getAllByPlaceholderText,\n getByPlaceholderText,\n} from './byPlaceholderText';\nimport { getAllByDisplayValue, getByDisplayValue } from './byDisplayValue';\nimport type { TextMatchOptions } from './byText';\n\nexport type GetByAPI = {\n getByText: (\n text: TextMatch,\n queryOptions?: TextMatchOptions\n ) => ReactTestInstance;\n getByPlaceholderText: (\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions\n ) => ReactTestInstance;\n getByDisplayValue: (\n value: TextMatch,\n queryOptions?: TextMatchOptions\n ) => ReactTestInstance;\n getByTestId: (\n testID: TextMatch,\n queryOptions?: TextMatchOptions\n ) => ReactTestInstance;\n getAllByTestId: (\n testID: TextMatch,\n queryOptions?: TextMatchOptions\n ) => Array<ReactTestInstance>;\n getAllByText: (\n text: TextMatch,\n queryOptions?: TextMatchOptions\n ) => Array<ReactTestInstance>;\n getAllByPlaceholderText: (\n placeholder: TextMatch,\n queryOptions?: TextMatchOptions\n ) => Array<ReactTestInstance>;\n getAllByDisplayValue: (\n value: TextMatch,\n queryOptions?: TextMatchOptions\n ) => Array<ReactTestInstance>;\n\n // Unsafe aliases\n UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;\n UNSAFE_getAllByType: <P>(\n type: React.ComponentType<P>\n ) => Array<ReactTestInstance>;\n UNSAFE_getByProps: (props: { [key: string]: any }) => ReactTestInstance;\n UNSAFE_getAllByProps: (props: {\n [key: string]: any;\n }) => Array<ReactTestInstance>;\n};\n\nexport const UNSAFE_getByType = (\n instance: ReactTestInstance\n): ((type: React.ComponentType<any>) => ReactTestInstance) =>\n function getByTypeFn(type: React.ComponentType<any>) {\n try {\n return instance.findByType(type);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByTypeFn);\n }\n };\n\nexport const UNSAFE_getByProps = (\n instance: ReactTestInstance\n): ((props: { [propName: string]: any }) => ReactTestInstance) =>\n function getByPropsFn(props: { [propName: string]: any }) {\n try {\n return instance.findByProps(props);\n } catch (error) {\n throw new ErrorWithStack(prepareErrorMessage(error), getByPropsFn);\n }\n };\n\nexport const UNSAFE_getAllByType = (\n instance: ReactTestInstance\n): ((type: React.ComponentType<any>) => Array<ReactTestInstance>) =>\n function getAllByTypeFn(type: React.ComponentType<any>) {\n const results = instance.findAllByType(type);\n if (results.length === 0) {\n throw new ErrorWithStack('No instances found', getAllByTypeFn);\n }\n return results;\n };\n\nexport const UNSAFE_getAllByProps = (\n instance: ReactTestInstance\n): ((props: { [propName: string]: any }) => Array<ReactTestInstance>) =>\n function getAllByPropsFn(props: { [propName: string]: any }) {\n const results = instance.findAllByProps(props);\n if (results.length === 0) {\n throw new ErrorWithStack(\n `No instances found with props:\\n${prettyFormat(props)}`,\n getAllByPropsFn\n );\n }\n return results;\n };\n\nexport const getByAPI = (instance: ReactTestInstance): GetByAPI => ({\n getByText: getByText(instance),\n getByPlaceholderText: getByPlaceholderText(instance),\n getByDisplayValue: getByDisplayValue(instance),\n getByTestId: getByTestId(instance),\n getAllByText: getAllByText(instance),\n getAllByPlaceholderText: getAllByPlaceholderText(instance),\n getAllByDisplayValue: getAllByDisplayValue(instance),\n getAllByTestId: getAllByTestId(instance),\n\n // Unsafe\n UNSAFE_getByType: UNSAFE_getByType(instance),\n UNSAFE_getAllByType: UNSAFE_getAllByType(instance),\n UNSAFE_getByProps: UNSAFE_getByProps(instance),\n UNSAFE_getAllByProps: UNSAFE_getAllByProps(instance),\n});\n"],"file":"getByAPI.js"}
@@ -1,20 +0,0 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import type { WaitForOptions } from '../waitFor';
3
- import type { TextMatchOptions } from './byText';
4
- declare type QueryFunction<ArgType, ReturnType> = (instance: ReactTestInstance) => (args: ArgType, queryOptions?: TextMatchOptions) => ReturnType;
5
- declare type FindQueryFunction<ArgType, ReturnType> = (instance: ReactTestInstance) => (args: ArgType, queryOptions?: TextMatchOptions & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReturnType>;
6
- declare type QueryAllByQuery<QueryArg> = QueryFunction<QueryArg, Array<ReactTestInstance>>;
7
- declare type QueryByQuery<QueryArg> = QueryFunction<QueryArg, null | ReactTestInstance>;
8
- declare type GetAllByQuery<QueryArg> = QueryFunction<QueryArg, Array<ReactTestInstance>>;
9
- declare type GetByQuery<QueryArg> = QueryFunction<QueryArg, ReactTestInstance>;
10
- declare type FindAllByQuery<QueryArg> = FindQueryFunction<QueryArg, Array<ReactTestInstance>>;
11
- declare type FindByQuery<QueryArg> = FindQueryFunction<QueryArg, ReactTestInstance>;
12
- export declare type Queries<QueryArg> = {
13
- getBy: GetByQuery<QueryArg>;
14
- getAllBy: GetAllByQuery<QueryArg>;
15
- queryBy: QueryByQuery<QueryArg>;
16
- findBy: FindByQuery<QueryArg>;
17
- findAllBy: FindAllByQuery<QueryArg>;
18
- };
19
- export declare function makeQueries<QueryArg>(queryAllByQuery: QueryAllByQuery<QueryArg>, getMissingError: (args: QueryArg) => string, getMultipleError: (args: QueryArg) => string): Queries<QueryArg>;
20
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/helpers/makeQueries.ts"],"names":["deprecatedKeys","extractDeprecatedWaitForOptionUsage","queryOptions","waitForOptions","timeout","interval","stackTraceError","forEach","key","option","console","warn","toString","makeQueries","queryAllByQuery","getMissingError","getMultipleError","getAllByQuery","instance","getAllFn","args","results","length","ErrorWithStack","queryByQuery","singleQueryFn","getByQuery","getFn","findAllByQuery","findAllFn","deprecatedWaitForOptions","findByQuery","findFn","getBy","getAllBy","queryBy","findBy","findAllBy"],"mappings":";;;;;;;AACA;;AAEA;;;;AAyCA;AACA;AACA,MAAMA,cAAwC,GAAG,CAC/C,SAD+C,EAE/C,UAF+C,EAG/C,iBAH+C,CAAjD;;AAKA,MAAMC,mCAAmC,GAAIC,YAAD,IAAmC;AAC7E,MAAIA,YAAJ,EAAkB;AAChB,UAAMC,cAA8B,GAAG;AACrCC,MAAAA,OAAO,EAAEF,YAAY,CAACE,OADe;AAErCC,MAAAA,QAAQ,EAAEH,YAAY,CAACG,QAFc;AAGrCC,MAAAA,eAAe,EAAEJ,YAAY,CAACI;AAHO,KAAvC;AAKAN,IAAAA,cAAc,CAACO,OAAf,CAAwBC,GAAD,IAAS;AAC9B,YAAMC,MAAM,GAAGP,YAAY,CAACM,GAAD,CAA3B;;AACA,UAAIC,MAAJ,EAAY;AACV;AACAC,QAAAA,OAAO,CAACC,IAAR,CACG,kBAAiBH,GAAI;AAChC;AACA;AACA,2BAA2BA,GAAI,KAAIC,MAAM,CAACG,QAAP,EAAkB,KAJ7C;AAMD;AACF,KAXD;AAYA,WAAOT,cAAP;AACD;AACF,CArBD;;AAuBO,SAASU,WAAT,CACLC,eADK,EAELC,eAFK,EAGLC,gBAHK,EAIc;AACnB,WAASC,aAAT,CAAuBC,QAAvB,EAAoD;AAClD,WAAO,SAASC,QAAT,CAAkBC,IAAlB,EAAkClB,YAAlC,EAAmE;AACxE,YAAMmB,OAAO,GAAGP,eAAe,CAACI,QAAD,CAAf,CAA0BE,IAA1B,EAAgClB,YAAhC,CAAhB;;AAEA,UAAImB,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;AACxB,cAAM,IAAIC,sBAAJ,CAAmBR,eAAe,CAACK,IAAD,CAAlC,EAA0CD,QAA1C,CAAN;AACD;;AAED,aAAOE,OAAP;AACD,KARD;AASD;;AAED,WAASG,YAAT,CAAsBN,QAAtB,EAAmD;AACjD,WAAO,SAASO,aAAT,CACLL,IADK,EAELlB,YAFK,EAGL;AACA,YAAMmB,OAAO,GAAGP,eAAe,CAACI,QAAD,CAAf,CAA0BE,IAA1B,EAAgClB,YAAhC,CAAhB;;AAEA,UAAImB,OAAO,CAACC,MAAR,GAAiB,CAArB,EAAwB;AACtB,cAAM,IAAIC,sBAAJ,CAAmBP,gBAAgB,CAACI,IAAD,CAAnC,EAA2CK,aAA3C,CAAN;AACD;;AAED,UAAIJ,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;AACxB,eAAO,IAAP;AACD;;AAED,aAAOD,OAAO,CAAC,CAAD,CAAd;AACD,KAfD;AAgBD;;AAED,WAASK,UAAT,CAAoBR,QAApB,EAAiD;AAC/C,WAAO,SAASS,KAAT,CAAeP,IAAf,EAA+BlB,YAA/B,EAAgE;AACrE,YAAMmB,OAAO,GAAGP,eAAe,CAACI,QAAD,CAAf,CAA0BE,IAA1B,EAAgClB,YAAhC,CAAhB;;AAEA,UAAImB,OAAO,CAACC,MAAR,GAAiB,CAArB,EAAwB;AACtB,cAAM,IAAIC,sBAAJ,CAAmBP,gBAAgB,CAACI,IAAD,CAAnC,EAA2CO,KAA3C,CAAN;AACD;;AAED,UAAIN,OAAO,CAACC,MAAR,KAAmB,CAAvB,EAA0B;AACxB,cAAM,IAAIC,sBAAJ,CAAmBR,eAAe,CAACK,IAAD,CAAlC,EAA0CO,KAA1C,CAAN;AACD;;AAED,aAAON,OAAO,CAAC,CAAD,CAAd;AACD,KAZD;AAaD;;AAED,WAASO,cAAT,CAAwBV,QAAxB,EAAqD;AACnD,WAAO,SAASW,SAAT,CACLT,IADK,EAELlB,YAFK,EAGLC,cAA8B,GAAG,EAH5B,EAIL;AACA,YAAM2B,wBAAwB,GAAG7B,mCAAmC,CAClEC,YADkE,CAApE;AAGA,aAAO,sBAAQ,MAAMe,aAAa,CAACC,QAAD,CAAb,CAAwBE,IAAxB,EAA8BlB,YAA9B,CAAd,EAA2D,EAChE,GAAG4B,wBAD6D;AAEhE,WAAG3B;AAF6D,OAA3D,CAAP;AAID,KAZD;AAaD;;AAED,WAAS4B,WAAT,CAAqBb,QAArB,EAAkD;AAChD,WAAO,SAASc,MAAT,CACLZ,IADK,EAELlB,YAFK,EAGLC,cAA8B,GAAG,EAH5B,EAIL;AACA,YAAM2B,wBAAwB,GAAG7B,mCAAmC,CAClEC,YADkE,CAApE;AAGA,aAAO,sBAAQ,MAAMwB,UAAU,CAACR,QAAD,CAAV,CAAqBE,IAArB,EAA2BlB,YAA3B,CAAd,EAAwD,EAC7D,GAAG4B,wBAD0D;AAE7D,WAAG3B;AAF0D,OAAxD,CAAP;AAID,KAZD;AAaD;;AAED,SAAO;AACL8B,IAAAA,KAAK,EAAEP,UADF;AAELQ,IAAAA,QAAQ,EAAEjB,aAFL;AAGLkB,IAAAA,OAAO,EAAEX,YAHJ;AAILY,IAAAA,MAAM,EAAEL,WAJH;AAKLM,IAAAA,SAAS,EAAET;AALN,GAAP;AAOD","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport waitFor from '../waitFor';\nimport type { WaitForOptions } from '../waitFor';\nimport { ErrorWithStack } from './errors';\nimport type { TextMatchOptions } from './byText';\n\ntype QueryFunction<ArgType, ReturnType> = (\n instance: ReactTestInstance\n) => (args: ArgType, queryOptions?: TextMatchOptions) => ReturnType;\n\ntype FindQueryFunction<ArgType, ReturnType> = (\n instance: ReactTestInstance\n) => (\n args: ArgType,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions?: WaitForOptions\n) => Promise<ReturnType>;\n\ntype QueryAllByQuery<QueryArg> = QueryFunction<\n QueryArg,\n Array<ReactTestInstance>\n>;\ntype QueryByQuery<QueryArg> = QueryFunction<QueryArg, null | ReactTestInstance>;\n\ntype GetAllByQuery<QueryArg> = QueryFunction<\n QueryArg,\n Array<ReactTestInstance>\n>;\ntype GetByQuery<QueryArg> = QueryFunction<QueryArg, ReactTestInstance>;\n\ntype FindAllByQuery<QueryArg> = FindQueryFunction<\n QueryArg,\n Array<ReactTestInstance>\n>;\ntype FindByQuery<QueryArg> = FindQueryFunction<QueryArg, ReactTestInstance>;\n\nexport type Queries<QueryArg> = {\n getBy: GetByQuery<QueryArg>;\n getAllBy: GetAllByQuery<QueryArg>;\n queryBy: QueryByQuery<QueryArg>;\n findBy: FindByQuery<QueryArg>;\n findAllBy: FindAllByQuery<QueryArg>;\n};\n\n// The WaitForOptions has been moved to the second option param of findBy* methods with the adding of TextMatchOptions\n// To make the migration easier and avoid a breaking change, keep reading this options from the first param but warn\nconst deprecatedKeys: (keyof WaitForOptions)[] = [\n 'timeout',\n 'interval',\n 'stackTraceError',\n];\nconst extractDeprecatedWaitForOptionUsage = (queryOptions?: WaitForOptions) => {\n if (queryOptions) {\n const waitForOptions: WaitForOptions = {\n timeout: queryOptions.timeout,\n interval: queryOptions.interval,\n stackTraceError: queryOptions.stackTraceError,\n };\n deprecatedKeys.forEach((key) => {\n const option = queryOptions[key];\n if (option) {\n // eslint-disable-next-line no-console\n console.warn(\n `Use of option \"${key}\" in a findBy* query's second parameter, TextMatchOptions, is deprecated. Please pass this option in the third, WaitForOptions, parameter. \nExample: \n\n findByText(text, {}, { ${key}: ${option.toString()} })`\n );\n }\n });\n return waitForOptions;\n }\n};\n\nexport function makeQueries<QueryArg>(\n queryAllByQuery: QueryAllByQuery<QueryArg>,\n getMissingError: (args: QueryArg) => string,\n getMultipleError: (args: QueryArg) => string\n): Queries<QueryArg> {\n function getAllByQuery(instance: ReactTestInstance) {\n return function getAllFn(args: QueryArg, queryOptions?: TextMatchOptions) {\n const results = queryAllByQuery(instance)(args, queryOptions);\n\n if (results.length === 0) {\n throw new ErrorWithStack(getMissingError(args), getAllFn);\n }\n\n return results;\n };\n }\n\n function queryByQuery(instance: ReactTestInstance) {\n return function singleQueryFn(\n args: QueryArg,\n queryOptions?: TextMatchOptions\n ) {\n const results = queryAllByQuery(instance)(args, queryOptions);\n\n if (results.length > 1) {\n throw new ErrorWithStack(getMultipleError(args), singleQueryFn);\n }\n\n if (results.length === 0) {\n return null;\n }\n\n return results[0];\n };\n }\n\n function getByQuery(instance: ReactTestInstance) {\n return function getFn(args: QueryArg, queryOptions?: TextMatchOptions) {\n const results = queryAllByQuery(instance)(args, queryOptions);\n\n if (results.length > 1) {\n throw new ErrorWithStack(getMultipleError(args), getFn);\n }\n\n if (results.length === 0) {\n throw new ErrorWithStack(getMissingError(args), getFn);\n }\n\n return results[0];\n };\n }\n\n function findAllByQuery(instance: ReactTestInstance) {\n return function findAllFn(\n args: QueryArg,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions: WaitForOptions = {}\n ) {\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage(\n queryOptions\n );\n return waitFor(() => getAllByQuery(instance)(args, queryOptions), {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n });\n };\n }\n\n function findByQuery(instance: ReactTestInstance) {\n return function findFn(\n args: QueryArg,\n queryOptions?: TextMatchOptions & WaitForOptions,\n waitForOptions: WaitForOptions = {}\n ) {\n const deprecatedWaitForOptions = extractDeprecatedWaitForOptionUsage(\n queryOptions\n );\n return waitFor(() => getByQuery(instance)(args, queryOptions), {\n ...deprecatedWaitForOptions,\n ...waitForOptions,\n });\n };\n }\n\n return {\n getBy: getByQuery,\n getAllBy: getAllByQuery,\n queryBy: queryByQuery,\n findBy: findByQuery,\n findAllBy: findAllByQuery,\n };\n}\n"],"file":"makeQueries.js"}
@@ -1,39 +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 QueryByAPI = {
6
- queryByText: (name: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance | null;
7
- queryAllByText: (text: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
8
- queryByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance | null;
9
- queryAllByPlaceholderText: (placeholder: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
10
- queryByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions) => ReactTestInstance | null;
11
- queryAllByDisplayValue: (value: TextMatch, queryOptions?: TextMatchOptions) => Array<ReactTestInstance>;
12
- queryByTestId: (testID: TextMatch) => ReactTestInstance | null;
13
- queryAllByTestId: (testID: TextMatch) => Array<ReactTestInstance>;
14
- UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
15
- UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
16
- UNSAFE_queryByProps: (props: {
17
- [key: string]: any;
18
- }) => ReactTestInstance | null;
19
- UNSAFE_queryAllByProps: (props: {
20
- [key: string]: any;
21
- }) => Array<ReactTestInstance>;
22
- queryByName: () => void;
23
- queryByType: () => void;
24
- queryByProps: () => void;
25
- queryAllByName: () => void;
26
- queryAllByType: () => void;
27
- queryAllByProps: () => void;
28
- queryByPlaceholder: () => void;
29
- queryAllByPlaceholder: () => void;
30
- };
31
- export declare const UNSAFE_queryByType: (instance: ReactTestInstance) => (type: React.ComponentType<any>) => ReactTestInstance | null;
32
- export declare const UNSAFE_queryByProps: (instance: ReactTestInstance) => (props: {
33
- [propName: string]: any;
34
- }) => ReactTestInstance | null;
35
- export declare const UNSAFE_queryAllByType: (instance: ReactTestInstance) => (type: React.ComponentType<any>) => Array<ReactTestInstance>;
36
- export declare const UNSAFE_queryAllByProps: (instance: ReactTestInstance) => (props: {
37
- [propName: string]: any;
38
- }) => Array<ReactTestInstance>;
39
- export declare const queryByAPI: (instance: ReactTestInstance) => QueryByAPI;