@testing-library/react-native 11.1.0 → 11.3.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 (47) hide show
  1. package/build/act.d.ts +8 -3
  2. package/build/act.js +73 -2
  3. package/build/act.js.map +1 -1
  4. package/build/config.d.ts +10 -0
  5. package/build/config.js +28 -0
  6. package/build/config.js.map +1 -0
  7. package/build/fireEvent.js +7 -11
  8. package/build/fireEvent.js.map +1 -1
  9. package/build/helpers/accessiblity.d.ts +2 -0
  10. package/build/helpers/accessiblity.js +60 -0
  11. package/build/helpers/accessiblity.js.map +1 -0
  12. package/build/helpers/component-tree.d.ts +44 -0
  13. package/build/helpers/component-tree.js +145 -0
  14. package/build/helpers/component-tree.js.map +1 -0
  15. package/build/helpers/stringValidation.d.ts +2 -0
  16. package/build/helpers/stringValidation.js +38 -0
  17. package/build/helpers/stringValidation.js.map +1 -0
  18. package/build/helpers/timers.js +1 -1
  19. package/build/helpers/timers.js.map +1 -1
  20. package/build/index.flow.js +28 -4
  21. package/build/index.js +27 -11
  22. package/build/index.js.map +1 -1
  23. package/build/pure.d.ts +4 -0
  24. package/build/pure.js +22 -0
  25. package/build/pure.js.map +1 -1
  26. package/build/queries/a11yState.d.ts +1 -1
  27. package/build/queries/a11yState.js.map +1 -1
  28. package/build/queries/displayValue.js +7 -15
  29. package/build/queries/displayValue.js.map +1 -1
  30. package/build/queries/placeholderText.js +6 -14
  31. package/build/queries/placeholderText.js.map +1 -1
  32. package/build/queries/role.d.ts +10 -6
  33. package/build/queries/role.js +13 -2
  34. package/build/queries/role.js.map +1 -1
  35. package/build/queries/text.js +28 -28
  36. package/build/queries/text.js.map +1 -1
  37. package/build/react-versions.d.ts +1 -0
  38. package/build/react-versions.js +19 -0
  39. package/build/react-versions.js.map +1 -0
  40. package/build/render.d.ts +20 -7
  41. package/build/render.js +37 -1
  42. package/build/render.js.map +1 -1
  43. package/build/waitFor.js +16 -12
  44. package/build/waitFor.js.map +1 -1
  45. package/build/within.d.ts +18 -6
  46. package/package.json +12 -11
  47. package/typings/index.flow.js +28 -4
@@ -202,6 +202,11 @@ interface UnsafeByPropsQueries {
202
202
  | Array<ReactTestInstance>
203
203
  | [];
204
204
  }
