@testing-library/react-native 11.4.0 → 11.5.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 (69) hide show
  1. package/README.md +3 -3
  2. package/build/cleanup.d.ts +1 -1
  3. package/build/config.d.ts +10 -2
  4. package/build/config.js +12 -3
  5. package/build/config.js.map +1 -1
  6. package/build/flushMicroTasks.d.ts +1 -1
  7. package/build/helpers/accessiblity.d.ts +10 -4
  8. package/build/helpers/accessiblity.js +19 -9
  9. package/build/helpers/accessiblity.js.map +1 -1
  10. package/build/helpers/debugDeep.d.ts +1 -1
  11. package/build/helpers/findAll.d.ts +10 -0
  12. package/build/helpers/findAll.js +44 -0
  13. package/build/helpers/findAll.js.map +1 -0
  14. package/build/helpers/format.d.ts +2 -2
  15. package/build/helpers/getTextContent.d.ts +2 -0
  16. package/build/helpers/getTextContent.js +20 -0
  17. package/build/helpers/getTextContent.js.map +1 -0
  18. package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
  19. package/build/helpers/matchers/accessibilityValue.js +12 -0
  20. package/build/helpers/matchers/accessibilityValue.js.map +1 -0
  21. package/build/helpers/matchers/matchTextContent.d.ts +3 -0
  22. package/build/helpers/matchers/matchTextContent.js +22 -0
  23. package/build/helpers/matchers/matchTextContent.js.map +1 -0
  24. package/build/helpers/timers.js.map +1 -1
  25. package/build/index.flow.js +122 -54
  26. package/build/matches.d.ts +7 -3
  27. package/build/matches.js.map +1 -1
  28. package/build/pure.d.ts +12 -23
  29. package/build/pure.js +8 -2
  30. package/build/pure.js.map +1 -1
  31. package/build/queries/a11yState.d.ts +15 -14
  32. package/build/queries/a11yState.js +3 -2
  33. package/build/queries/a11yState.js.map +1 -1
  34. package/build/queries/a11yValue.d.ts +15 -20
  35. package/build/queries/a11yValue.js +16 -5
  36. package/build/queries/a11yValue.js.map +1 -1
  37. package/build/queries/displayValue.d.ts +11 -9
  38. package/build/queries/displayValue.js +2 -1
  39. package/build/queries/displayValue.js.map +1 -1
  40. package/build/queries/hintText.d.ts +23 -21
  41. package/build/queries/hintText.js +2 -1
  42. package/build/queries/hintText.js.map +1 -1
  43. package/build/queries/labelText.d.ts +11 -9
  44. package/build/queries/labelText.js +2 -1
  45. package/build/queries/labelText.js.map +1 -1
  46. package/build/queries/makeQueries.d.ts +8 -8
  47. package/build/queries/options.d.ts +11 -0
  48. package/build/queries/options.js +2 -0
  49. package/build/queries/options.js.map +1 -0
  50. package/build/queries/placeholderText.d.ts +11 -9
  51. package/build/queries/placeholderText.js +2 -1
  52. package/build/queries/placeholderText.js.map +1 -1
  53. package/build/queries/role.d.ts +7 -4
  54. package/build/queries/role.js +19 -10
  55. package/build/queries/role.js.map +1 -1
  56. package/build/queries/testId.d.ts +11 -9
  57. package/build/queries/testId.js +3 -2
  58. package/build/queries/testId.js.map +1 -1
  59. package/build/queries/text.d.ts +11 -13
  60. package/build/queries/text.js +6 -47
  61. package/build/queries/text.js.map +1 -1
  62. package/build/queries/unsafeProps.d.ts +1 -1
  63. package/build/queries/unsafeType.d.ts +1 -1
  64. package/build/render.d.ts +92 -146
  65. package/build/renderHook.d.ts +2 -2
  66. package/build/waitFor.d.ts +1 -1
  67. package/build/within.d.ts +90 -144
  68. package/package.json +8 -8
  69. package/typings/index.flow.js +122 -54
@@ -1 +1 @@
1
- {"version":3,"file":"a11yValue.js","names":["queryAllByA11yValue","instance","queryAllByA11yValueFn","value","findAll","node","type","matchObjectProp","props","accessibilityValue","getMultipleError","JSON","stringify","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yValueQueries","getByA11yValue","getAllByA11yValue","queryByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue"],"sources":["../../src/queries/a11yValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\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\ntype A11yValue = {\n min?: number;\n max?: number;\n now?: number;\n text?: string;\n};\n\nconst queryAllByA11yValue = (\n instance: ReactTestInstance\n): ((value: A11yValue) => Array<ReactTestInstance>) =>\n function queryAllByA11yValueFn(value) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n matchObjectProp(node.props.accessibilityValue, value)\n );\n };\n\nconst getMultipleError = (value: A11yValue) =>\n `Found multiple elements with accessibilityValue: ${JSON.stringify(value)} `;\nconst getMissingError = (value: A11yValue) =>\n `Unable to find an element with accessibilityValue: ${JSON.stringify(value)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yValueQueries = {\n getByA11yValue: GetByQuery<A11yValue>;\n getAllByA11yValue: GetAllByQuery<A11yValue>;\n queryByA11yValue: QueryByQuery<A11yValue>;\n queryAllByA11yValue: QueryAllByQuery<A11yValue>;\n findByA11yValue: FindByQuery<A11yValue>;\n findAllByA11yValue: FindAllByQuery<A11yValue>;\n\n getByAccessibilityValue: GetByQuery<A11yValue>;\n getAllByAccessibilityValue: GetAllByQuery<A11yValue>;\n queryByAccessibilityValue: QueryByQuery<A11yValue>;\n queryAllByAccessibilityValue: QueryAllByQuery<A11yValue>;\n findByAccessibilityValue: FindByQuery<A11yValue>;\n findAllByAccessibilityValue: FindAllByQuery<A11yValue>;\n};\n\nexport const bindByA11yValueQueries = (\n instance: ReactTestInstance\n): ByA11yValueQueries => {\n const getByA11yValue = getBy(instance);\n const getAllByA11yValue = getAllBy(instance);\n const queryByA11yValue = queryBy(instance);\n const queryAllByA11yValue = queryAllBy(instance);\n const findByA11yValue = findBy(instance);\n const findAllByA11yValue = findAllBy(instance);\n\n return {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AAiBA,MAAMA,mBAAmB,GACvBC,QAA2B,IAE3B,SAASC,qBAAqB,CAACC,KAAK,EAAE;EACpC,OAAOF,QAAQ,CAACG,OAAO,CACpBC,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAC7B,IAAAC,gCAAe,EAACF,IAAI,CAACG,KAAK,CAACC,kBAAkB,EAAEN,KAAK,CAAC,CACxD;AACH,CAAC;AAEH,MAAMO,gBAAgB,GAAIP,KAAgB,IACvC,oDAAmDQ,IAAI,CAACC,SAAS,CAACT,KAAK,CAAE,GAAE;AAC9E,MAAMU,eAAe,GAAIV,KAAgB,IACtC,sDAAqDQ,IAAI,CAACC,SAAS,CAACT,KAAK,CAAE,EAAC;AAE/E,MAAM;EAAEW,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EpB,mBAAmB,EACnBa,eAAe,EACfH,gBAAgB,CACjB;AAkBM,MAAMW,sBAAsB,GACjCpB,QAA2B,IACJ;EACvB,MAAMqB,cAAc,GAAGR,KAAK,CAACb,QAAQ,CAAC;EACtC,MAAMsB,iBAAiB,GAAGR,QAAQ,CAACd,QAAQ,CAAC;EAC5C,MAAMuB,gBAAgB,GAAGR,OAAO,CAACf,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGiB,UAAU,CAAChB,QAAQ,CAAC;EAChD,MAAMwB,eAAe,GAAGP,MAAM,CAACjB,QAAQ,CAAC;EACxC,MAAMyB,kBAAkB,GAAGP,SAAS,CAAClB,QAAQ,CAAC;EAE9C,OAAO;IACLqB,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChBxB,mBAAmB;IACnByB,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAE9B,mBAAmB;IACjD+B,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
1
+ {"version":3,"file":"a11yValue.js","names":["queryAllByA11yValue","instance","queryAllByA11yValueFn","value","queryOptions","findAll","node","type","matchAccessibilityValue","formatQueryParams","matcher","params","accessiblityValueKeys","forEach","valueKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yValueQueries","getByA11yValue","getAllByA11yValue","queryByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue"],"sources":["../../src/queries/a11yValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { accessiblityValueKeys } from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yValue = (\n instance: ReactTestInstance\n): ((\n value: AccessibilityValueMatcher,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yValueFn(value, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityValue(node, value),\n queryOptions\n );\n };\n\nconst formatQueryParams = (matcher: AccessibilityValueMatcher) => {\n const params: string[] = [];\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (matcher[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${matcher[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (matcher: AccessibilityValueMatcher) =>\n `Found multiple elements with ${formatQueryParams(matcher)}`;\n\nconst getMissingError = (matcher: AccessibilityValueMatcher) =>\n `Unable to find an element with ${formatQueryParams(matcher)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yValueQueries = {\n getByA11yValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n getAllByA11yValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByA11yValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n queryAllByA11yValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByA11yValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n findAllByA11yValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n\n getByAccessibilityValue: GetByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n getAllByAccessibilityValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByAccessibilityValue: QueryByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryAllByAccessibilityValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByAccessibilityValue: FindByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findAllByAccessibilityValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yValueQueries = (\n instance: ReactTestInstance\n): ByA11yValueQueries => {\n const getByA11yValue = getBy(instance);\n const getAllByA11yValue = getAllBy(instance);\n const queryByA11yValue = queryBy(instance);\n const queryAllByA11yValue = queryAllBy(instance);\n const findByA11yValue = findBy(instance);\n const findAllByA11yValue = findAllBy(instance);\n\n return {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AAIA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,KAAK,EAAEC,YAAY,EAAE;EAClD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAAC,2CAAuB,EAACF,IAAI,EAAEH,KAAK,CAAC,EACvEC,YAAY,CACb;AACH,CAAC;AAEH,MAAMK,iBAAiB,GAAIC,OAAkC,IAAK;EAChE,MAAMC,MAAgB,GAAG,EAAE;EAE3BC,mCAAqB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC1C,IAAIJ,OAAO,CAACI,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACnCJ,MAAM,CAACK,IAAI,CAAE,GAAEF,QAAS,WAAUJ,OAAO,CAACI,QAAQ,CAAE,EAAC,CAAC;IACxD;EACF,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAIR,OAAkC,IACzD,gCAA+BD,iBAAiB,CAACC,OAAO,CAAE,EAAC;AAE9D,MAAMS,eAAe,GAAIT,OAAkC,IACxD,kCAAiCD,iBAAiB,CAACC,OAAO,CAAE,EAAC;AAEhE,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E1B,mBAAmB,EACnBmB,eAAe,EACfD,gBAAgB,CACjB;AA6CM,MAAMS,sBAAsB,GACjC1B,QAA2B,IACJ;EACvB,MAAM2B,cAAc,GAAGR,KAAK,CAACnB,QAAQ,CAAC;EACtC,MAAM4B,iBAAiB,GAAGR,QAAQ,CAACpB,QAAQ,CAAC;EAC5C,MAAM6B,gBAAgB,GAAGR,OAAO,CAACrB,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGuB,UAAU,CAACtB,QAAQ,CAAC;EAChD,MAAM8B,eAAe,GAAGP,MAAM,CAACvB,QAAQ,CAAC;EACxC,MAAM+B,kBAAkB,GAAGP,SAAS,CAACxB,QAAQ,CAAC;EAE9C,OAAO;IACL2B,cAAc;IACdC,iBAAiB;IACjBC,gBAAgB;IAChB9B,mBAAmB;IACnB+B,eAAe;IACfC,kBAAkB;IAElBC,uBAAuB,EAAEL,cAAc;IACvCM,0BAA0B,EAAEL,iBAAiB;IAC7CM,yBAAyB,EAAEL,gBAAgB;IAC3CM,4BAA4B,EAAEpC,mBAAmB;IACjDqC,wBAAwB,EAAEN,eAAe;IACzCO,2BAA2B,EAAEN;EAC/B,CAAC;AACH,CAAC;AAAC"}
@@ -1,13 +1,15 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
2
+ import { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- import type { TextMatchOptions } from './text';
5
- export declare type ByDisplayValueQueries = {
6
- getByDisplayValue: GetByQuery<TextMatch, TextMatchOptions>;
7
- getAllByDisplayValue: GetAllByQuery<TextMatch, TextMatchOptions>;
8
- queryByDisplayValue: QueryByQuery<TextMatch, TextMatchOptions>;
9
- queryAllByDisplayValue: QueryAllByQuery<TextMatch, TextMatchOptions>;
10
- findByDisplayValue: FindByQuery<TextMatch, TextMatchOptions>;
11
- findAllByDisplayValue: FindAllByQuery<TextMatch, TextMatchOptions>;
4
+ import type { CommonQueryOptions } from './options';
5
+ type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
6
+ export type ByDisplayValueQueries = {
7
+ getByDisplayValue: GetByQuery<TextMatch, ByDisplayValueOptions>;
8
+ getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;
9
+ queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;
10
+ queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;
11
+ findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;
12
+ findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;
12
13
  };
13
14
  export declare const bindByDisplayValueQueries: (instance: ReactTestInstance) => ByDisplayValueQueries;
15
+ export {};
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.bindByDisplayValueQueries = void 0;
7
7
  var _reactNative = require("react-native");
8
8
  var _filterNodeByType = require("../helpers/filterNodeByType");
9
+ var _findAll = require("../helpers/findAll");
9
10
  var _matches = require("../matches");
10
11
  var _makeQueries = require("./makeQueries");
11
12
  const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
@@ -17,7 +18,7 @@ const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
17
18
  return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
18
19
  };
19
20
  const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
20
- return instance.findAll(node => getTextInputNodeByDisplayValue(node, displayValue, queryOptions));
21
+ return (0, _findAll.findAll)(instance, node => getTextInputNodeByDisplayValue(node, displayValue, queryOptions), queryOptions);
21
22
  };
22
23
  const getMultipleError = displayValue => `Found multiple elements with display value: ${String(displayValue)} `;
23
24
  const getMissingError = displayValue => `Unable to find an element with displayValue: ${String(displayValue)}`;
@@ -1 +1 @@
1
- {"version":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,IAAuB,EACvBC,KAAgB,EAChBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,SAAS,GACbL,IAAI,CAACM,KAAK,CAACL,KAAK,KAAKM,SAAS,GAAGP,IAAI,CAACM,KAAK,CAACL,KAAK,GAAGD,IAAI,CAACM,KAAK,CAACE,YAAY;EAC7E,OACE,IAAAC,kCAAgB,EAACT,IAAI,EAAEU,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACV,KAAK,EAAEI,SAAS,EAAED,UAAU,EAAED,KAAK,CAAC;AAEhD,CAAC;AAED,MAAMS,sBAAsB,GAC1BC,QAA2B,IAK3B,SAASC,wBAAwB,CAACC,YAAY,EAAEC,YAAY,EAAE;EAC5D,OAAOH,QAAQ,CAACI,OAAO,CAAEjB,IAAI,IAC3BD,8BAA8B,CAACC,IAAI,EAAEe,YAAY,EAAEC,YAAY,CAAC,CACjE;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIH,YAAuB,IAC9C,+CAA8CI,MAAM,CAACJ,YAAY,CAAE,GAAE;AACxE,MAAMK,eAAe,GAAIL,YAAuB,IAC7C,gDAA+CI,MAAM,CAACJ,YAAY,CAAE,EAAC;AAExE,MAAM;EAAEM,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ef,sBAAsB,EACtBQ,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,yBAAyB,GACpCf,QAA2B,KACA;EAC3BgB,iBAAiB,EAAER,KAAK,CAACR,QAAQ,CAAC;EAClCiB,oBAAoB,EAAER,QAAQ,CAACT,QAAQ,CAAC;EACxCkB,mBAAmB,EAAER,OAAO,CAACV,QAAQ,CAAC;EACtCD,sBAAsB,EAAEY,UAAU,CAACX,QAAQ,CAAC;EAC5CmB,kBAAkB,EAAEP,MAAM,CAACZ,QAAQ,CAAC;EACpCoB,qBAAqB,EAAEP,SAAS,CAACb,QAAQ;AAC3C,CAAC,CAAC;AAAC"}
1
+ {"version":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 { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } 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 { CommonQueryOptions } from './options';\n\ntype ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;\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?: ByDisplayValueOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByDisplayValueFn(displayValue, queryOptions) {\n return findAll(\n instance,\n (node) =>\n getTextInputNodeByDisplayValue(node, displayValue, queryOptions),\n 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, ByDisplayValueOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;\n findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;\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;AACA;AAaA,MAAMA,8BAA8B,GAAG,CACrCC,IAAuB,EACvBC,KAAgB,EAChBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,MAAMG,SAAS,GACbL,IAAI,CAACM,KAAK,CAACL,KAAK,KAAKM,SAAS,GAAGP,IAAI,CAACM,KAAK,CAACL,KAAK,GAAGD,IAAI,CAACM,KAAK,CAACE,YAAY;EAC7E,OACE,IAAAC,kCAAgB,EAACT,IAAI,EAAEU,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACV,KAAK,EAAEI,SAAS,EAAED,UAAU,EAAED,KAAK,CAAC;AAEhD,CAAC;AAED,MAAMS,sBAAsB,GAC1BC,QAA2B,IAK3B,SAASC,wBAAwB,CAACC,YAAY,EAAEC,YAAY,EAAE;EAC5D,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPb,IAAI,IACHD,8BAA8B,CAACC,IAAI,EAAEe,YAAY,EAAEC,YAAY,CAAC,EAClEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIH,YAAuB,IAC9C,+CAA8CI,MAAM,CAACJ,YAAY,CAAE,GAAE;AACxE,MAAMK,eAAe,GAAIL,YAAuB,IAC7C,gDAA+CI,MAAM,CAACJ,YAAY,CAAE,EAAC;AAExE,MAAM;EAAEM,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ef,sBAAsB,EACtBQ,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,yBAAyB,GACpCf,QAA2B,KACA;EAC3BgB,iBAAiB,EAAER,KAAK,CAACR,QAAQ,CAAC;EAClCiB,oBAAoB,EAAER,QAAQ,CAACT,QAAQ,CAAC;EACxCkB,mBAAmB,EAAER,OAAO,CAACV,QAAQ,CAAC;EACtCD,sBAAsB,EAAEY,UAAU,CAACX,QAAQ,CAAC;EAC5CmB,kBAAkB,EAAEP,MAAM,CAACZ,QAAQ,CAAC;EACpCoB,qBAAqB,EAAEP,SAAS,CAACb,QAAQ;AAC3C,CAAC,CAAC;AAAC"}
@@ -1,25 +1,27 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
2
+ import { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- import { TextMatchOptions } from './text';
5
- export declare type ByHintTextQueries = {
6
- getByHintText: GetByQuery<TextMatch, TextMatchOptions>;
7
- getAllByHintText: GetAllByQuery<TextMatch, TextMatchOptions>;
8
- queryByHintText: QueryByQuery<TextMatch, TextMatchOptions>;
9
- queryAllByHintText: QueryAllByQuery<TextMatch, TextMatchOptions>;
10
- findByHintText: FindByQuery<TextMatch, TextMatchOptions>;
11
- findAllByHintText: FindAllByQuery<TextMatch, TextMatchOptions>;
12
- getByA11yHint: GetByQuery<TextMatch, TextMatchOptions>;
13
- getAllByA11yHint: GetAllByQuery<TextMatch, TextMatchOptions>;
14
- queryByA11yHint: QueryByQuery<TextMatch, TextMatchOptions>;
15
- queryAllByA11yHint: QueryAllByQuery<TextMatch, TextMatchOptions>;
16
- findByA11yHint: FindByQuery<TextMatch, TextMatchOptions>;
17
- findAllByA11yHint: FindAllByQuery<TextMatch, TextMatchOptions>;
18
- getByAccessibilityHint: GetByQuery<TextMatch, TextMatchOptions>;
19
- getAllByAccessibilityHint: GetAllByQuery<TextMatch, TextMatchOptions>;
20
- queryByAccessibilityHint: QueryByQuery<TextMatch, TextMatchOptions>;
21
- queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, TextMatchOptions>;
22
- findByAccessibilityHint: FindByQuery<TextMatch, TextMatchOptions>;
23
- findAllByAccessibilityHint: FindAllByQuery<TextMatch, TextMatchOptions>;
4
+ import { CommonQueryOptions } from './options';
5
+ type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
6
+ export type ByHintTextQueries = {
7
+ getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;
8
+ getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;
9
+ queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;
10
+ queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;
11
+ findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;
12
+ findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;
13
+ getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;
14
+ getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;
15
+ queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;
16
+ queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;
17
+ findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;
18
+ findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;
19
+ getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;
20
+ getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;
21
+ queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;
22
+ queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;
23
+ findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;
24
+ findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;
24
25
  };
25
26
  export declare const bindByHintTextQueries: (instance: ReactTestInstance) => ByHintTextQueries;
27
+ export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByHintTextQueries = void 0;
7
+ var _findAll = require("../helpers/findAll");
7
8
  var _matches = require("../matches");
8
9
  var _makeQueries = require("./makeQueries");
9
10
  const getNodeByHintText = (node, text, options = {}) => {
@@ -14,7 +15,7 @@ const getNodeByHintText = (node, text, options = {}) => {
14
15
  return (0, _matches.matches)(text, node.props.accessibilityHint, normalizer, exact);
15
16
  };
16
17
  const queryAllByHintText = instance => function queryAllByA11yHintFn(hint, queryOptions) {
17
- return instance.findAll(node => typeof node.type === 'string' && getNodeByHintText(node, hint, queryOptions));
18
+ return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && getNodeByHintText(node, hint, queryOptions), queryOptions);
18
19
  };
19
20
  const getMultipleError = hint => `Found multiple elements with accessibilityHint: ${String(hint)} `;
20
21
  const getMissingError = hint => `Unable to find an element with accessibilityHint: ${String(hint)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"hintText.js","names":["getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint"],"sources":["../../src/queries/hintText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\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 { TextMatchOptions } from './text';\n\nconst getNodeByHintText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityHint, normalizer, exact);\n};\n\nconst queryAllByHintText = (\n instance: ReactTestInstance\n): ((\n hint: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n getNodeByHintText(node, hint, queryOptions)\n );\n };\n\nconst getMultipleError = (hint: TextMatch) =>\n `Found multiple elements with accessibilityHint: ${String(hint)} `;\nconst getMissingError = (hint: TextMatch) =>\n `Unable to find an element with accessibilityHint: ${String(hint)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByHintText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByHintTextQueries = {\n getByHintText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByHintText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByHintText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, TextMatchOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByA11yHint: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, TextMatchOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByHintTextQueries = (\n instance: ReactTestInstance\n): ByHintTextQueries => {\n const getByHintText = getBy(instance);\n const getAllByHintText = getAllBy(instance);\n const queryByHintText = queryBy(instance);\n const queryAllByHintText = queryAllBy(instance);\n const findByHintText = findBy(instance);\n const findAllByHintText = findAllBy(instance);\n\n return {\n getByHintText,\n getAllByHintText,\n queryByHintText,\n queryAllByHintText,\n findByHintText,\n findAllByHintText,\n\n // a11yHint aliases\n getByA11yHint: getByHintText,\n getAllByA11yHint: getAllByHintText,\n queryByA11yHint: queryByHintText,\n queryAllByA11yHint: queryAllByHintText,\n findByA11yHint: findByHintText,\n findAllByA11yHint: findAllByHintText,\n\n // accessibilityHint aliases\n getByAccessibilityHint: getByHintText,\n getAllByAccessibilityHint: getAllByHintText,\n queryByAccessibilityHint: queryByHintText,\n queryAllByAccessibilityHint: queryAllByHintText,\n findByAccessibilityHint: findByHintText,\n findAllByAccessibilityHint: findAllByHintText,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AAWA,MAAMA,iBAAiB,GAAG,CACxBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,iBAAiB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACvE,CAAC;AAED,MAAMK,kBAAkB,GACtBC,QAA2B,IAK3B,SAASC,oBAAoB,CAACC,IAAI,EAAEC,YAAY,EAAE;EAChD,OAAOH,QAAQ,CAACI,OAAO,CACpBb,IAAI,IACH,OAAOA,IAAI,CAACc,IAAI,KAAK,QAAQ,IAC7Bf,iBAAiB,CAACC,IAAI,EAAEW,IAAI,EAAEC,YAAY,CAAC,CAC9C;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIJ,IAAe,IACtC,mDAAkDK,MAAM,CAACL,IAAI,CAAE,GAAE;AACpE,MAAMM,eAAe,GAAIN,IAAe,IACrC,qDAAoDK,MAAM,CAACL,IAAI,CAAE,EAAC;AAErE,MAAM;EAAEO,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,kBAAkB,EAClBS,eAAe,EACfF,gBAAgB,CACjB;AA2BM,MAAMU,qBAAqB,GAChChB,QAA2B,IACL;EACtB,MAAMiB,aAAa,GAAGR,KAAK,CAACT,QAAQ,CAAC;EACrC,MAAMkB,gBAAgB,GAAGR,QAAQ,CAACV,QAAQ,CAAC;EAC3C,MAAMmB,eAAe,GAAGR,OAAO,CAACX,QAAQ,CAAC;EACzC,MAAMD,kBAAkB,GAAGa,UAAU,CAACZ,QAAQ,CAAC;EAC/C,MAAMoB,cAAc,GAAGP,MAAM,CAACb,QAAQ,CAAC;EACvC,MAAMqB,iBAAiB,GAAGP,SAAS,CAACd,QAAQ,CAAC;EAE7C,OAAO;IACLiB,aAAa;IACbC,gBAAgB;IAChBC,eAAe;IACfpB,kBAAkB;IAClBqB,cAAc;IACdC,iBAAiB;IAEjB;IACAC,aAAa,EAAEL,aAAa;IAC5BM,gBAAgB,EAAEL,gBAAgB;IAClCM,eAAe,EAAEL,eAAe;IAChCM,kBAAkB,EAAE1B,kBAAkB;IACtC2B,cAAc,EAAEN,cAAc;IAC9BO,iBAAiB,EAAEN,iBAAiB;IAEpC;IACAO,sBAAsB,EAAEX,aAAa;IACrCY,yBAAyB,EAAEX,gBAAgB;IAC3CY,wBAAwB,EAAEX,eAAe;IACzCY,2BAA2B,EAAEhC,kBAAkB;IAC/CiC,uBAAuB,EAAEZ,cAAc;IACvCa,0BAA0B,EAAEZ;EAC9B,CAAC;AACH,CAAC;AAAC"}
1
+ {"version":3,"file":"hintText.js","names":["getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint"],"sources":["../../src/queries/hintText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByHintTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByHintText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityHint, normalizer, exact);\n};\n\nconst queryAllByHintText = (\n instance: ReactTestInstance\n): ((\n hint: TextMatch,\n queryOptions?: ByHintTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n getNodeByHintText(node, hint, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (hint: TextMatch) =>\n `Found multiple elements with accessibilityHint: ${String(hint)} `;\nconst getMissingError = (hint: TextMatch) =>\n `Unable to find an element with accessibilityHint: ${String(hint)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByHintText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByHintTextQueries = {\n getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n};\n\nexport const bindByHintTextQueries = (\n instance: ReactTestInstance\n): ByHintTextQueries => {\n const getByHintText = getBy(instance);\n const getAllByHintText = getAllBy(instance);\n const queryByHintText = queryBy(instance);\n const queryAllByHintText = queryAllBy(instance);\n const findByHintText = findBy(instance);\n const findAllByHintText = findAllBy(instance);\n\n return {\n getByHintText,\n getAllByHintText,\n queryByHintText,\n queryAllByHintText,\n findByHintText,\n findAllByHintText,\n\n // a11yHint aliases\n getByA11yHint: getByHintText,\n getAllByA11yHint: getAllByHintText,\n queryByA11yHint: queryByHintText,\n queryAllByA11yHint: queryAllByHintText,\n findByA11yHint: findByHintText,\n findAllByA11yHint: findAllByHintText,\n\n // accessibilityHint aliases\n getByAccessibilityHint: getByHintText,\n getAllByAccessibilityHint: getAllByHintText,\n queryByAccessibilityHint: queryByHintText,\n queryAllByAccessibilityHint: queryAllByHintText,\n findByAccessibilityHint: findByHintText,\n findAllByAccessibilityHint: findAllByHintText,\n };\n};\n"],"mappings":";;;;;;AACA;AACA;AACA;AAaA,MAAMA,iBAAiB,GAAG,CACxBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,iBAAiB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACvE,CAAC;AAED,MAAMK,kBAAkB,GACtBC,QAA2B,IAK3B,SAASC,oBAAoB,CAACC,IAAI,EAAEC,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPT,IAAI,IACH,OAAOA,IAAI,CAACc,IAAI,KAAK,QAAQ,IAC7Bf,iBAAiB,CAACC,IAAI,EAAEW,IAAI,EAAEC,YAAY,CAAC,EAC7CA,YAAY,CACb;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIJ,IAAe,IACtC,mDAAkDK,MAAM,CAACL,IAAI,CAAE,GAAE;AACpE,MAAMM,eAAe,GAAIN,IAAe,IACrC,qDAAoDK,MAAM,CAACL,IAAI,CAAE,EAAC;AAErE,MAAM;EAAEO,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,kBAAkB,EAClBS,eAAe,EACfF,gBAAgB,CACjB;AA2BM,MAAMU,qBAAqB,GAChChB,QAA2B,IACL;EACtB,MAAMiB,aAAa,GAAGR,KAAK,CAACT,QAAQ,CAAC;EACrC,MAAMkB,gBAAgB,GAAGR,QAAQ,CAACV,QAAQ,CAAC;EAC3C,MAAMmB,eAAe,GAAGR,OAAO,CAACX,QAAQ,CAAC;EACzC,MAAMD,kBAAkB,GAAGa,UAAU,CAACZ,QAAQ,CAAC;EAC/C,MAAMoB,cAAc,GAAGP,MAAM,CAACb,QAAQ,CAAC;EACvC,MAAMqB,iBAAiB,GAAGP,SAAS,CAACd,QAAQ,CAAC;EAE7C,OAAO;IACLiB,aAAa;IACbC,gBAAgB;IAChBC,eAAe;IACfpB,kBAAkB;IAClBqB,cAAc;IACdC,iBAAiB;IAEjB;IACAC,aAAa,EAAEL,aAAa;IAC5BM,gBAAgB,EAAEL,gBAAgB;IAClCM,eAAe,EAAEL,eAAe;IAChCM,kBAAkB,EAAE1B,kBAAkB;IACtC2B,cAAc,EAAEN,cAAc;IAC9BO,iBAAiB,EAAEN,iBAAiB;IAEpC;IACAO,sBAAsB,EAAEX,aAAa;IACrCY,yBAAyB,EAAEX,gBAAgB;IAC3CY,wBAAwB,EAAEX,eAAe;IACzCY,2BAA2B,EAAEhC,kBAAkB;IAC/CiC,uBAAuB,EAAEZ,cAAc;IACvCa,0BAA0B,EAAEZ;EAC9B,CAAC;AACH,CAAC;AAAC"}
@@ -1,13 +1,15 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
2
+ import { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- import { TextMatchOptions } from './text';
5
- export declare type ByLabelTextQueries = {
6
- getByLabelText: GetByQuery<TextMatch, TextMatchOptions>;
7
- getAllByLabelText: GetAllByQuery<TextMatch, TextMatchOptions>;
8
- queryByLabelText: QueryByQuery<TextMatch, TextMatchOptions>;
9
- queryAllByLabelText: QueryAllByQuery<TextMatch, TextMatchOptions>;
10
- findByLabelText: FindByQuery<TextMatch, TextMatchOptions>;
11
- findAllByLabelText: FindAllByQuery<TextMatch, TextMatchOptions>;
4
+ import { CommonQueryOptions } from './options';
5
+ type ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;
6
+ export type ByLabelTextQueries = {
7
+ getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;
8
+ getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;
9
+ queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;
10
+ queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;
11
+ findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;
12
+ findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;
12
13
  };
13
14
  export declare const bindByLabelTextQueries: (instance: ReactTestInstance) => ByLabelTextQueries;
15
+ export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByLabelTextQueries = void 0;
7
+ var _findAll = require("../helpers/findAll");
7
8
  var _matches = require("../matches");
8
9
  var _makeQueries = require("./makeQueries");
9
10
  const getNodeByLabelText = (node, text, options = {}) => {
@@ -14,7 +15,7 @@ const getNodeByLabelText = (node, text, options = {}) => {
14
15
  return (0, _matches.matches)(text, node.props.accessibilityLabel, normalizer, exact);
15
16
  };
16
17
  const queryAllByLabelText = instance => function queryAllByLabelTextFn(text, queryOptions) {
17
- return instance.findAll(node => typeof node.type === 'string' && getNodeByLabelText(node, text, queryOptions));
18
+ return (0, _findAll.findAll)(instance, node => typeof node.type === 'string' && getNodeByLabelText(node, text, queryOptions), queryOptions);
18
19
  };
19
20
  const getMultipleError = labelText => `Found multiple elements with accessibilityLabel: ${String(labelText)} `;
20
21
  const getMissingError = labelText => `Unable to find an element with accessibilityLabel: ${String(labelText)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"labelText.js","names":["getNodeByLabelText","node","text","options","exact","normalizer","matches","props","accessibilityLabel","queryAllByLabelText","instance","queryAllByLabelTextFn","queryOptions","findAll","type","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText"],"sources":["../../src/queries/labelText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\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 { TextMatchOptions } from './text';\n\nconst getNodeByLabelText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityLabel, normalizer, exact);\n};\n\nconst queryAllByLabelText = (\n instance: ReactTestInstance\n): ((\n text: TextMatch,\n queryOptions?: TextMatchOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByLabelTextFn(text, queryOptions?: TextMatchOptions) {\n return instance.findAll(\n (node) =>\n typeof node.type === 'string' &&\n getNodeByLabelText(node, text, queryOptions)\n );\n };\n\nconst getMultipleError = (labelText: TextMatch) =>\n `Found multiple elements with accessibilityLabel: ${String(labelText)} `;\nconst getMissingError = (labelText: TextMatch) =>\n `Unable to find an element with accessibilityLabel: ${String(labelText)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByLabelText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByLabelTextQueries = {\n getByLabelText: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByLabelText: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByLabelText: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByLabelTextQueries = (\n instance: ReactTestInstance\n): ByLabelTextQueries => ({\n getByLabelText: getBy(instance),\n getAllByLabelText: getAllBy(instance),\n queryByLabelText: queryBy(instance),\n queryAllByLabelText: queryAllBy(instance),\n findByLabelText: findBy(instance),\n findAllByLabelText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AAWA,MAAMA,kBAAkB,GAAG,CACzBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,kBAAkB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACxE,CAAC;AAED,MAAMK,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACT,IAAI,EAAEU,YAA+B,EAAE;EACpE,OAAOF,QAAQ,CAACG,OAAO,CACpBZ,IAAI,IACH,OAAOA,IAAI,CAACa,IAAI,KAAK,QAAQ,IAC7Bd,kBAAkB,CAACC,IAAI,EAAEC,IAAI,EAAEU,YAAY,CAAC,CAC/C;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIC,SAAoB,IAC3C,oDAAmDC,MAAM,CAACD,SAAS,CAAE,GAAE;AAC1E,MAAME,eAAe,GAAIF,SAAoB,IAC1C,sDAAqDC,MAAM,CAACD,SAAS,CAAE,EAAC;AAE3E,MAAM;EAAEG,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,mBAAmB,EACnBS,eAAe,EACfH,gBAAgB,CACjB;AAWM,MAAMW,sBAAsB,GACjChB,QAA2B,KACH;EACxBiB,cAAc,EAAER,KAAK,CAACT,QAAQ,CAAC;EAC/BkB,iBAAiB,EAAER,QAAQ,CAACV,QAAQ,CAAC;EACrCmB,gBAAgB,EAAER,OAAO,CAACX,QAAQ,CAAC;EACnCD,mBAAmB,EAAEa,UAAU,CAACZ,QAAQ,CAAC;EACzCoB,eAAe,EAAEP,MAAM,CAACb,QAAQ,CAAC;EACjCqB,kBAAkB,EAAEP,SAAS,CAACd,QAAQ;AACxC,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"labelText.js","names":["getNodeByLabelText","node","text","options","exact","normalizer","matches","props","accessibilityLabel","queryAllByLabelText","instance","queryAllByLabelTextFn","queryOptions","findAll","type","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText"],"sources":["../../src/queries/labelText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByLabelText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityLabel, normalizer, exact);\n};\n\nconst queryAllByLabelText = (\n instance: ReactTestInstance\n): ((\n text: TextMatch,\n queryOptions?: ByLabelTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByLabelTextFn(text, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' &&\n getNodeByLabelText(node, text, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (labelText: TextMatch) =>\n `Found multiple elements with accessibilityLabel: ${String(labelText)} `;\nconst getMissingError = (labelText: TextMatch) =>\n `Unable to find an element with accessibilityLabel: ${String(labelText)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByLabelText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByLabelTextQueries = {\n getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;\n queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;\n findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;\n};\n\nexport const bindByLabelTextQueries = (\n instance: ReactTestInstance\n): ByLabelTextQueries => ({\n getByLabelText: getBy(instance),\n getAllByLabelText: getAllBy(instance),\n queryByLabelText: queryBy(instance),\n queryAllByLabelText: queryAllBy(instance),\n findByLabelText: findBy(instance),\n findAllByLabelText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAaA,MAAMA,kBAAkB,GAAG,CACzBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,kBAAkB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACxE,CAAC;AAED,MAAMK,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACT,IAAI,EAAEU,YAAY,EAAE;EACjD,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPT,IAAI,IACH,OAAOA,IAAI,CAACa,IAAI,KAAK,QAAQ,IAC7Bd,kBAAkB,CAACC,IAAI,EAAEC,IAAI,EAAEU,YAAY,CAAC,EAC9CA,YAAY,CACb;AACH,CAAC;AAEH,MAAMG,gBAAgB,GAAIC,SAAoB,IAC3C,oDAAmDC,MAAM,CAACD,SAAS,CAAE,GAAE;AAC1E,MAAME,eAAe,GAAIF,SAAoB,IAC1C,sDAAqDC,MAAM,CAACD,SAAS,CAAE,EAAC;AAE3E,MAAM;EAAEG,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhB,mBAAmB,EACnBS,eAAe,EACfH,gBAAgB,CACjB;AAWM,MAAMW,sBAAsB,GACjChB,QAA2B,KACH;EACxBiB,cAAc,EAAER,KAAK,CAACT,QAAQ,CAAC;EAC/BkB,iBAAiB,EAAER,QAAQ,CAACV,QAAQ,CAAC;EACrCmB,gBAAgB,EAAER,OAAO,CAACX,QAAQ,CAAC;EACnCD,mBAAmB,EAAEa,UAAU,CAACZ,QAAQ,CAAC;EACzCoB,eAAe,EAAEP,MAAM,CAACb,QAAQ,CAAC;EACjCqB,kBAAkB,EAAEP,SAAS,CAACd,QAAQ;AACxC,CAAC,CAAC;AAAC"}
@@ -1,13 +1,13 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
2
  import type { WaitForOptions } from '../waitFor';
3
- export declare type GetByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance;
4
- export declare type GetAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
5
- export declare type QueryByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance | null;
6
- export declare type QueryAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
7
- export declare type FindByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
8
- export declare type FindAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance[]>;
9
- declare type UnboundQuery<Query> = (instance: ReactTestInstance) => Query;
10
- export declare type UnboundQueries<Predicate, Options> = {
3
+ export type GetByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance;
4
+ export type GetAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
5
+ export type QueryByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance | null;
6
+ export type QueryAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options) => ReactTestInstance[];
7
+ export type FindByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance>;
8
+ export type FindAllByQuery<Predicate, Options = void> = (predicate: Predicate, options?: Options & WaitForOptions, waitForOptions?: WaitForOptions) => Promise<ReactTestInstance[]>;
9
+ type UnboundQuery<Query> = (instance: ReactTestInstance) => Query;
10
+ export type UnboundQueries<Predicate, Options> = {
11
11
  getBy: UnboundQuery<GetByQuery<Predicate, Options>>;
12
12
  getAllBy: UnboundQuery<GetAllByQuery<Predicate, Options>>;
13
13
  queryBy: UnboundQuery<QueryByQuery<Predicate, Options>>;
@@ -0,0 +1,11 @@
1
+ import { NormalizerFn } from '../matches';
2
+ export type CommonQueryOptions = {
3
+ /** Should query include elements hidden from accessibility. */
4
+ includeHiddenElements?: boolean;
5
+ /** RTL-compatibile alias to `includeHiddenElements`. */
6
+ hidden?: boolean;
7
+ };
8
+ export type TextMatchOptions = {
9
+ exact?: boolean;
10
+ normalizer?: NormalizerFn;
11
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","names":[],"sources":["../../src/queries/options.ts"],"sourcesContent":["import { NormalizerFn } from '../matches';\n\nexport type CommonQueryOptions = {\n /** Should query include elements hidden from accessibility. */\n includeHiddenElements?: boolean;\n\n /** RTL-compatibile alias to `includeHiddenElements`. */\n hidden?: boolean;\n};\n\nexport type TextMatchOptions = {\n exact?: boolean;\n normalizer?: NormalizerFn;\n};\n"],"mappings":""}
@@ -1,13 +1,15 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
2
+ import { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- import type { TextMatchOptions } from './text';
5
- export declare type ByPlaceholderTextQueries = {
6
- getByPlaceholderText: GetByQuery<TextMatch, TextMatchOptions>;
7
- getAllByPlaceholderText: GetAllByQuery<TextMatch, TextMatchOptions>;
8
- queryByPlaceholderText: QueryByQuery<TextMatch, TextMatchOptions>;
9
- queryAllByPlaceholderText: QueryAllByQuery<TextMatch, TextMatchOptions>;
10
- findByPlaceholderText: FindByQuery<TextMatch, TextMatchOptions>;
11
- findAllByPlaceholderText: FindAllByQuery<TextMatch, TextMatchOptions>;
4
+ import type { CommonQueryOptions } from './options';
5
+ type ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;
6
+ export type ByPlaceholderTextQueries = {
7
+ getByPlaceholderText: GetByQuery<TextMatch, ByPlaceholderTextOptions>;
8
+ getAllByPlaceholderText: GetAllByQuery<TextMatch, ByPlaceholderTextOptions>;
9
+ queryByPlaceholderText: QueryByQuery<TextMatch, ByPlaceholderTextOptions>;
10
+ queryAllByPlaceholderText: QueryAllByQuery<TextMatch, ByPlaceholderTextOptions>;
11
+ findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;
12
+ findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;
12
13
  };
13
14
  export declare const bindByPlaceholderTextQueries: (instance: ReactTestInstance) => ByPlaceholderTextQueries;
15
+ export {};
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByPlaceholderTextQueries = void 0;
7
7
  var _reactNative = require("react-native");
8
+ var _findAll = require("../helpers/findAll");
8
9
  var _filterNodeByType = require("../helpers/filterNodeByType");
9
10
  var _matches = require("../matches");
10
11
  var _makeQueries = require("./makeQueries");
@@ -16,7 +17,7 @@ const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
16
17
  return (0, _filterNodeByType.filterNodeByType)(node, _reactNative.TextInput) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
17
18
  };
18
19
  const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
19
- return instance.findAll(node => getTextInputNodeByPlaceholderText(node, placeholder, queryOptions));
20
+ return (0, _findAll.findAll)(instance, node => getTextInputNodeByPlaceholderText(node, placeholder, queryOptions), queryOptions);
20
21
  };
21
22
  const getMultipleError = placeholder => `Found multiple elements with placeholder: ${String(placeholder)} `;
22
23
  const getMissingError = placeholder => `Unable to find an element with placeholder: ${String(placeholder)}`;
@@ -1 +1 @@
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,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OACE,IAAAG,kCAAgB,EAACL,IAAI,EAAEM,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACN,WAAW,EAAED,IAAI,CAACQ,KAAK,CAACP,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMM,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAACV,WAAW,EAAEW,YAAY,EAAE;EAC1D,OAAOF,QAAQ,CAACG,OAAO,CAAEb,IAAI,IAC3BD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEW,YAAY,CAAC,CACnE;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIb,WAAsB,IAC7C,6CAA4Cc,MAAM,CAACd,WAAW,CAAE,GAAE;AACrE,MAAMe,eAAe,GAAIf,WAAsB,IAC5C,+CAA8Cc,MAAM,CAACd,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEgB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,yBAAyB,EACzBO,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,4BAA4B,GACvCd,QAA2B,KACG;EAC9Be,oBAAoB,EAAER,KAAK,CAACP,QAAQ,CAAC;EACrCgB,uBAAuB,EAAER,QAAQ,CAACR,QAAQ,CAAC;EAC3CiB,sBAAsB,EAAER,OAAO,CAACT,QAAQ,CAAC;EACzCD,yBAAyB,EAAEW,UAAU,CAACV,QAAQ,CAAC;EAC/CkB,qBAAqB,EAAEP,MAAM,CAACX,QAAQ,CAAC;EACvCmB,wBAAwB,EAAEP,SAAS,CAACZ,QAAQ;AAC9C,CAAC,CAAC;AAAC"}
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 { findAll } from '../helpers/findAll';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { matches, TextMatch, TextMatchOptions } 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 { CommonQueryOptions } from './options';\n\ntype ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;\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?: ByPlaceholderTextOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return findAll(\n instance,\n (node) =>\n getTextInputNodeByPlaceholderText(node, placeholder, queryOptions),\n 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, ByPlaceholderTextOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<\n TextMatch,\n ByPlaceholderTextOptions\n >;\n findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;\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;AACA;AAaA,MAAMA,iCAAiC,GAAG,CACxCC,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OACE,IAAAG,kCAAgB,EAACL,IAAI,EAAEM,sBAAS,CAAC,IACjC,IAAAC,gBAAO,EAACN,WAAW,EAAED,IAAI,CAACQ,KAAK,CAACP,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMM,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAACV,WAAW,EAAEW,YAAY,EAAE;EAC1D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPV,IAAI,IACHD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEW,YAAY,CAAC,EACpEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIb,WAAsB,IAC7C,6CAA4Cc,MAAM,CAACd,WAAW,CAAE,GAAE;AACrE,MAAMe,eAAe,GAAIf,WAAsB,IAC5C,+CAA8Cc,MAAM,CAACd,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEgB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,yBAAyB,EACzBO,eAAe,EACfF,gBAAgB,CACjB;AAcM,MAAMU,4BAA4B,GACvCd,QAA2B,KACG;EAC9Be,oBAAoB,EAAER,KAAK,CAACP,QAAQ,CAAC;EACrCgB,uBAAuB,EAAER,QAAQ,CAACR,QAAQ,CAAC;EAC3CiB,sBAAsB,EAAER,OAAO,CAACT,QAAQ,CAAC;EACzCD,yBAAyB,EAAEW,UAAU,CAACV,QAAQ,CAAC;EAC/CkB,qBAAqB,EAAEP,MAAM,CAACX,QAAQ,CAAC;EACvCmB,wBAAwB,EAAEP,SAAS,CAACZ,QAAQ;AAC9C,CAAC,CAAC;AAAC"}
@@ -1,11 +1,14 @@
1
- import { type AccessibilityState } from 'react-native';
1
+ import type { AccessibilityState } from 'react-native';
2
2
  import type { ReactTestInstance } from 'react-test-renderer';
3
+ import { AccessibilityValueMatcher } from '../helpers/matchers/accessibilityValue';
3
4
  import type { TextMatch } from '../matches';
4
5
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
5
- declare type ByRoleOptions = {
6
+ import { CommonQueryOptions } from './options';
7
+ type ByRoleOptions = CommonQueryOptions & AccessibilityState & {
6
8
  name?: TextMatch;
7
- } & AccessibilityState;
8
- export declare type ByRoleQueries = {
9
+ value?: AccessibilityValueMatcher;
10
+ };
11
+ export type ByRoleQueries = {
9
12
  getByRole: GetByQuery<TextMatch, ByRoleOptions>;
10
13
  getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;
11
14
  queryByRole: QueryByQuery<TextMatch, ByRoleOptions>;
@@ -5,7 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByRoleQueries = void 0;
7
7
  var _accessiblity = require("../helpers/accessiblity");
8
+ var _findAll = require("../helpers/findAll");
8
9
  var _accessibilityState = require("../helpers/matchers/accessibilityState");
10
+ var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
9
11
  var _matchStringProp = require("../helpers/matchers/matchStringProp");
10
12
  var _within = require("../within");
11
13
  var _makeQueries = require("./makeQueries");
@@ -20,26 +22,33 @@ const matchAccessibleNameIfNeeded = (node, name) => {
20
22
  const matchAccessibleStateIfNeeded = (node, options) => {
21
23
  return options != null ? (0, _accessibilityState.matchAccessibilityState)(node, options) : true;
22
24
  };
25
+ const matchAccessibilityValueIfNeeded = (node, value) => {
26
+ return value != null ? (0, _accessibilityValue.matchAccessibilityValue)(node, value) : true;
27
+ };
23
28
  const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
24
- return instance.findAll(node =>
29
+ return (0, _findAll.findAll)(instance, node =>
25
30
  // run the cheapest checks first, and early exit too avoid unneeded computations
26
-
27
- typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibleNameIfNeeded(node, options?.name));
31
+ typeof node.type === 'string' && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
28
32
  };
29
- const buildErrorMessage = (role, options = {}) => {
30
- const errors = [`role: "${String(role)}"`];
33
+ const formatQueryParams = (role, options = {}) => {
34
+ const params = [`role: "${String(role)}"`];
31
35
  if (options.name) {
32
- errors.push(`name: "${String(options.name)}"`);
36
+ params.push(`name: "${String(options.name)}"`);
33
37
  }
34
38
  _accessiblity.accessibilityStateKeys.forEach(stateKey => {
35
39
  if (options[stateKey] !== undefined) {
36
- errors.push(`${stateKey} state: ${options[stateKey]}`);
40
+ params.push(`${stateKey} state: ${options[stateKey]}`);
41
+ }
42
+ });
43
+ _accessiblity.accessiblityValueKeys.forEach(valueKey => {
44
+ if (options?.value?.[valueKey] !== undefined) {
45
+ params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);
37
46
  }
38
47
  });
39
- return errors.join(', ');
48
+ return params.join(', ');
40
49
  };
41
- const getMultipleError = (role, options) => `Found multiple elements with ${buildErrorMessage(role, options)}`;
42
- const getMissingError = (role, options) => `Unable to find an element with ${buildErrorMessage(role, options)}`;
50
+ const getMultipleError = (role, options) => `Found multiple elements with ${formatQueryParams(role, options)}`;
51
+ const getMissingError = (role, options) => `Unable to find an element with ${formatQueryParams(role, options)}`;
43
52
  const {
44
53
  getBy,
45
54
  getAllBy,
@@ -1 +1 @@
1
- {"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","queryAllByRole","instance","queryAllByRoleFn","role","findAll","type","matchStringProp","props","accessibilityRole","buildErrorMessage","errors","String","push","accessibilityStateKeys","forEach","stateKey","undefined","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import { type AccessibilityState } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport type { 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} & AccessibilityState;\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 matchAccessibleStateIfNeeded = (\n node: ReactTestInstance,\n options?: ByRoleOptions\n) => {\n return options != null ? matchAccessibilityState(node, options) : true;\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 // run the cheapest checks first, and early exit too avoid unneeded computations\n\n typeof node.type === 'string' &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibleNameIfNeeded(node, options?.name)\n );\n };\n\nconst buildErrorMessage = (role: TextMatch, options: ByRoleOptions = {}) => {\n const errors = [`role: \"${String(role)}\"`];\n\n if (options.name) {\n errors.push(`name: \"${String(options.name)}\"`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${buildErrorMessage(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${buildErrorMessage(role, options)}`;\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":";;;;;;AAEA;AACA;AACA;AAEA;AACA;AAcA,MAAMA,2BAA2B,GAAG,CAClCC,IAAuB,EACvBC,IAAgB,KACb;EACH,IAAIA,IAAI,IAAI,IAAI,EAAE,OAAO,IAAI;EAE7B,MAAM;IAAEC,cAAc;IAAEC;EAAoB,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,IAAI,CAAC;EAC1E,OACEE,cAAc,CAACD,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC,IAAIF,mBAAmB,CAACF,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC;AAE3E,CAAC;AAED,MAAMC,4BAA4B,GAAG,CACnCN,IAAuB,EACvBO,OAAuB,KACpB;EACH,OAAOA,OAAO,IAAI,IAAI,GAAG,IAAAC,2CAAuB,EAACR,IAAI,EAAEO,OAAO,CAAC,GAAG,IAAI;AACxE,CAAC;AAED,MAAME,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAEL,OAAO,EAAE;EACvC,OAAOG,QAAQ,CAACG,OAAO,CACpBb,IAAI;EACH;;EAEA,OAAOA,IAAI,CAACc,IAAI,KAAK,QAAQ,IAC7B,IAAAC,gCAAe,EAACf,IAAI,CAACgB,KAAK,CAACC,iBAAiB,EAAEL,IAAI,CAAC,IACnDN,4BAA4B,CAACN,IAAI,EAAEO,OAAO,CAAC,IAC3CR,2BAA2B,CAACC,IAAI,EAAEO,OAAO,EAAEN,IAAI,CAAC,CACnD;AACH,CAAC;AAEH,MAAMiB,iBAAiB,GAAG,CAACN,IAAe,EAAEL,OAAsB,GAAG,CAAC,CAAC,KAAK;EAC1E,MAAMY,MAAM,GAAG,CAAE,UAASC,MAAM,CAACR,IAAI,CAAE,GAAE,CAAC;EAE1C,IAAIL,OAAO,CAACN,IAAI,EAAE;IAChBkB,MAAM,CAACE,IAAI,CAAE,UAASD,MAAM,CAACb,OAAO,CAACN,IAAI,CAAE,GAAE,CAAC;EAChD;EAEAqB,oCAAsB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC3C,IAAIjB,OAAO,CAACiB,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACnCN,MAAM,CAACE,IAAI,CAAE,GAAEG,QAAS,WAAUjB,OAAO,CAACiB,QAAQ,CAAE,EAAC,CAAC;IACxD;EACF,CAAC,CAAC;EAEF,OAAOL,MAAM,CAACO,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAG,CAACf,IAAe,EAAEL,OAAuB,KAC/D,gCAA+BW,iBAAiB,CAACN,IAAI,EAAEL,OAAO,CAAE,EAAC;AAEpE,MAAMqB,eAAe,GAAG,CAAChB,IAAe,EAAEL,OAAuB,KAC9D,kCAAiCW,iBAAiB,CAACN,IAAI,EAAEL,OAAO,CAAE,EAAC;AAEtE,MAAM;EAAEsB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E1B,cAAc,EACdmB,eAAe,EACfD,gBAAgB,CACjB;AAWM,MAAMS,iBAAiB,GAC5B1B,QAA2B,KACR;EACnB2B,SAAS,EAAER,KAAK,CAACnB,QAAQ,CAAC;EAC1B4B,YAAY,EAAER,QAAQ,CAACpB,QAAQ,CAAC;EAChC6B,WAAW,EAAER,OAAO,CAACrB,QAAQ,CAAC;EAC9BD,cAAc,EAAEuB,UAAU,CAACtB,QAAQ,CAAC;EACpC8B,UAAU,EAAEP,MAAM,CAACvB,QAAQ,CAAC;EAC5B+B,aAAa,EAAEP,SAAS,CAACxB,QAAQ;AACnC,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","findAll","type","matchStringProp","props","accessibilityRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessiblityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityState } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport {\n accessibilityStateKeys,\n accessiblityValueKeys,\n} from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport type { 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';\nimport { CommonQueryOptions } from './options';\n\ntype ByRoleOptions = CommonQueryOptions &\n AccessibilityState & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\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 matchAccessibleStateIfNeeded = (\n node: ReactTestInstance,\n options?: ByRoleOptions\n) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): ((role: TextMatch, options?: ByRoleOptions) => Array<ReactTestInstance>) =>\n function queryAllByRoleFn(role, options) {\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit too avoid unneeded computations\n typeof node.type === 'string' &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: \"${String(role)}\"`];\n\n if (options.name) {\n params.push(`name: \"${String(options.name)}\"`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\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":";;;;;;AAEA;AAIA;AACA;AACA;AAIA;AAEA;AACA;AAiBA,MAAMA,2BAA2B,GAAG,CAClCC,IAAuB,EACvBC,IAAgB,KACb;EACH,IAAIA,IAAI,IAAI,IAAI,EAAE,OAAO,IAAI;EAE7B,MAAM;IAAEC,cAAc;IAAEC;EAAoB,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,IAAI,CAAC;EAC1E,OACEE,cAAc,CAACD,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC,IAAIF,mBAAmB,CAACF,IAAI,CAAC,CAACI,MAAM,GAAG,CAAC;AAE3E,CAAC;AAED,MAAMC,4BAA4B,GAAG,CACnCN,IAAuB,EACvBO,OAAuB,KACpB;EACH,OAAOA,OAAO,IAAI,IAAI,GAAG,IAAAC,2CAAuB,EAACR,IAAI,EAAEO,OAAO,CAAC,GAAG,IAAI;AACxE,CAAC;AAED,MAAME,+BAA+B,GAAG,CACtCT,IAAuB,EACvBU,KAAiC,KAC9B;EACH,OAAOA,KAAK,IAAI,IAAI,GAAG,IAAAC,2CAAuB,EAACX,IAAI,EAAEU,KAAK,CAAC,GAAG,IAAI;AACpE,CAAC;AAED,MAAME,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAER,OAAO,EAAE;EACvC,OAAO,IAAAS,gBAAO,EACZH,QAAQ,EACPb,IAAI;EACH;EACA,OAAOA,IAAI,CAACiB,IAAI,KAAK,QAAQ,IAC7B,IAAAC,gCAAe,EAAClB,IAAI,CAACmB,KAAK,CAACC,iBAAiB,EAAEL,IAAI,CAAC,IACnDT,4BAA4B,CAACN,IAAI,EAAEO,OAAO,CAAC,IAC3CE,+BAA+B,CAACT,IAAI,EAAEO,OAAO,EAAEG,KAAK,CAAC,IACrDX,2BAA2B,CAACC,IAAI,EAAEO,OAAO,EAAEN,IAAI,CAAC,EAClDM,OAAO,CACR;AACH,CAAC;AAEH,MAAMc,iBAAiB,GAAG,CAACN,IAAe,EAAER,OAAsB,GAAG,CAAC,CAAC,KAAK;EAC1E,MAAMe,MAAM,GAAG,CAAE,UAASC,MAAM,CAACR,IAAI,CAAE,GAAE,CAAC;EAE1C,IAAIR,OAAO,CAACN,IAAI,EAAE;IAChBqB,MAAM,CAACE,IAAI,CAAE,UAASD,MAAM,CAAChB,OAAO,CAACN,IAAI,CAAE,GAAE,CAAC;EAChD;EAEAwB,oCAAsB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC3C,IAAIpB,OAAO,CAACoB,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACnCN,MAAM,CAACE,IAAI,CAAE,GAAEG,QAAS,WAAUpB,OAAO,CAACoB,QAAQ,CAAE,EAAC,CAAC;IACxD;EACF,CAAC,CAAC;EAEFE,mCAAqB,CAACH,OAAO,CAAEI,QAAQ,IAAK;IAC1C,IAAIvB,OAAO,EAAEG,KAAK,GAAGoB,QAAQ,CAAC,KAAKF,SAAS,EAAE;MAC5CN,MAAM,CAACE,IAAI,CAAE,GAAEM,QAAS,WAAUvB,OAAO,EAAEG,KAAK,GAAGoB,QAAQ,CAAE,EAAC,CAAC;IACjE;EACF,CAAC,CAAC;EAEF,OAAOR,MAAM,CAACS,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAG,CAACjB,IAAe,EAAER,OAAuB,KAC/D,gCAA+Bc,iBAAiB,CAACN,IAAI,EAAER,OAAO,CAAE,EAAC;AAEpE,MAAM0B,eAAe,GAAG,CAAClB,IAAe,EAAER,OAAuB,KAC9D,kCAAiCc,iBAAiB,CAACN,IAAI,EAAER,OAAO,CAAE,EAAC;AAEtE,MAAM;EAAE2B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E5B,cAAc,EACdqB,eAAe,EACfD,gBAAgB,CACjB;AAWM,MAAMS,iBAAiB,GAC5B5B,QAA2B,KACR;EACnB6B,SAAS,EAAER,KAAK,CAACrB,QAAQ,CAAC;EAC1B8B,YAAY,EAAER,QAAQ,CAACtB,QAAQ,CAAC;EAChC+B,WAAW,EAAER,OAAO,CAACvB,QAAQ,CAAC;EAC9BD,cAAc,EAAEyB,UAAU,CAACxB,QAAQ,CAAC;EACpCgC,UAAU,EAAEP,MAAM,CAACzB,QAAQ,CAAC;EAC5BiC,aAAa,EAAEP,SAAS,CAAC1B,QAAQ;AACnC,CAAC,CAAC;AAAC"}
@@ -1,13 +1,15 @@
1
1
  import type { ReactTestInstance } from 'react-test-renderer';
2
- import { TextMatch } from '../matches';
2
+ import { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './makeQueries';
4
- import type { TextMatchOptions } from './text';
5
- export declare type ByTestIdQueries = {
6
- getByTestId: GetByQuery<TextMatch, TextMatchOptions>;
7
- getAllByTestId: GetAllByQuery<TextMatch, TextMatchOptions>;
8
- queryByTestId: QueryByQuery<TextMatch, TextMatchOptions>;
9
- queryAllByTestId: QueryAllByQuery<TextMatch, TextMatchOptions>;
10
- findByTestId: FindByQuery<TextMatch, TextMatchOptions>;
11
- findAllByTestId: FindAllByQuery<TextMatch, TextMatchOptions>;
4
+ import type { CommonQueryOptions } from './options';
5
+ type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
6
+ export type ByTestIdQueries = {
7
+ getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;
8
+ getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;
9
+ queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;
10
+ queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;
11
+ findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;
12
+ findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;
12
13
  };
13
14
  export declare const bindByTestIdQueries: (instance: ReactTestInstance) => ByTestIdQueries;
15
+ export {};
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByTestIdQueries = void 0;
7
+ var _findAll = require("../helpers/findAll");
7
8
  var _matches = require("../matches");
8
9
  var _makeQueries = require("./makeQueries");
9
10
  const getNodeByTestId = (node, testID, options = {}) => {
@@ -14,8 +15,8 @@ const getNodeByTestId = (node, testID, options = {}) => {
14
15
  return (0, _matches.matches)(testID, node.props.testID, normalizer, exact);
15
16
  };
16
17
  const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
17
- const results = instance.findAll(node => getNodeByTestId(node, testId, queryOptions)).filter(element => typeof element.type === 'string');
18
- return results;
18
+ const results = (0, _findAll.findAll)(instance, node => getNodeByTestId(node, testId, queryOptions), queryOptions);
19
+ return results.filter(element => typeof element.type === 'string');
19
20
  };
20
21
  const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
21
22
  const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","results","findAll","filter","element","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId"],"sources":["../../src/queries/testId.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\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 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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, TextMatchOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, TextMatchOptions>;\n queryByTestId: QueryByQuery<TextMatch, TextMatchOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, TextMatchOptions>;\n findByTestId: FindByQuery<TextMatch, TextMatchOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, TextMatchOptions>;\n};\n\nexport const bindByTestIdQueries = (\n instance: ReactTestInstance\n): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AAWA,MAAMA,eAAe,GAAG,CACtBC,IAAuB,EACvBC,MAAiB,EACjBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,IAAI,CAACM,KAAK,CAACL,MAAM,EAAEG,UAAU,EAAED,KAAK,CAAC;AAC9D,CAAC;AAED,MAAMI,gBAAgB,GACpBC,QAA2B,IAK3B,SAASC,kBAAkB,CAACC,MAAM,EAAEC,YAAY,EAAE;EAChD,MAAMC,OAAO,GAAGJ,QAAQ,CACrBK,OAAO,CAAEb,IAAI,IAAKD,eAAe,CAACC,IAAI,EAAEU,MAAM,EAAEC,YAAY,CAAC,CAAC,CAC9DG,MAAM,CAAEC,OAAO,IAAK,OAAOA,OAAO,CAACC,IAAI,KAAK,QAAQ,CAAC;EAExD,OAAOJ,OAAO;AAChB,CAAC;AAEH,MAAMK,gBAAgB,GAAIP,MAAiB,IACxC,wCAAuCQ,MAAM,CAACR,MAAM,CAAE,EAAC;AAC1D,MAAMS,eAAe,GAAIT,MAAiB,IACvC,0CAAyCQ,MAAM,CAACR,MAAM,CAAE,EAAC;AAE5D,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,gBAAgB,EAChBY,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,mBAAmB,GAC9BnB,QAA2B,KACN;EACrBoB,WAAW,EAAER,KAAK,CAACZ,QAAQ,CAAC;EAC5BqB,cAAc,EAAER,QAAQ,CAACb,QAAQ,CAAC;EAClCsB,aAAa,EAAER,OAAO,CAACd,QAAQ,CAAC;EAChCD,gBAAgB,EAAEgB,UAAU,CAACf,QAAQ,CAAC;EACtCuB,YAAY,EAAEP,MAAM,CAAChB,QAAQ,CAAC;EAC9BwB,eAAe,EAAEP,SAAS,CAACjB,QAAQ;AACrC,CAAC,CAAC;AAAC"}
1
+ {"version":3,"file":"testId.js","names":["getNodeByTestId","node","testID","options","exact","normalizer","matches","props","queryAllByTestId","instance","queryAllByTestIdFn","testId","queryOptions","results","findAll","filter","element","type","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId"],"sources":["../../src/queries/testId.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } 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 { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\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?: ByTestIdOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByTestIdFn(testId, queryOptions) {\n const results = findAll(\n instance,\n (node) => getNodeByTestId(node, testId, queryOptions),\n queryOptions\n );\n\n return results.filter((element) => typeof element.type === 'string');\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 { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (\n instance: ReactTestInstance\n): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAaA,MAAMA,eAAe,GAAG,CACtBC,IAAuB,EACvBC,MAAiB,EACjBC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,IAAI,CAACM,KAAK,CAACL,MAAM,EAAEG,UAAU,EAAED,KAAK,CAAC;AAC9D,CAAC;AAED,MAAMI,gBAAgB,GACpBC,QAA2B,IAK3B,SAASC,kBAAkB,CAACC,MAAM,EAAEC,YAAY,EAAE;EAChD,MAAMC,OAAO,GAAG,IAAAC,gBAAO,EACrBL,QAAQ,EACPR,IAAI,IAAKD,eAAe,CAACC,IAAI,EAAEU,MAAM,EAAEC,YAAY,CAAC,EACrDA,YAAY,CACb;EAED,OAAOC,OAAO,CAACE,MAAM,CAAEC,OAAO,IAAK,OAAOA,OAAO,CAACC,IAAI,KAAK,QAAQ,CAAC;AACtE,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,MAAiB,IACxC,wCAAuCQ,MAAM,CAACR,MAAM,CAAE,EAAC;AAC1D,MAAMS,eAAe,GAAIT,MAAiB,IACvC,0CAAyCQ,MAAM,CAACR,MAAM,CAAE,EAAC;AAE5D,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,gBAAgB,EAChBY,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,mBAAmB,GAC9BnB,QAA2B,KACN;EACrBoB,WAAW,EAAER,KAAK,CAACZ,QAAQ,CAAC;EAC5BqB,cAAc,EAAER,QAAQ,CAACb,QAAQ,CAAC;EAClCsB,aAAa,EAAER,OAAO,CAACd,QAAQ,CAAC;EAChCD,gBAAgB,EAAEgB,UAAU,CAACf,QAAQ,CAAC;EACtCuB,YAAY,EAAEP,MAAM,CAAChB,QAAQ,CAAC;EAC9BwB,eAAe,EAAEP,SAAS,CAACjB,QAAQ;AACrC,CAAC,CAAC;AAAC"}