205
+
206
+ interface ByRoleOptions {
207
+ name?: string;
208
+ }
209
+
205
210
  interface A11yAPI {
206
211
  // Label
207
212
  getByLabelText: (matcher: TextMatch) => GetReturn;
@@ -244,16 +249,27 @@ interface A11yAPI {
244
249
  ) => FindAllReturn;
245
250
 
246
251
  // Role
247
- getByRole: (matcher: A11yRole | RegExp) => GetReturn;
248
- getAllByRole: (matcher: A11yRole | RegExp) => GetAllReturn;
249
- queryByRole: (matcher: A11yRole | RegExp) => QueryReturn;
250
- queryAllByRole: (matcher: A11yRole | RegExp) => QueryAllReturn;
252
+ getByRole: (matcher: A11yRole | RegExp, role?: ByRoleOptions) => GetReturn;
253
+ getAllByRole: (
254
+ matcher: A11yRole | RegExp,
255
+ role?: ByRoleOptions
256
+ ) => GetAllReturn;
257
+ queryByRole: (
258
+ matcher: A11yRole | RegExp,
259
+ role?: ByRoleOptions
260
+ ) => QueryReturn;
261
+ queryAllByRole: (
262
+ matcher: A11yRole | RegExp,
263
+ role?: ByRoleOptions
264
+ ) => QueryAllReturn;
251
265
  findByRole: (
252
266
  matcher: A11yRole | RegExp,
267
+ role?: ByRoleOptions,
253
268
  waitForOptions?: WaitForOptions
254
269
  ) => FindReturn;
255
270
  findAllByRole: (
256
271
  matcher: A11yRole | RegExp,
272
+ role?: ByRoleOptions,
257
273
  waitForOptions?: WaitForOptions
258
274
  ) => FindAllReturn;
259
275
 
@@ -330,6 +346,7 @@ declare module '@testing-library/react-native' {
330
346
  declare interface RenderOptions {
331
347
  wrapper?: React.ComponentType<any>;
332
348
  createNodeMock?: (element: React.Element<any>) => any;
349
+ unstable_validateStringsRenderedWithinText?: boolean;
333
350
  }
334
351
 
335
352
  declare export var render: (
@@ -351,6 +368,13 @@ declare module '@testing-library/react-native' {
351
368
 
352
369
  declare export var waitForElementToBeRemoved: WaitForElementToBeRemovedFunction;
353
370
 
371
+ declare interface Config {
372
+ asyncUtilTimeout: number;
373
+ }
374
+
375
+ declare export var configure: (options: $Shape<Config>) => void;
376
+ declare export var resetToDefaults: () => void;
377
+
354
378
  declare export var act: (callback: () => void) => Thenable;
355
379
  declare export var within: (instance: ReactTestInstance) => Queries;
356
380
  declare export var getQueriesForElement: (
package/build/index.js CHANGED
@@ -19,16 +19,32 @@ Object.keys(_pure).forEach(function (key) {
19
19
 
20
20
  var _flushMicroTasks = require("./flushMicroTasks");
21
21
 
22
- // If we're running in a test runner that supports afterEach
23
- // then we'll automatically run cleanup afterEach test
24
- // this ensures that tests run in isolation from each other
25
- // if you don't like this then either import the `pure` module
26
- // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.
27
- if (typeof afterEach === 'function' && !process.env.RNTL_SKIP_AUTO_CLEANUP) {
28
- // eslint-disable-next-line no-undef
29
- afterEach(async () => {
30
- await (0, _flushMicroTasks.flushMicroTasks)();
31
- (0, _pure.cleanup)();
32
- });
22
+ var _act = require("./act");
23
+
24
+ if (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {
25
+ // If we're running in a test runner that supports afterEach
26
+ // then we'll automatically run cleanup afterEach test
27
+ // this ensures that tests run in isolation from each other
28
+ // if you don't like this then either import the `pure` module
29
+ // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.
30
+ if (typeof afterEach === 'function') {
31
+ // eslint-disable-next-line no-undef
32
+ afterEach(async () => {
33
+ await (0, _flushMicroTasks.flushMicroTasks)();
34
+ (0, _pure.cleanup)();
35
+ });
36
+ }
37
+
38
+ if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
39
+ // This matches the behavior of React < 18.
40
+ let previousIsReactActEnvironment = (0, _act.getIsReactActEnvironment)();
41
+ beforeAll(() => {
42
+ previousIsReactActEnvironment = (0, _act.getIsReactActEnvironment)();
43
+ (0, _act.setReactActEnvironment)(true);
44
+ });
45
+ afterAll(() => {
46
+ (0, _act.setReactActEnvironment)(previousIsReactActEnvironment);
47
+ });
48
+ }
33
49
  }
34
50
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["afterEach","process","env","RNTL_SKIP_AUTO_CLEANUP","flushMicroTasks","cleanup"],"sources":["../src/index.ts"],"sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasks } from './flushMicroTasks';\n\n// If we're running in a test runner that supports afterEach\n// then we'll automatically run cleanup afterEach test\n// this ensures that tests run in isolation from each other\n// if you don't like this then either import the `pure` module\n// or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\nif (typeof afterEach === 'function' && !process.env.RNTL_SKIP_AUTO_CLEANUP) {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasks();\n cleanup();\n });\n}\n\nexport * from './pure';\n"],"mappings":";;;;;;AAAA;;AAgBA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AAfA;;AAEA;AACA;AACA;AACA;AACA;AACA,IAAI,OAAOA,SAAP,KAAqB,UAArB,IAAmC,CAACC,OAAO,CAACC,GAAR,CAAYC,sBAApD,EAA4E;EAC1E;EACAH,SAAS,CAAC,YAAY;IACpB,MAAM,IAAAI,gCAAA,GAAN;IACA,IAAAC,aAAA;EACD,CAHQ,CAAT;AAID"}
1
+ {"version":3,"file":"index.js","names":["process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","flushMicroTasks","cleanup","beforeAll","afterAll","previousIsReactActEnvironment","getIsReactActEnvironment","setReactActEnvironment"],"sources":["../src/index.ts"],"sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasks } from './flushMicroTasks';\nimport { getIsReactActEnvironment, setReactActEnvironment } from './act';\n\nif (typeof process === 'undefined' || !process.env?.RNTL_SKIP_AUTO_CLEANUP) {\n // If we're running in a test runner that supports afterEach\n // then we'll automatically run cleanup afterEach test\n // this ensures that tests run in isolation from each other\n // if you don't like this then either import the `pure` module\n // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\n if (typeof afterEach === 'function') {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasks();\n cleanup();\n });\n }\n\n if (typeof beforeAll === 'function' && typeof afterAll === 'function') {\n // This matches the behavior of React < 18.\n let previousIsReactActEnvironment = getIsReactActEnvironment();\n beforeAll(() => {\n previousIsReactActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(true);\n });\n\n afterAll(() => {\n setReactActEnvironment(previousIsReactActEnvironment);\n });\n }\n}\n\nexport * from './pure';\n"],"mappings":";;;;;;AAAA;;AAgCA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AA/BA;;AACA;;AAEA,IAAI,OAAOA,OAAP,KAAmB,WAAnB,IAAkC,CAACA,OAAO,CAACC,GAAR,EAAaC,sBAApD,EAA4E;EAC1E;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,SAAP,KAAqB,UAAzB,EAAqC;IACnC;IACAA,SAAS,CAAC,YAAY;MACpB,MAAM,IAAAC,gCAAA,GAAN;MACA,IAAAC,aAAA;IACD,CAHQ,CAAT;EAID;;EAED,IAAI,OAAOC,SAAP,KAAqB,UAArB,IAAmC,OAAOC,QAAP,KAAoB,UAA3D,EAAuE;IACrE;IACA,IAAIC,6BAA6B,GAAG,IAAAC,6BAAA,GAApC;IACAH,SAAS,CAAC,MAAM;MACdE,6BAA6B,GAAG,IAAAC,6BAAA,GAAhC;MACA,IAAAC,2BAAA,EAAuB,IAAvB;IACD,CAHQ,CAAT;IAKAH,QAAQ,CAAC,MAAM;MACb,IAAAG,2BAAA,EAAuBF,6BAAvB;IACD,CAFO,CAAR;EAGD;AACF"}
package/build/pure.d.ts CHANGED
@@ -8,10 +8,13 @@ import { within, getQueriesForElement } from './within';
8
8
  import { getDefaultNormalizer } from './matches';
9
9
  import { renderHook } from './renderHook';
10
10
  import { screen } from './screen';
11
+ import { isInaccessible } from './helpers/accessiblity';
11
12
  export type { RenderOptions, RenderResult, RenderResult as RenderAPI, } from './render';
12
13
  export type { RenderHookOptions, RenderHookResult } from './renderHook';
14
+ export type { Config } from './config';
13
15
  export { act };
14
16
  export { cleanup };
17
+ export { configure, resetToDefaults } from './config';
15
18
  export { fireEvent };
16
19
  export { render };
17
20
  export { waitFor };
@@ -20,3 +23,4 @@ export { within, getQueriesForElement };
20
23
  export { getDefaultNormalizer };
21
24
  export { renderHook };
22
25
  export { screen };
26
+ export { isInaccessible };
package/build/pure.js CHANGED
@@ -15,6 +15,12 @@ Object.defineProperty(exports, "cleanup", {
15
15
  return _cleanup.default;
16
16
  }
17
17
  });
18
+ Object.defineProperty(exports, "configure", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _config.configure;
22
+ }
23
+ });
18
24
  Object.defineProperty(exports, "fireEvent", {
19
25
  enumerable: true,
20
26
  get: function () {
@@ -33,6 +39,12 @@ Object.defineProperty(exports, "getQueriesForElement", {
33
39
  return _within.getQueriesForElement;
34
40
  }
35
41
  });
42
+ Object.defineProperty(exports, "isInaccessible", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _accessiblity.isInaccessible;
46
+ }
47
+ });
36
48
  Object.defineProperty(exports, "render", {
37
49
  enumerable: true,
38
50
  get: function () {
@@ -45,6 +57,12 @@ Object.defineProperty(exports, "renderHook", {
45
57
  return _renderHook.renderHook;
46
58
  }
47
59
  });
60
+ Object.defineProperty(exports, "resetToDefaults", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _config.resetToDefaults;
64
+ }
65
+ });
48
66
  Object.defineProperty(exports, "screen", {
49
67
  enumerable: true,
50
68
  get: function () {
@@ -90,5 +108,9 @@ var _renderHook = require("./renderHook");
90
108
 
91
109
  var _screen = require("./screen");
92
110
 
111
+ var _accessiblity = require("./helpers/accessiblity");
112
+
113
+ var _config = require("./config");
114
+
93
115
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
94
116
  //# sourceMappingURL=pure.js.map
package/build/pure.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"sourcesContent":["import act from './act';\nimport cleanup from './cleanup';\nimport fireEvent from './fireEvent';\nimport render from './render';\nimport waitFor from './waitFor';\nimport waitForElementToBeRemoved from './waitForElementToBeRemoved';\nimport { within, getQueriesForElement } from './within';\nimport { getDefaultNormalizer } from './matches';\nimport { renderHook } from './renderHook';\nimport { screen } from './screen';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\n\nexport { act };\nexport { cleanup };\nexport { fireEvent };\nexport { render };\nexport { waitFor };\nexport { waitForElementToBeRemoved };\nexport { within, getQueriesForElement };\nexport { getDefaultNormalizer };\nexport { renderHook };\nexport { screen };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA"}
1
+ {"version":3,"file":"pure.js","names":[],"sources":["../src/pure.ts"],"sourcesContent":["import act from './act';\nimport cleanup from './cleanup';\nimport fireEvent from './fireEvent';\nimport render from './render';\nimport waitFor from './waitFor';\nimport waitForElementToBeRemoved from './waitForElementToBeRemoved';\nimport { within, getQueriesForElement } from './within';\nimport { getDefaultNormalizer } from './matches';\nimport { renderHook } from './renderHook';\nimport { screen } from './screen';\nimport { isInaccessible } from './helpers/accessiblity';\n\nexport type {\n RenderOptions,\n RenderResult,\n RenderResult as RenderAPI,\n} from './render';\nexport type { RenderHookOptions, RenderHookResult } from './renderHook';\nexport type { Config } from './config';\n\nexport { act };\nexport { cleanup };\nexport { configure, resetToDefaults } from './config';\nexport { fireEvent };\nexport { render };\nexport { waitFor };\nexport { waitForElementToBeRemoved };\nexport { within, getQueriesForElement };\nexport { getDefaultNormalizer };\nexport { renderHook };\nexport { screen };\nexport { isInaccessible };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAYA"}
@@ -1,5 +1,5 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { AccessibilityState } from 'react-native';
2
+ import type { AccessibilityState } from 'react-native';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
4
  export declare type ByA11yStateQueries = {
5
5
  getByA11yState: GetByQuery<AccessibilityState>;
@@ -1 +1 @@
1
- {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","state","findAll","node","type","matchObjectProp","props","accessibilityState","getMultipleError","JSON","stringify","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { matchObjectProp } from '../helpers/matchers/matchObjectProp';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((state: AccessibilityState) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(state) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchObjectProp(node.props.accessibilityState, state)\n );\n };\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with accessibilityState: ${JSON.stringify(state)}`;\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with accessibilityState: ${JSON.stringify(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState>;\n getAllByA11yState: GetAllByQuery<AccessibilityState>;\n queryByA11yState: QueryByQuery<AccessibilityState>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState>;\n findByA11yState: FindByQuery<AccessibilityState>;\n findAllByA11yState: FindAllByQuery<AccessibilityState>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState>;\n getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;\n queryByAccessibilityState: QueryByQuery<AccessibilityState>;\n queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;\n findByAccessibilityState: FindByQuery<AccessibilityState>;\n findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAUA,MAAMA,mBAAmB,GACvBC,QAD0B,IAG1B,SAASC,qBAAT,CAA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D,CAzBM"}
1
+ {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","state","findAll","node","type","matchObjectProp","props","accessibilityState","getMultipleError","JSON","stringify","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport type { AccessibilityState } from 'react-native';\nimport { matchObjectProp } from '../helpers/matchers/matchObjectProp';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): ((state: AccessibilityState) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(state) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchObjectProp(node.props.accessibilityState, state)\n );\n };\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with accessibilityState: ${JSON.stringify(state)}`;\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with accessibilityState: ${JSON.stringify(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState>;\n getAllByA11yState: GetAllByQuery<AccessibilityState>;\n queryByA11yState: QueryByQuery<AccessibilityState>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState>;\n findByA11yState: FindByQuery<AccessibilityState>;\n findAllByA11yState: FindAllByQuery<AccessibilityState>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState>;\n getAllByAccessibilityState: GetAllByQuery<AccessibilityState>;\n queryByAccessibilityState: QueryByQuery<AccessibilityState>;\n queryAllByAccessibilityState: QueryAllByQuery<AccessibilityState>;\n findByAccessibilityState: FindByQuery<AccessibilityState>;\n findAllByAccessibilityState: FindAllByQuery<AccessibilityState>;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;;AAEA;;AACA;;AAUA,MAAMA,mBAAmB,GACvBC,QAD0B,IAG1B,SAASC,qBAAT,CAA+BC,KAA/B,EAAsC;EACpC,OAAOF,QAAQ,CAACG,OAAT,CACJC,IAAD,IACE,OAAOA,IAAI,CAACC,IAAZ,KAAqB,QAArB,IACA,IAAAC,gCAAA,EAAgBF,IAAI,CAACG,KAAL,CAAWC,kBAA3B,EAA+CN,KAA/C,CAHG,CAAP;AAKD,CATH;;AAWA,MAAMO,gBAAgB,GAAIP,KAAD,IACtB,oDAAmDQ,IAAI,CAACC,SAAL,CAAeT,KAAf,CAAsB,EAD5E;;AAEA,MAAMU,eAAe,GAAIV,KAAD,IACrB,sDAAqDQ,IAAI,CAACC,SAAL,CAAeT,KAAf,CAAsB,EAD9E;;AAGA,MAAM;EAAEW,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEpB,mBADkE,EAElEa,eAFkE,EAGlEH,gBAHkE,CAApE;;AAsBO,MAAMW,sBAAsB,GACjCpB,QADoC,IAEb;EACvB,MAAMqB,cAAc,GAAGR,KAAK,CAACb,QAAD,CAA5B;EACA,MAAMsB,iBAAiB,GAAGR,QAAQ,CAACd,QAAD,CAAlC;EACA,MAAMuB,gBAAgB,GAAGR,OAAO,CAACf,QAAD,CAAhC;EACA,MAAMD,mBAAmB,GAAGiB,UAAU,CAAChB,QAAD,CAAtC;EACA,MAAMwB,eAAe,GAAGP,MAAM,CAACjB,QAAD,CAA9B;EACA,MAAMyB,kBAAkB,GAAGP,SAAS,CAAClB,QAAD,CAApC;EAEA,OAAO;IACLqB,cADK;IAELC,iBAFK;IAGLC,gBAHK;IAILxB,mBAJK;IAKLyB,eALK;IAMLC,kBANK;IAQLC,uBAAuB,EAAEL,cARpB;IASLM,0BAA0B,EAAEL,iBATvB;IAULM,yBAAyB,EAAEL,gBAVtB;IAWLM,4BAA4B,EAAE9B,mBAXzB;IAYL+B,wBAAwB,EAAEN,eAZrB;IAaLO,2BAA2B,EAAEN;EAbxB,CAAP;AAeD,CAzBM"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByDisplayValueQueries = void 0;
7
7
 
8
- var _errors = require("../helpers/errors");
8
+ var _reactNative = require("react-native");
9
9
 
10
10
  var _filterNodeByType = require("../helpers/filterNodeByType");
11
11
 
@@ -14,20 +14,12 @@ var _matches = require("../matches");
14
14
  var _makeQueries = require("./makeQueries");
15
15
 
16
16
  const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
17
- try {
18
- const {
19
- TextInput
20
- } = require('react-native');
21
-
22
- const {
23
- exact,
24
- normalizer
25
- } = options;
26
- const nodeValue = node.props.value !== undefined ? node.props.value : node.props.defaultValue;
27
- return (0, _filterNodeByType.filterNodeByType)(node, TextInput) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
28
- } catch (error) {
29
- throw (0, _errors.createLibraryNotSupportedError)(error);
30
- }
17
+ const {
18
+ exact,
19
+ normalizer
20
+ } = options;
21
+ const nodeValue = node.props.value !== undefined ? node.props.value : node.props.defaultValue;
22
+ return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
31
23
  };
32
24
 
33
25
  const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
@@ -1 +1 @@
1
- {"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","TextInput","require","exact","normalizer","nodeValue","props","undefined","defaultValue","filterNodeByType","matches","error","createLibraryNotSupportedError","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue"],"sources":["../../src/queries/displayValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { createLibraryNotSupportedError } from '../helpers/errors';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { TextMatchOptions } from './text';\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByDisplayValueQueries = {\n getByDisplayValue: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByDisplayValue: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByDisplayValueQueries = (\n instance: ReactTestInstance\n): ByDisplayValueQueries => ({\n getByDisplayValue: getBy(instance),\n getAllByDisplayValue: getAllBy(instance),\n queryByDisplayValue: queryBy(instance),\n queryAllByDisplayValue: queryAllBy(instance),\n findByDisplayValue: findBy(instance),\n findAllByDisplayValue: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAWA,MAAMA,8BAA8B,GAAG,CACrCC,IADqC,EAErCC,KAFqC,EAGrCC,OAAyB,GAAG,EAHS,KAIlC;EACH,IAAI;IACF,MAAM;MAAEC;IAAF,IAAgBC,OAAO,CAAC,cAAD,CAA7B;;IACA,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAwBJ,OAA9B;IACA,MAAMK,SAAS,GACbP,IAAI,CAACQ,KAAL,CAAWP,KAAX,KAAqBQ,SAArB,GACIT,IA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":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","filterNodeByType","TextInput","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue"],"sources":["../../src/queries/displayValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { TextMatchOptions } from './text';\n\nconst getTextInputNodeByDisplayValue = (\n node: ReactTestInstance,\n value: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n const nodeValue =\n node.props.value !== undefined ? node.props.value : node.props.defaultValue;\n return (\n filterNodeByType(node, TextInput) &&\n matches(value, nodeValue, normalizer, exact)\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByDisplayValueQueries = {\n getByDisplayValue: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByDisplayValue: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByDisplayValueQueries = (\n instance: ReactTestInstance\n): ByDisplayValueQueries => ({\n getByDisplayValue: getBy(instance),\n getAllByDisplayValue: getAllBy(instance),\n queryByDisplayValue: queryBy(instance),\n queryAllByDisplayValue: queryAllBy(instance),\n findByDisplayValue: findBy(instance),\n findAllByDisplayValue: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAWA,MAAMA,8BAA8B,GAAG,CACrCC,IADqC,EAErCC,KAFqC,EAGrCC,OAAyB,GAAG,EAHS,KAIlC;EACH,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAwBF,OAA9B;EACA,MAAMG,SAAS,GACbL,IAAI,CAACM,KAAL,CAAWL,KAAX,KAAqBM,SAArB,GAAiCP,IAAI,CAACM,KAAL,CAAWL,KAA5C,GAAoDD,IAAI,CAACM,KAAL,CAAWE,YADjE;EAEA,OACE,IAAAC,kCAAA,EAAiBT,IAAjB,EAAuBU,sBAAvB,KACA,IAAAC,gBAAA,EAAQV,KAAR,EAAeI,SAAf,EAA0BD,UAA1B,EAAsCD,KAAtC,CAFF;AAID,CAZD;;AAcA,MAAMS,sBAAsB,GAC1BC,QAD6B,IAM7B,SAASC,wBAAT,CAAkCC,YAAlC,EAAgDC,YAAhD,EAA8D;EAC5D,OAAOH,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;EAAEM,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEf,sBADkE,EAElEQ,eAFkE,EAGlEF,gBAHkE,CAApE;;AAeO,MAAMU,yBAAyB,GACpCf,QADuC,KAEZ;EAC3BgB,iBAAiB,EAAER,KAAK,CAACR,QAAD,CADG;EAE3BiB,oBAAoB,EAAER,QAAQ,CAACT,QAAD,CAFH;EAG3BkB,mBAAmB,EAAER,OAAO,CAACV,QAAD,CAHD;EAI3BD,sBAAsB,EAAEY,UAAU,CAACX,QAAD,CAJP;EAK3BmB,kBAAkB,EAAEP,MAAM,CAACZ,QAAD,CALC;EAM3BoB,qBAAqB,EAAEP,SAAS,CAACb,QAAD;AANL,CAFY,CAAlC"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByPlaceholderTextQueries = void 0;
7
7
 
8
- var _errors = require("../helpers/errors");
8
+ var _reactNative = require("react-native");
9
9
 
10
10
  var _filterNodeByType = require("../helpers/filterNodeByType");
11
11
 
@@ -14,19 +14,11 @@ var _matches = require("../matches");
14
14
  var _makeQueries = require("./makeQueries");
15
15
 
16
16
  const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
17
- try {
18
- const {
19
- TextInput
20
- } = require('react-native');
21
-
22
- const {
23
- exact,
24
- normalizer
25
- } = options;
26
- return (0, _filterNodeByType.filterNodeByType)(node, TextInput) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
27
- } catch (error) {
28
- throw (0, _errors.createLibraryNotSupportedError)(error);
29
- }
17
+ const {
18
+ exact,
19
+ normalizer
20
+ } = options;
21
+ return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
30
22
  };
31
23
 
32
24
  const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
@@ -1 +1 @@
1
- {"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","TextInput","require","exact","normalizer","filterNodeByType","matches","props","error","createLibraryNotSupportedError","queryAllByPlaceholderText","instance","queryAllByPlaceholderFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByPlaceholderTextQueries","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText"],"sources":["../../src/queries/placeholderText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { createLibraryNotSupportedError } from '../helpers/errors';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { TextMatchOptions } from './text';\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByPlaceholderTextQueries = {\n getByPlaceholderText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByPlaceholderText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByPlaceholderTextQueries = (\n instance: ReactTestInstance\n): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(instance),\n getAllByPlaceholderText: getAllBy(instance),\n queryByPlaceholderText: queryBy(instance),\n queryAllByPlaceholderText: queryAllBy(instance),\n findByPlaceholderText: findBy(instance),\n findAllByPlaceholderText: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAWA,MAAMA,iCAAiC,GAAG,CACxCC,IADwC,EAExCC,WAFwC,EAGxCC,OAAyB,GAAG,EAHY,KAIrC;EACH,IAAI;IACF,MAAM;MAAEC;IAAF,IAAgBC,OAAO,CAAC,cAAD,CAA7B;;IACA,MAAM;MAAEC,KAAF;MAASC;IAAT,IAAwBJ,OAA9B;IACA,OACE,IAAAK,kCAAA,EAAiBP,IAAjB,EAAuBG,SAAvB,KACA,IAAAK,gBAAA,EAAQP,WAAR,EAAqBD,IAAI,CAACS,KAAL,CAAWR,WAAhC,EAA6CK,UAA7C,EAAyDD,KAAzD,CAFF;EAID,CAPD,CAOE,OAAOK,KAAP,EAAc;IACd,MAAM,IAAAC,sCAAA,EAA+BD,KAA/B,CAAN;EACD;AACF,CAfD;;AAiBA,MAAME,yBAAyB,GAC7BC,QADgC,IAMhC,SAASC,uBAAT,CAAiCb,WAAjC,EAA8Cc,YAA9C,EAA4D;EAC1D,OAAOF,QAAQ,CAACG,OAAT,CAAkBhB,IAAD,IACtBD,iCAAiC,CAACC,IAAD,EAAOC,WAAP,EAAoBc,YAApB,CAD5B,CAAP;AAGD,CAVH;;AAYA,MAAME,gBAAgB,GAAIhB,WAAD,IACtB,6CAA4CiB,MAAM,CAACjB,WAAD,CAAc,GADnE;;AAEA,MAAMkB,eAAe,GAAIlB,WAAD,IACrB,+CAA8CiB,MAAM,CAACjB,WAAD,CAAc,EADrE;;AAGA,MAAM;EAAEmB,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEd,yBADkE,EAElEO,eAFkE,EAGlEF,gBAHkE,CAApE;;AAeO,MAAMU,4BAA4B,GACvCd,QAD0C,KAEZ;EAC9Be,oBAAoB,EAAER,KAAK,CAACP,QAAD,CADG;EAE9BgB,uBAAuB,EAAER,QAAQ,CAACR,QAAD,CAFH;EAG9BiB,sBAAsB,EAAER,OAAO,CAACT,QAAD,CAHD;EAI9BD,yBAAyB,EAAEW,UAAU,CAACV,QAAD,CAJP;EAK9BkB,qBAAqB,EAAEP,MAAM,CAACX,QAAD,CALC;EAM9BmB,wBAAwB,EAAEP,SAAS,CAACZ,QAAD;AANL,CAFY,CAArC"}
1
+ {"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","filterNodeByType","TextInput","matches","props","queryAllByPlaceholderText","instance","queryAllByPlaceholderFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByPlaceholderTextQueries","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText"],"sources":["../../src/queries/placeholderText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { TextMatchOptions } from './text';\n\nconst getTextInputNodeByPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return (\n filterNodeByType(node, TextInput) &&\n matches(placeholder, node.props.placeholder, normalizer, exact)\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByPlaceholderTextQueries = {\n getByPlaceholderText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByPlaceholderText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByPlaceholderTextQueries = (\n instance: ReactTestInstance\n): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(instance),\n getAllByPlaceholderText: getAllBy(instance),\n queryByPlaceholderText: queryBy(instance),\n queryAllByPlaceholderText: queryAllBy(instance),\n findByPlaceholderText: findBy(instance),\n findAllByPlaceholderText: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAWA,MAAMA,iCAAiC,GAAG,CACxCC,IADwC,EAExCC,WAFwC,EAGxCC,OAAyB,GAAG,EAHY,KAIrC;EACH,MAAM;IAAEC,KAAF;IAASC;EAAT,IAAwBF,OAA9B;EACA,OACE,IAAAG,kCAAA,EAAiBL,IAAjB,EAAuBM,sBAAvB,KACA,IAAAC,gBAAA,EAAQN,WAAR,EAAqBD,IAAI,CAACQ,KAAL,CAAWP,WAAhC,EAA6CG,UAA7C,EAAyDD,KAAzD,CAFF;AAID,CAVD;;AAYA,MAAMM,yBAAyB,GAC7BC,QADgC,IAMhC,SAASC,uBAAT,CAAiCV,WAAjC,EAA8CW,YAA9C,EAA4D;EAC1D,OAAOF,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;EAAEgB,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEd,yBADkE,EAElEO,eAFkE,EAGlEF,gBAHkE,CAApE;;AAeO,MAAMU,4BAA4B,GACvCd,QAD0C,KAEZ;EAC9Be,oBAAoB,EAAER,KAAK,CAACP,QAAD,CADG;EAE9BgB,uBAAuB,EAAER,QAAQ,CAACR,QAAD,CAFH;EAG9BiB,sBAAsB,EAAER,OAAO,CAACT,QAAD,CAHD;EAI9BD,yBAAyB,EAAEW,UAAU,CAACV,QAAD,CAJP;EAK9BkB,qBAAqB,EAAEP,MAAM,CAACX,QAAD,CALC;EAM9BmB,wBAAwB,EAAEP,SAAS,CAACZ,QAAD;AANL,CAFY,CAArC"}
@@ -1,12 +1,16 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
2
  import { TextMatch } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
+ declare type ByRoleOptions = {
5
+ name?: TextMatch;
6
+ };
4
7
  export declare type ByRoleQueries = {
5
- getByRole: GetByQuery<TextMatch>;
6
- getAllByRole: GetAllByQuery<TextMatch>;
7
- queryByRole: QueryByQuery<TextMatch>;
8
- queryAllByRole: QueryAllByQuery<TextMatch>;
9
- findByRole: FindByQuery<TextMatch>;
10
- findAllByRole: FindAllByQuery<TextMatch>;
8
+ getByRole: GetByQuery<TextMatch, ByRoleOptions>;
9
+ getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;
10
+ queryByRole: QueryByQuery<TextMatch, ByRoleOptions>;
11
+ queryAllByRole: QueryAllByQuery<TextMatch, ByRoleOptions>;
12
+ findByRole: FindByQuery<TextMatch, ByRoleOptions>;
13
+ findAllByRole: FindAllByQuery<TextMatch, ByRoleOptions>;
11
14
  };
12
15
  export declare const bindByRoleQueries: (instance: ReactTestInstance) => ByRoleQueries;
16
+ export {};
@@ -7,10 +7,21 @@ exports.bindByRoleQueries = void 0;
7
7
 
8
8
  var _matchStringProp = require("../helpers/matchers/matchStringProp");
9
9
 
10
+ var _within = require("../within");
11
+
10
12
  var _makeQueries = require("./makeQueries");
11
13
 
12
- const queryAllByRole = instance => function queryAllByRoleFn(role) {
13
- return instance.findAll(node => typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role));
14
+ const matchAccessibleNameIfNeeded = (node, name) => {
15
+ if (name == null) return true;
16
+ const {
17
+ queryAllByText,
18
+ queryAllByLabelText
19
+ } = (0, _within.getQueriesForElement)(node);
20
+ return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;
21
+ };
22
+
23
+ const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
24
+ return instance.findAll(node => typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleNameIfNeeded(node, options?.name));
14
25
  };
15
26
 
16
27
  const getMultipleError = role => `Found multiple elements with accessibilityRole: ${String(role)} `;
@@ -1 +1 @@
1
- {"version":3,"file":"role.js","names":["queryAllByRole","instance","queryAllByRoleFn","role","findAll","node","type","matchStringProp","props","accessibilityRole","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { TextMatch } from '../matches';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchStringProp(node.props.accessibilityRole, role)\n );\n };\n\nconst getMultipleError = (role: TextMatch) =>\n `Found multiple elements with accessibilityRole: ${String(role)} `;\nconst getMissingError = (role: TextMatch) =>\n `Unable to find an element with accessibilityRole: ${String(role)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<TextMatch>;\n getAllByRole: GetAllByQuery<TextMatch>;\n queryByRole: QueryByQuery<TextMatch>;\n queryAllByRole: QueryAllByQuery<TextMatch>;\n findByRole: FindByQuery<TextMatch>;\n findAllByRole: FindAllByQuery<TextMatch>;\n};\n\nexport const bindByRoleQueries = (\n instance: ReactTestInstance\n): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AAEA;;AACA;;AAUA,MAAMA,cAAc,GAClBC,QADqB,IAGrB,SAASC,gBAAT,CAA0BC,IAA1B,EAAgC;EAC9B,OAAOF,QAAQ,CAACG,OAAT,CACJC,IAAD,IACE,OAAOA,IAAI,CAACC,IAAZ,KAAqB,QAArB,IACA,IAAAC,gCAAA,EAAgBF,IAAI,CAACG,KAAL,CAAWC,iBAA3B,EAA8CN,IAA9C,CAHG,CAAP;AAKD,CATH;;AAWA,MAAMO,gBAAgB,GAAIP,IAAD,IACtB,mDAAkDQ,MAAM,CAACR,IAAD,CAAO,GADlE;;AAEA,MAAMS,eAAe,GAAIT,IAAD,IACrB,qDAAoDQ,MAAM,CAACR,IAAD,CAAO,EADpE;;AAGA,MAAM;EAAEU,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEnB,cADkE,EAElEY,eAFkE,EAGlEF,gBAHkE,CAApE;;AAeO,MAAMU,iBAAiB,GAC5BnB,QAD+B,KAEZ;EACnBoB,SAAS,EAAER,KAAK,CAACZ,QAAD,CADG;EAEnBqB,YAAY,EAAER,QAAQ,CAACb,QAAD,CAFH;EAGnBsB,WAAW,EAAER,OAAO,CAACd,QAAD,CAHD;EAInBD,cAAc,EAAEgB,UAAU,CAACf,QAAD,CAJP;EAKnBuB,UAAU,EAAEP,MAAM,CAAChB,QAAD,CALC;EAMnBwB,aAAa,EAAEP,SAAS,CAACjB,QAAD;AANL,CAFY,CAA1B"}
1
+ {"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","queryAllByRole","instance","queryAllByRoleFn","role","options","findAll","type","matchStringProp","props","accessibilityRole","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport { TextMatch } from '../matches';\nimport { getQueriesForElement } from '../within';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\ntype ByRoleOptions = {\n name?: TextMatch;\n};\n\nconst matchAccessibleNameIfNeeded = (\n node: ReactTestInstance,\n name?: TextMatch\n) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return (\n queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0\n );\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch, options?: ByRoleOptions) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role, options) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleNameIfNeeded(node, options?.name)\n );\n };\n\nconst getMultipleError = (role: TextMatch) =>\n `Found multiple elements with accessibilityRole: ${String(role)} `;\nconst getMissingError = (role: TextMatch) =>\n `Unable to find an element with accessibilityRole: ${String(role)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<TextMatch, ByRoleOptions>;\n getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;\n queryByRole: QueryByQuery<TextMatch, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<TextMatch, ByRoleOptions>;\n findByRole: FindByQuery<TextMatch, ByRoleOptions>;\n findAllByRole: FindAllByQuery<TextMatch, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (\n instance: ReactTestInstance\n): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AAEA;;AACA;;AAcA,MAAMA,2BAA2B,GAAG,CAClCC,IADkC,EAElCC,IAFkC,KAG/B;EACH,IAAIA,IAAI,IAAI,IAAZ,EAAkB,OAAO,IAAP;EAElB,MAAM;IAAEC,cAAF;IAAkBC;EAAlB,IAA0C,IAAAC,4BAAA,EAAqBJ,IAArB,CAAhD;EACA,OACEE,cAAc,CAACD,IAAD,CAAd,CAAqBI,MAArB,GAA8B,CAA9B,IAAmCF,mBAAmB,CAACF,IAAD,CAAnB,CAA0BI,MAA1B,GAAmC,CADxE;AAGD,CAVD;;AAYA,MAAMC,cAAc,GAClBC,QADqB,IAGrB,SAASC,gBAAT,CAA0BC,IAA1B,EAAgCC,OAAhC,EAAyC;EACvC,OAAOH,QAAQ,CAACI,OAAT,CACJX,IAAD,IACE,OAAOA,IAAI,CAACY,IAAZ,KAAqB,QAArB,IACA,IAAAC,gCAAA,EAAgBb,IAAI,CAACc,KAAL,CAAWC,iBAA3B,EAA8CN,IAA9C,CADA,IAEAV,2BAA2B,CAACC,IAAD,EAAOU,OAAO,EAAET,IAAhB,CAJxB,CAAP;AAMD,CAVH;;AAYA,MAAMe,gBAAgB,GAAIP,IAAD,IACtB,mDAAkDQ,MAAM,CAACR,IAAD,CAAO,GADlE;;AAEA,MAAMS,eAAe,GAAIT,IAAD,IACrB,qDAAoDQ,MAAM,CAACR,IAAD,CAAO,EADpE;;AAGA,MAAM;EAAEU,KAAF;EAASC,QAAT;EAAmBC,OAAnB;EAA4BC,UAA5B;EAAwCC,MAAxC;EAAgDC;AAAhD,IAA8D,IAAAC,wBAAA,EAClEnB,cADkE,EAElEY,eAFkE,EAGlEF,gBAHkE,CAApE;;AAeO,MAAMU,iBAAiB,GAC5BnB,QAD+B,KAEZ;EACnBoB,SAAS,EAAER,KAAK,CAACZ,QAAD,CADG;EAEnBqB,YAAY,EAAER,QAAQ,CAACb,QAAD,CAFH;EAGnBsB,WAAW,EAAER,OAAO,CAACd,QAAD,CAHD;EAInBD,cAAc,EAAEgB,UAAU,CAACf,QAAD,CAJP;EAKnBuB,UAAU,EAAEP,MAAM,CAAChB,QAAD,CALC;EAMnBwB,aAAa,EAAEP,SAAS,CAACjB,QAAD;AANL,CAFY,CAA1B"}
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByTextQueries = void 0;
7
7
 
8
- var React = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
9
 
10
- var _errors = require("../helpers/errors");
10
+ var React = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _filterNodeByType = require("../helpers/filterNodeByType");
13
13
 
14
+ var _componentTree = require("../helpers/component-tree");
15
+
14
16
  var _matches = require("../matches");
15
17
 
16
18
  var _makeQueries = require("./makeQueries");
@@ -19,7 +21,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
21
 
20
22
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
21
23
 
22
- const getChildrenAsText = (children, TextComponent) => {
24
+ const getChildrenAsText = children => {
23
25
  const textContent = [];
24
26
  React.Children.forEach(children, child => {
25
27
  if (typeof child === 'string') {
@@ -37,12 +39,12 @@ const getChildrenAsText = (children, TextComponent) => {
37
39
  // has no text. In such situations, react-test-renderer will traverse down
38
40
  // this tree in a separate call and run this query again. As a result, the
39
41
  // query will match the deepest text node that matches requested text.
40
- if ((0, _filterNodeByType.filterNodeByType)(child, TextComponent)) {
42
+ if ((0, _filterNodeByType.filterNodeByType)(child, _reactNative.Text)) {
41
43
  return;
42
44
  }
43
45
 
44
46
  if ((0, _filterNodeByType.filterNodeByType)(child, React.Fragment)) {
45
- textContent.push(...getChildrenAsText(child.props.children, TextComponent));
47
+ textContent.push(...getChildrenAsText(child.props.children));
46
48
  }
47
49
  }
48
50
  });
@@ -50,34 +52,32 @@ const getChildrenAsText = (children, TextComponent) => {
50
52
  };
51
53
 
52
54
  const getNodeByText = (node, text, options = {}) => {
53
- try {
54
- const {
55
- Text
56
- } = require('react-native');
57
-
58
- const isTextComponent = (0, _filterNodeByType.filterNodeByType)(node, Text);
59
-
60
- if (isTextComponent) {
61
- const textChildren = getChildrenAsText(node.props.children, Text);
62
-
63
- if (textChildren) {
64
- const textToTest = textChildren.join('');
65
- const {
66
- exact,
67
- normalizer
68
- } = options;
69
- return (0, _matches.matches)(text, textToTest, normalizer, exact);
70
- }
55
+ const isTextComponent = (0, _filterNodeByType.filterNodeByType)(node, _reactNative.Text);
56
+
57
+ if (isTextComponent) {
58
+ const textChildren = getChildrenAsText(node.props.children);
59
+
60
+ if (textChildren) {
61
+ const textToTest = textChildren.join('');
62
+ const {
63
+ exact,
64
+ normalizer
65
+ } = options;
66
+ return (0, _matches.matches)(text, textToTest, normalizer, exact);
71
67
  }
72
-
73
- return false;
74
- } catch (error) {
75
- throw (0, _errors.createLibraryNotSupportedError)(error);
76
68
  }
69
+
70
+ return false;
77
71
  };
78
72
 
79
73
  const queryAllByText = instance => function queryAllByTextFn(text, options) {
80
- const results = instance.findAll(node => getNodeByText(node, text, options));
74
+ const baseInstance = (0, _componentTree.isHostElementForType)(instance, _reactNative.Text) ? (0, _componentTree.getCompositeParentOfType)(instance, _reactNative.Text) : instance;
75
+
76
+ if (!baseInstance) {
77
+ return [];
78
+ }
79
+
80
+ const results = baseInstance.findAll(node => getNodeByText(node, text, options));
81
81
  return results;
82
82
  };
83
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["getChildrenAsText","children","TextComponent","textContent","React","Children","forEach","child","push","toString","props","filterNodeByType","Fragment","getNodeByText","node","text","options","Text","require","isTextComponent","textChildren","textToTest","join","exact","normalizer","matches","error","createLibraryNotSupportedError","queryAllByText","instance","queryAllByTextFn","results","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport * as React from 'react';\nimport { createLibraryNotSupportedError } from '../helpers/errors';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch } from '../matches';\nimport type { NormalizerFn } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\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 options?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, options) {\n const results = instance.findAll((node) =>\n getNodeByText(node, text, options)\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByText: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByTextQueries = (\n instance: ReactTestInstance\n): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;AAeA,MAAMA,iBAAiB,GAAG,CACxBC,QADwB,EAExBC,aAFwB,KAGrB;EACH,MAAMC,WAAqB,GAAG,EAA9B;EACAC,KAAK,CAACC,QAAN,CAAeC,OAAf,CAAuBL,QAAvB,EAAkCM,KAAD,IAAW;IAC1C,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;MAC7BJ,WAAW,CAACK,IAAZ,CAAiBD,KAAjB;MACA;IACD;;IAED,IAAI,OAAOA,KAAP,KAAiB,QAArB,EAA+B;MAC7BJ,WAAW,CAACK,IAAZ,CAAiBD,KAAK,CAACE,QAAN,EAAjB;MACA;IACD;;IAED,IAAIF,KAAK,EAAEG,KAAP,EAAcT,QAAlB,EAA4B;MAC1B;MACA;MACA;MACA;MACA,IAAI,IAAAU,kCAAA,EAAiBJ,KAAjB,EAAwBL,aAAxB,CAAJ,EAA4C;QAC1C;MACD;;MAED,IAAI,IAAAS,kCAAA,EAAiBJ,KAAjB,EAAwBH,KAAK,CAACQ,QAA9B,CAAJ,EAA6C;QAC3CT,WAAW,CAACK,IAAZ,CACE,GAAGR,iBAAiB,CAACO,KAAK,CAACG,KAAN,CAAYT,QAAb,EAAuBC,aAAvB,CADtB;MAGD;IACF;EACF,CA1BD;EA4BA,OAAOC,WAAP;AACD,CAlCD;;AAoCA,MAAMU,aAAa,GAAG,CACpBC,IADoB,EAEpBC,IAFoB,EAGpBC,OAAyB,GAAG,EAHR,KAIjB;EACH,IAAI;IACF,MAAM;MAAEC;IAAF,IAAWC,OAAO,CAAC,cAAD,CAAxB;;IACA,MAAMC,eAAe,GAAG,IAAAR,kCAAA,EAAiBG,IAAjB,EAAuB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H;EAGnBiB,WAAW,EAAER,OAAO,CAACT,QAAD,CAHD;EAInBD,cAAc,EAAEW,UAAU,CAACV,QAAD,CAJP;EAKnBkB,UAAU,EAAEP,MAAM,CAACX,QAAD,CALC;EAMnBmB,aAAa,EAAEP,SAAS,CAACZ,QAAD;AANL,CAFY,CAA1B"}
1
+ {"version":3,"file":"text.js","names":["getChildrenAsText","children","textContent","React","Children","forEach","child","push","toString","props","filterNodeByType","Text","Fragment","getNodeByText","node","text","options","isTextComponent","textChildren","textToTest","join","exact","normalizer","matches","queryAllByText","instance","queryAllByTextFn","baseInstance","isHostElementForType","getCompositeParentOfType","results","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { Text } from 'react-native';\nimport * as React from 'react';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport {\n isHostElementForType,\n getCompositeParentOfType,\n} from '../helpers/component-tree';\nimport { matches, TextMatch } from '../matches';\nimport type { NormalizerFn } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\n\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n\nconst getChildrenAsText = (children: React.ReactChild[]) => {\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, Text)) {\n return;\n }\n\n if (filterNodeByType(child, React.Fragment)) {\n textContent.push(...getChildrenAsText(child.props.children));\n }\n }\n });\n\n return textContent;\n};\n\nconst getNodeByText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const isTextComponent = filterNodeByType(node, Text);\n if (isTextComponent) {\n const textChildren = getChildrenAsText(node.props.children);\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};\n\nconst queryAllByText = (\n instance: ReactTestInstance\n): ((\n text: TextMatch,\n options?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, options) {\n const baseInstance = isHostElementForType(instance, Text)\n ? getCompositeParentOfType(instance, Text)\n : instance;\n\n if (!baseInstance) {\n return [];\n }\n\n const results = baseInstance.findAll((node) =>\n getNodeByText(node, text, options)\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByText: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByTextQueries = (\n instance: ReactTestInstance\n): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AAIA;;AAEA;;;;;;AAe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
+ export declare function checkReactVersionAtLeast(major: number, minor: number): boolean;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.checkReactVersionAtLeast = checkReactVersionAtLeast;
7
+
8
+ var React = _interopRequireWildcard(require("react"));
9
+
10
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
+
12
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+
14
+ function checkReactVersionAtLeast(major, minor) {
15
+ if (React.version === undefined) return false;
16
+ const [actualMajor, actualMinor] = React.version.split('.').map(Number);
17
+ return actualMajor > major || actualMajor === major && actualMinor >= minor;
18
+ }
19
+ //# sourceMappingURL=react-versions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-versions.js","names":["checkReactVersionAtLeast","major","minor","React","version","undefined","actualMajor","actualMinor","split","map","Number"],"sources":["../src/react-versions.ts"],"sourcesContent":["import * as React from 'react';\n\nexport function checkReactVersionAtLeast(\n major: number,\n minor: number\n): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAEO,SAASA,wBAAT,CACLC,KADK,EAELC,KAFK,EAGI;EACT,IAAIC,KAAK,CAACC,OAAN,KAAkBC,SAAtB,EAAiC,OAAO,KAAP;EACjC,MAAM,CAACC,WAAD,EAAcC,WAAd,IAA6BJ,KAAK,CAACC,OAAN,CAAcI,KAAd,CAAoB,GAApB,EAAyBC,GAAzB,CAA6BC,MAA7B,CAAnC;EAEA,OAAOJ,WAAW,GAAGL,KAAd,IAAwBK,WAAW,KAAKL,KAAhB,IAAyBM,WAAW,IAAIL,KAAvE;AACD"}