@testing-library/react-native 11.5.1 → 12.0.0-rc.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.
package/README.md CHANGED
@@ -72,11 +72,11 @@ Then automatically add it to your jest tests by using `setupFilesAfterEnv` optio
72
72
  }
73
73
  ```
74
74
 
75
- ### Custom Jest Preset
75
+ ### Custom Jest Preset (React Native before 0.71)
76
76
 
77
- > **important** if you use "modern" Fake Timers
77
+ We generally advise to use the "react-native" preset when testing with this library.
78
78
 
79
- We generally advise to use the "react-native" preset when testing with this library. However, if you use ["modern" Fake Timers](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers) (default since Jest 27), you'll need to apply our custom Jest preset or awaiting promises, like `waitFor`, will timeout.
79
+ However, if you use React Native version earlier than 0.71 with [modern Jest fake timers](https://jestjs.io/blog/2020/05/05/jest-26#new-fake-timers) (default since Jest 27), you'll need to apply this custom Jest preset or otherwise awaiting promises, like using `waitFor` or `findBy*`, queries will fail with timeout.
80
80
 
81
81
  This is a [known issue](https://github.com/facebook/react-native/issues/29303). It happens because React Native's Jest preset overrides native Promise. Our preset restores it to defaults, which is not a problem in most apps out there.
82
82
 
package/build/config.d.ts CHANGED
@@ -19,8 +19,6 @@ export type HostComponentNames = {
19
19
  textInput: string;
20
20
  };
21
21
  export type InternalConfig = Config & {
22
- /** Whether to use breaking changes intended for next major version release. */
23
- useBreakingChanges: boolean;
24
22
  /** Names for key React Native host components. */
25
23
  hostComponentNames?: HostComponentNames;
26
24
  };
@@ -37,8 +35,6 @@ export declare function getConfig(): {
37
35
  defaultIncludeHiddenElements: boolean;
38
36
  /** Default options for `debug` helper. */
39
37
  defaultDebugOptions?: Partial<DebugOptions> | undefined;
40
- /** Whether to use breaking changes intended for next major version release. */
41
- useBreakingChanges: boolean;
42
38
  /** Names for key React Native host components. */
43
39
  hostComponentNames?: HostComponentNames | undefined;
44
40
  };
package/build/config.js CHANGED
@@ -12,9 +12,8 @@ exports.resetToDefaults = resetToDefaults;
12
12
  */
13
13
 
14
14
  const defaultConfig = {
15
- useBreakingChanges: false,
16
15
  asyncUtilTimeout: 1000,
17
- defaultIncludeHiddenElements: true
16
+ defaultIncludeHiddenElements: false
18
17
  };
19
18
  let config = {
20
19
  ...defaultConfig
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["defaultConfig","useBreakingChanges","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n};\n\nexport type InternalConfig = Config & {\n /** Whether to use breaking changes intended for next major version release. */\n useBreakingChanges: boolean;\n\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n useBreakingChanges: false,\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: true,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AA+BA,MAAMA,aAA6B,GAAG;EACpCC,kBAAkB,EAAE,KAAK;EACzBC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGJ;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASK,SAAS,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiB,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAe,GAAG;EAChCP,MAAM,GAAG;IAAE,GAAGJ;EAAc,CAAC;AAC/B;AAEO,SAASY,SAAS,GAAG;EAC1B,OAAOR,MAAM;AACf"}
1
+ {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AA4BA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAAS,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,iBAAiB,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAe,GAAG;EAChCP,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASW,SAAS,GAAG;EAC1B,OAAOR,MAAM;AACf"}
@@ -38,6 +38,11 @@ function isHiddenFromAccessibility(element, {
38
38
  const isInaccessible = isHiddenFromAccessibility;
39
39
  exports.isInaccessible = isInaccessible;
40
40
  function isSubtreeInaccessible(element) {
41
+ // Null props can happen for React.Fragments
42
+ if (element.props == null) {
43
+ return false;
44
+ }
45
+
41
46
  // iOS: accessibilityElementsHidden
42
47
  // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
43
48
  if (element.props.accessibilityElementsHidden) {
@@ -1 +1 @@
1
- {"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","accessiblityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal","isAccessibilityElement","accessible","isHostElementForType","Text","TextInput","Switch"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n Switch,\n Text,\n TextInput,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, isHostElementForType } from './component-tree';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessiblityValueKeys: (keyof AccessibilityValue)[] = [\n 'min',\n 'max',\n 'now',\n 'text',\n];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {}\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => sibling.props.accessibilityViewIsModal)) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(\n element: ReactTestInstance | null\n): boolean {\n if (element == null) {\n return false;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n return (\n isHostElementForType(element, Text) ||\n isHostElementForType(element, TextInput) ||\n isHostElementForType(element, Switch)\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AASA;AAMO,MAAMA,sBAAoD,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,MAAMC,qBAAmD,GAAG,CACjE,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,CACP;AAAC;AAEK,SAASC,yBAAyB,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;E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AACc,UAAU;EACjC;EAEA,OACE,IAAAC,mCAAoB,EAACzB,OAAO,EAAE0B,iBAAI,CAAC,IACnC,IAAAD,mCAAoB,EAACzB,OAAO,EAAE2B,sBAAS,CAAC,IACxC,IAAAF,mCAAoB,EAACzB,OAAO,EAAE4B,mBAAM,CAAC;AAEzC"}
1
+ {"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","accessiblityValueKeys","isHiddenFromAccessibility","element","cache","current","isCurrentSubtreeInaccessible","get","undefined","isSubtreeInaccessible","set","parent","isInaccessible","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal","isAccessibilityElement","accessible","isHostElementForType","Text","TextInput","Switch"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n Switch,\n Text,\n TextInput,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings, isHostElementForType } from './component-tree';\n\ntype IsInaccessibleOptions = {\n cache?: WeakMap<ReactTestInstance, boolean>;\n};\n\nexport const accessibilityStateKeys: (keyof AccessibilityState)[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport const accessiblityValueKeys: (keyof AccessibilityValue)[] = [\n 'min',\n 'max',\n 'now',\n 'text',\n];\n\nexport function isHiddenFromAccessibility(\n element: ReactTestInstance | null,\n { cache }: IsInaccessibleOptions = {}\n): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n let isCurrentSubtreeInaccessible = cache?.get(current);\n\n if (isCurrentSubtreeInaccessible === undefined) {\n isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);\n cache?.set(current, isCurrentSubtreeInaccessible);\n }\n\n if (isCurrentSubtreeInaccessible) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\n/** RTL-compatitibility alias for `isHiddenFromAccessibility` */\nexport const isInaccessible = isHiddenFromAccessibility;\n\nfunction isSubtreeInaccessible(element: ReactTestInstance): boolean {\n // Null props can happen for React.Fragments\n if (element.props == null) {\n return false;\n }\n\n // iOS: accessibilityElementsHidden\n // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios\n if (element.props.accessibilityElementsHidden) {\n return true;\n }\n\n // Android: importantForAccessibility\n // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android\n if (element.props.importantForAccessibility === 'no-hide-descendants') {\n return true;\n }\n\n // Note that `opacity: 0` is not treated as inaccessible on iOS\n const flatStyle = StyleSheet.flatten(element.props.style) ?? {};\n if (flatStyle.display === 'none') return true;\n\n // iOS: accessibilityViewIsModal\n // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios\n const hostSiblings = getHostSiblings(element);\n if (hostSiblings.some((sibling) => sibling.props.accessibilityViewIsModal)) {\n return true;\n }\n\n return false;\n}\n\nexport function isAccessibilityElement(\n element: ReactTestInstance | null\n): boolean {\n if (element == null) {\n return false;\n }\n\n if (element.props.accessible !== undefined) {\n return element.props.accessible;\n }\n\n return (\n isHostElementForType(element, Text) ||\n isHostElementForType(element, TextInput) ||\n isHostElementForType(element, Switch)\n );\n}\n"],"mappings":";;;;;;;;;AAAA;AASA;AAMO,MAAMA,sBAAoD,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,MAAMC,qBAAmD,GAAG,CACjE,KAAK,EACL,KAAK,EACL,KAAK,EACL,MAAM,CACP;AAAC;AAEK,SAASC,yBAAyB,CACvCC,OAAiC,EACjC;EAAEC;AAA6B,CAAC,GAAG,CAAC,CAAC,EAC5B;EACT,IAAID,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIE,OAAiC,GAAGF,OAAO;EAC/C,OAAOE,OAAO,EAAE;IACd,IAAIC,4BAA4B,GAAGF,KAAK,EAAEG,GAAG,CAACF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CAACc,UAAU;EACjC;EAEA,OACE,IAAAC,mCAAoB,EAACzB,OAAO,EAAE0B,iBAAI,CAAC,IACnC,IAAAD,mCAAoB,EAACzB,OAAO,EAAE2B,sBAAS,CAAC,IACxC,IAAAF,mCAAoB,EAACzB,OAAO,EAAE4B,mBAAM,CAAC;AAEzC"}
@@ -0,0 +1 @@
1
+ export declare function deprecateQueries<Queries extends Record<string, any>>(queriesObject: Queries, recommendation: string): Queries;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.deprecateQueries = deprecateQueries;
7
+ var _queryName = require("./query-name");
8
+ function deprecateQueries(queriesObject, recommendation) {
9
+ const result = {};
10
+ Object.keys(queriesObject).forEach(queryName => {
11
+ const queryFn = queriesObject[queryName];
12
+ // @ts-expect-error: generic typing is hard
13
+ result[queryName] = deprecateQuery(queryFn, queryName, recommendation);
14
+ });
15
+ return result;
16
+ }
17
+ function deprecateQuery(queryFn, queryName, recommendation) {
18
+ const formattedRecommendation = recommendation.replace(/{queryPrefix}/g, (0, _queryName.getQueryPrefix)(queryName));
19
+
20
+ // @ts-expect-error: generic typing is hard
21
+ const wrapper = (...args) => {
22
+ const errorMessage = `${queryName}(...) is deprecated and will be removed in the future.\n\n${formattedRecommendation}`;
23
+ // eslint-disable-next-line no-console
24
+ console.warn(errorMessage);
25
+ return queryFn(...args);
26
+ };
27
+ return wrapper;
28
+ }
29
+ //# sourceMappingURL=deprecation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecation.js","names":["deprecateQueries","queriesObject","recommendation","result","Object","keys","forEach","queryName","queryFn","deprecateQuery","formattedRecommendation","replace","getQueryPrefix","wrapper","args","errorMessage","console","warn"],"sources":["../../src/helpers/deprecation.ts"],"sourcesContent":["import { getQueryPrefix } from './query-name';\n\nexport function deprecateQueries<Queries extends Record<string, any>>(\n queriesObject: Queries,\n recommendation: string\n): Queries {\n const result = {} as Queries;\n Object.keys(queriesObject).forEach((queryName) => {\n const queryFn = queriesObject[queryName];\n // @ts-expect-error: generic typing is hard\n result[queryName] = deprecateQuery(queryFn, queryName, recommendation);\n });\n\n return result;\n}\n\nfunction deprecateQuery<QueryFn extends (...args: any) => any>(\n queryFn: QueryFn,\n queryName: string,\n recommendation: string\n): QueryFn {\n const formattedRecommendation = recommendation.replace(\n /{queryPrefix}/g,\n getQueryPrefix(queryName)\n );\n\n // @ts-expect-error: generic typing is hard\n const wrapper: QueryFn = (...args: any) => {\n const errorMessage = `${queryName}(...) is deprecated and will be removed in the future.\\n\\n${formattedRecommendation}`;\n // eslint-disable-next-line no-console\n console.warn(errorMessage);\n return queryFn(...args);\n };\n\n return wrapper;\n}\n"],"mappings":";;;;;;AAAA;AAEO,SAASA,gBAAgB,CAC9BC,aAAsB,EACtBC,cAAsB,EACb;EACT,MAAMC,MAAM,GAAG,CAAC,CAAY;EAC5BC,MAAM,CAACC,IAAI,CAACJ,aAAa,CAAC,CAACK,OAAO,CAAEC,SAAS,IAAK;IAChD,MAAMC,OAAO,GAAGP,aAAa,CAACM,SAAS,CAAC;IACxC;IACAJ,MAAM,CAACI,SAAS,CAAC,GAAGE,cAAc,CAACD,OAAO,EAAED,SAAS,EAAEL,cAAc,CAAC;EACxE,CAAC,CAAC;EAEF,OAAOC,MAAM;AACf;AAEA,SAASM,cAAc,CACrBD,OAAgB,EAChBD,SAAiB,EACjBL,cAAsB,EACb;EACT,MAAMQ,uBAAuB,GAAGR,cAAc,CAACS,OAAO,CACpD,gBAAgB,EAChB,IAAAC,yBAAc,EAACL,SAAS,CAAC,CAC1B;;EAED;EACA,MAAMM,OAAgB,GAAG,CAAC,GAAGC,IAAS,KAAK;IACzC,MAAMC,YAAY,GAAI,GAAER,SAAU,6DAA4DG,uBAAwB,EAAC;IACvH;IACAM,OAAO,CAACC,IAAI,CAACF,YAAY,CAAC;IAC1B,OAAOP,OAAO,CAAC,GAAGM,IAAI,CAAC;EACzB,CAAC;EAED,OAAOD,OAAO;AAChB"}
@@ -1,2 +1,3 @@
1
1
  import { HostComponentNames } from '../config';
2
2
  export declare function getHostComponentNames(): HostComponentNames;
3
+ export declare function configureHostComponentNamesIfNeeded(): void;
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.configureHostComponentNamesIfNeeded = configureHostComponentNamesIfNeeded;
6
7
  exports.getHostComponentNames = getHostComponentNames;
7
8
  var _react = _interopRequireDefault(require("react"));
8
9
  var _reactNative = require("react-native");
@@ -10,13 +11,29 @@ var _reactTestRenderer = _interopRequireDefault(require("react-test-renderer"));
10
11
  var _config = require("../config");
11
12
  var _within = require("../within");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
- const defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
14
+ const userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
14
15
  Please check if you are using compatible versions of React Native and React Native Testing Library.`;
15
16
  function getHostComponentNames() {
17
+ let hostComponentNames = (0, _config.getConfig)().hostComponentNames;
18
+ if (!hostComponentNames) {
19
+ hostComponentNames = detectHostComponentNames();
20
+ (0, _config.configureInternal)({
21
+ hostComponentNames
22
+ });
23
+ }
24
+ return hostComponentNames;
25
+ }
26
+ function configureHostComponentNamesIfNeeded() {
16
27
  const configHostComponentNames = (0, _config.getConfig)().hostComponentNames;
17
28
  if (configHostComponentNames) {
18
- return configHostComponentNames;
29
+ return;
19
30
  }
31
+ const hostComponentNames = detectHostComponentNames();
32
+ (0, _config.configureInternal)({
33
+ hostComponentNames
34
+ });
35
+ }
36
+ function detectHostComponentNames() {
20
37
  try {
21
38
  const renderer = _reactTestRenderer.default.create( /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
22
39
  testID: "text"
@@ -33,18 +50,13 @@ function getHostComponentNames() {
33
50
  if (typeof textHostName !== 'string' || typeof textInputHostName !== 'string') {
34
51
  throw new Error('getByTestId returned non-host component');
35
52
  }
36
- const hostComponentNames = {
53
+ return {
37
54
  text: textHostName,
38
55
  textInput: textInputHostName
39
56
  };
40
- (0, _config.configureInternal)({
41
- hostComponentNames
42
- });
43
- return hostComponentNames;
44
57
  } catch (error) {
45
58
  const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
46
- throw new Error(`Trying to detect host component names triggered the following error:\n\n${errorMessage}\n\n${defaultErrorMessage}
47
- `);
59
+ throw new Error(`Trying to detect host component names triggered the following error:\n\n${errorMessage}\n\n${userConfigErrorMessage}`);
48
60
  }
49
61
  }
50
62
  //# sourceMappingURL=host-component-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-component-names.js","names":["defaultErrorMessage","getHostComponentNames","configHostComponentNames","getConfig","hostComponentNames","renderer","TestRenderer","create","getByTestId","getQueriesForElement","root","textHostName","type","textInputHostName","Error","text","textInput","configureInternal","error","errorMessage","message"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, TextInput, View } from 'react-native';\nimport TestRenderer from 'react-test-renderer';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { getQueriesForElement } from '../within';\n\nconst defaultErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return configHostComponentNames;\n }\n\n try {\n const renderer = TestRenderer.create(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n </View>\n );\n const { getByTestId } = getQueriesForElement(renderer.root);\n const textHostName = getByTestId('text').type;\n const textInputHostName = getByTestId('textInput').type;\n\n // This code path should not happen as getByTestId always returns host elements.\n if (\n typeof textHostName !== 'string' ||\n typeof textInputHostName !== 'string'\n ) {\n throw new Error('getByTestId returned non-host component');\n }\n\n const hostComponentNames = {\n text: textHostName,\n textInput: textInputHostName,\n };\n configureInternal({ hostComponentNames });\n return hostComponentNames;\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(`Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${defaultErrorMessage}\n`);\n }\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AAAiD;AAEjD,MAAMA,mBAAmB,GAAI;AAC7B,oGAAoG;AAE7F,SAASC,qBAAqB,GAAuB;EAC1D,MAAMC,wBAAwB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAC/D,IAAIF,wBAAwB,EAAE;IAC5B,OAAOA,wBAAwB;EACjC;EAEA,IAAI;IACF,MAAMG,QAAQ,GAAGC,0BAAY,CAACC,MAAM,eAClC,6BAAC,iBAAI,qBACH,6BAAC,iBAAI;MAAC,MAAM,EAAC;IAAM,GAAC,OAAK,CAAO,eAChC,6BAAC,sBAAS;MAAC,MAAM,EAAC;IAAW,EAAG,CAC3B,CACR;IACD,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,QAAQ,CAACK,IAAI,CAAC;IAC3D,MAAMC,YAAY,GAAGH,WAAW,CAAC,MAAM,CAAC,CAACI,IAAI;IAC7C,MAAMC,iBAAiB,GAAGL,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI;;IAEvD;IACA,IACE,OAAOD,YAAY,KAAK,QAAQ,IAChC,OAAOE,iBAAiB,KAAK,QAAQ,EACrC;MACA,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IAEA,MAAMV,kBAAkB,GAAG;MACzBW,IAAI,EAAEJ,YAAY;MAClBK,SAAS,EAAEH;IACb,CAAC;IACD,IAAAI,yBAAiB,EAAC;MAAEb;IAAmB,CAAC,CAAC;IACzC,OAAOA,kBAAkB;EAC3B,CAAC,CAAC,OAAOc,KAAK,EAAE;IACd,MAAMC,YAAY,GAChBD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAIA,KAAK,GACpDA,KAAK,CAACE,OAAO,GACb,IAAI;IAEV,MAAM,IAAIN,KAAK,CAAE,2EAA0EK,YAAa,OAAMnB,mBAAoB;AACtI,CAAC,CAAC;EACA;AACF"}
1
+ {"version":3,"file":"host-component-names.js","names":["userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","TestRenderer","create","getByTestId","getQueriesForElement","root","textHostName","type","textInputHostName","Error","text","textInput","error","errorMessage","message"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import React from 'react';\nimport { Text, TextInput, View } from 'react-native';\nimport TestRenderer from 'react-test-renderer';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { getQueriesForElement } from '../within';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = TestRenderer.create(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n </View>\n );\n\n const { getByTestId } = getQueriesForElement(renderer.root);\n const textHostName = getByTestId('text').type;\n const textInputHostName = getByTestId('textInput').type;\n\n // This code path should not happen as getByTestId always returns host elements.\n if (\n typeof textHostName !== 'string' ||\n typeof textInputHostName !== 'string'\n ) {\n throw new Error('getByTestId returned non-host component');\n }\n\n return {\n text: textHostName,\n textInput: textInputHostName,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AAAiD;AAEjD,MAAMA,sBAAsB,GAAI;AAChC,oGAAoG;AAE7F,SAASC,qBAAqB,GAAuB;EAC1D,IAAIC,kBAAkB,GAAG,IAAAC,iBAAS,GAAE,CAACD,kBAAkB;EACvD,IAAI,CAACA,kBAAkB,EAAE;IACvBA,kBAAkB,GAAGE,wBAAwB,EAAE;IAC/C,IAAAC,yBAAiB,EAAC;MAAEH;IAAmB,CAAC,CAAC;EAC3C;EAEA,OAAOA,kBAAkB;AAC3B;AAEO,SAASI,mCAAmC,GAAG;EACpD,MAAMC,wBAAwB,GAAG,IAAAJ,iBAAS,GAAE,CAACD,kBAAkB;EAC/D,IAAIK,wBAAwB,EAAE;IAC5B;EACF;EAEA,MAAML,kBAAkB,GAAGE,wBAAwB,EAAE;EACrD,IAAAC,yBAAiB,EAAC;IAAEH;EAAmB,CAAC,CAAC;AAC3C;AAEA,SAASE,wBAAwB,GAAuB;EACtD,IAAI;IACF,MAAMI,QAAQ,GAAGC,0BAAY,CAACC,MAAM,eAClC,6BAAC,iBAAI,qBACH,6BAAC,iBAAI;MAAC,MAAM,EAAC;IAAM,GAAC,OAAK,CAAO,eAChC,6BAAC,sBAAS;MAAC,MAAM,EAAC;IAAW,EAAG,CAC3B,CACR;IAED,MAAM;MAAEC;IAAY,CAAC,GAAG,IAAAC,4BAAoB,EAACJ,QAAQ,CAACK,IAAI,CAAC;IAC3D,MAAMC,YAAY,GAAGH,WAAW,CAAC,MAAM,CAAC,CAACI,IAAI;IAC7C,MAAMC,iBAAiB,GAAGL,WAAW,CAAC,WAAW,CAAC,CAACI,IAAI;;IAEvD;IACA,IACE,OAAOD,YAAY,KAAK,QAAQ,IAChC,OAAOE,iBAAiB,KAAK,QAAQ,EACrC;MACA,MAAM,IAAIC,KAAK,CAAC,yCAAyC,CAAC;IAC5D;IAEA,OAAO;MACLC,IAAI,EAAEJ,YAAY;MAClBK,SAAS,EAAEH;IACb,CAAC;EACH,CAAC,CAAC,OAAOI,KAAK,EAAE;IACd,MAAMC,YAAY,GAChBD,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAIA,KAAK,GACpDA,KAAK,CAACE,OAAO,GACb,IAAI;IAEV,MAAM,IAAIL,KAAK,CACZ,2EAA0EI,YAAa,OAAMrB,sBAAuB,EAAC,CACvH;EACH;AACF"}
@@ -0,0 +1 @@
1
+ export declare function getQueryPrefix(queryName: string): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getQueryPrefix = getQueryPrefix;
7
+ function getQueryPrefix(queryName) {
8
+ const parts = queryName.split('By');
9
+ return parts[0];
10
+ }
11
+ //# sourceMappingURL=query-name.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-name.js","names":["getQueryPrefix","queryName","parts","split"],"sources":["../../src/helpers/query-name.ts"],"sourcesContent":["export function getQueryPrefix(queryName: string) {\n const parts = queryName.split('By');\n return parts[0];\n}\n"],"mappings":";;;;;;AAAO,SAASA,cAAc,CAACC,SAAiB,EAAE;EAChD,MAAMC,KAAK,GAAGD,SAAS,CAACE,KAAK,CAAC,IAAI,CAAC;EACnC,OAAOD,KAAK,CAAC,CAAC,CAAC;AACjB"}
@@ -436,7 +436,8 @@ declare module '@testing-library/react-native' {
436
436
  unmount(nextElement?: React.Element<any>): void;
437
437
  toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
438
438
  debug: Debug;
439
- container: ReactTestInstance;
439
+ root: ReactTestInstance;
440
+ UNSAFE_root: ReactTestInstance;
440
441
  }
441
442
 
442
443
  declare type RenderAPI = RenderResult;
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByA11yStateQueries = void 0;
7
7
  var _accessiblity = require("../helpers/accessiblity");
8
+ var _deprecation = require("../helpers/deprecation");
8
9
  var _findAll = require("../helpers/findAll");
9
10
  var _accessibilityState = require("../helpers/matchers/accessibilityState");
10
11
  var _makeQueries = require("./makeQueries");
@@ -38,18 +39,20 @@ const bindByA11yStateQueries = instance => {
38
39
  const findByA11yState = findBy(instance);
39
40
  const findAllByA11yState = findAllBy(instance);
40
41
  return {
41
- getByA11yState,
42
- getAllByA11yState,
43
- queryByA11yState,
44
- queryAllByA11yState,
45
- findByA11yState,
46
- findAllByA11yState,
47
- getByAccessibilityState: getByA11yState,
48
- getAllByAccessibilityState: getAllByA11yState,
49
- queryByAccessibilityState: queryByA11yState,
50
- queryAllByAccessibilityState: queryAllByA11yState,
51
- findByAccessibilityState: findByA11yState,
52
- findAllByAccessibilityState: findAllByA11yState
42
+ ...(0, _deprecation.deprecateQueries)({
43
+ getByA11yState,
44
+ getAllByA11yState,
45
+ queryByA11yState,
46
+ queryAllByA11yState,
47
+ findByA11yState,
48
+ findAllByA11yState,
49
+ getByAccessibilityState: getByA11yState,
50
+ getAllByAccessibilityState: getAllByA11yState,
51
+ queryByAccessibilityState: queryByA11yState,
52
+ queryAllByAccessibilityState: queryAllByA11yState,
53
+ findByAccessibilityState: findByA11yState,
54
+ findAllByAccessibilityState: findAllByA11yState
55
+ }, 'Use {queryPrefix}ByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from "@testing-library/jest-native" package instead.')
53
56
  };
54
57
  };
55
58
  exports.bindByA11yStateQueries = bindByA11yStateQueries;
@@ -1 +1 @@
1
- {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","type","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\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 queryAllByA11yState = (\n instance: ReactTestInstance\n): ((\n matcher: AccessibilityState,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(matcher, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityState(node, matcher),\n queryOptions\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityState = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;\n queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;\n findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByAccessibilityState: GetAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryByAccessibilityState: QueryByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryAllByAccessibilityState: QueryAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByAccessibilityState: FindAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n };\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,OAAO,EAAEC,YAAY,EAAE;EACpD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAA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gB;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
+ {"version":3,"file":"a11yState.js","names":["queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","type","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","deprecateQueries","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { AccessibilityState } from 'react-native';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { deprecateQueries } from '../helpers/deprecation';\nimport { findAll } from '../helpers/findAll';\nimport { matchAccessibilityState } from '../helpers/matchers/accessibilityState';\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 queryAllByA11yState = (\n instance: ReactTestInstance\n): ((\n matcher: AccessibilityState,\n queryOptions?: CommonQueryOptions\n) => Array<ReactTestInstance>) =>\n function queryAllByA11yStateFn(matcher, queryOptions) {\n return findAll(\n instance,\n (node) =>\n typeof node.type === 'string' && matchAccessibilityState(node, matcher),\n queryOptions\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityState = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityState) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityState) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByA11yState: GetAllByQuery<AccessibilityState, CommonQueryOptions>;\n queryByA11yState: QueryByQuery<AccessibilityState, CommonQueryOptions>;\n queryAllByA11yState: QueryAllByQuery<AccessibilityState, CommonQueryOptions>;\n findByA11yState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByA11yState: FindAllByQuery<AccessibilityState, CommonQueryOptions>;\n\n getByAccessibilityState: GetByQuery<AccessibilityState, CommonQueryOptions>;\n getAllByAccessibilityState: GetAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryByAccessibilityState: QueryByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n queryAllByAccessibilityState: QueryAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n findByAccessibilityState: FindByQuery<AccessibilityState, CommonQueryOptions>;\n findAllByAccessibilityState: FindAllByQuery<\n AccessibilityState,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n ...deprecateQueries(\n {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n },\n 'Use {queryPrefix}ByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from \"@testing-library/jest-native\" package instead.'\n ),\n };\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AAWA,MAAMA,mBAAmB,GACvBC,QAA2B,IAK3B,SAASC,qBAAqB,CAACC,OAAO,EAAEC,YAAY,EAAE;EACpD,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,OAAOA,IAAI,CAACC,IAAI,KAAK,QAAQ,IAAI,IAAAC,2CAAuB,EAACF,IAAI,EAAEH,OAAO,CAAC,EACzEC,YAAY,CACb;AACH,CAAC;AAEH,MAAMK,iBAAiB,GAAG,CAACC,KAAyB,GAAG,CAAC,CAAC,KAAK;EAC5D,MAAMC,MAAgB,GAAG,EAAE;EAE3BC,oCAAsB,CAACC,OAAO,CAAEC,QAAQ,IAAK;IAC3C,IAAIJ,KAAK,CAACI,QAAQ,CAAC,KAAKC,SAAS,EAAE;MACjCJ,MAAM,CAACK,IAAI,CAAE,GAAEF,QAAS,WAAUJ,KAAK,CAACI,QAAQ,CAAE,EAAC,CAAC;IACtD;EACF,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACM,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAIR,KAAyB,IAChD,gCAA+BD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE5D,MAAMS,eAAe,GAAIT,KAAyB,IAC/C,kCAAiCD,iBAAiB,CAACC,KAAK,CAAE,EAAC;AAE9D,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E1B,mBAAmB,EACnBmB,eAAe,EACfD,gBAAgB,CACjB;AA8BM,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;IACL,GAAG,IAAAgC,6BAAgB,EACjB;MACEL,cAAc;MACdC,iBAAiB;MACjBC,gBAAgB;MAChB9B,mBAAmB;MACnB+B,eAAe;MACfC,kBAAkB;MAClBE,uBAAuB,EAAEN,cAAc;MACvCO,0BAA0B,EAAEN,iBAAiB;MAC7CO,yBAAyB,EAAEN,gBAAgB;MAC3CO,4BAA4B,EAAErC,mBAAmB;MACjDsC,wBAAwB,EAAEP,eAAe;MACzCQ,2BAA2B,EAAEP;IAC/B,CAAC,EACD,gMAAgM;EAEpM,CAAC;AACH,CAAC;AAAC"}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.bindByA11yValueQueries = void 0;
7
7
  var _accessiblity = require("../helpers/accessiblity");
8
+ var _deprecation = require("../helpers/deprecation");
8
9
  var _findAll = require("../helpers/findAll");
9
10
  var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
10
11
  var _makeQueries = require("./makeQueries");
@@ -38,18 +39,20 @@ const bindByA11yValueQueries = instance => {
38
39
  const findByA11yValue = findBy(instance);
39
40
  const findAllByA11yValue = findAllBy(instance);
40
41
  return {
41
- getByA11yValue,
42
- getAllByA11yValue,
43
- queryByA11yValue,
44
- queryAllByA11yValue,
45
- findByA11yValue,
46
- findAllByA11yValue,
47
- getByAccessibilityValue: getByA11yValue,
48
- getAllByAccessibilityValue: getAllByA11yValue,
49
- queryByAccessibilityValue: queryByA11yValue,
50
- queryAllByAccessibilityValue: queryAllByA11yValue,
51
- findByAccessibilityValue: findByA11yValue,
52
- findAllByAccessibilityValue: findAllByA11yValue
42
+ ...(0, _deprecation.deprecateQueries)({
43
+ getByA11yValue,
44
+ getAllByA11yValue,
45
+ queryByA11yValue,
46
+ queryAllByA11yValue,
47
+ findByA11yValue,
48
+ findAllByA11yValue,
49
+ getByAccessibilityValue: getByA11yValue,
50
+ getAllByAccessibilityValue: getAllByA11yValue,
51
+ queryByAccessibilityValue: queryByA11yValue,
52
+ queryAllByAccessibilityValue: queryAllByA11yValue,
53
+ findByAccessibilityValue: findByA11yValue,
54
+ findAllByAccessibilityValue: findAllByA11yValue
55
+ }, 'Use expect(...).toHaveAccessibilityValue(...) matcher from "@testing-library/jest-native" package or {queryPrefix}ByRole(role, { value: ... }) query instead.')
53
56
  };
54
57
  };
55
58
  exports.bindByA11yValueQueries = bindByA11yValueQueries;
@@ -1 +1 @@
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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,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","deprecateQueries","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 { deprecateQueries } from '../helpers/deprecation';\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 ...deprecateQueries(\n {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n },\n 'Use expect(...).toHaveAccessibilityValue(...) matcher from \"@testing-library/jest-native\" package or {queryPrefix}ByRole(role, { value: ... }) query instead.'\n ),\n };\n};\n"],"mappings":";;;;;;AACA;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;IACL,GAAG,IAAAgC,6BAAgB,EACjB;MACEL,cAAc;MACdC,iBAAiB;MACjBC,gBAAgB;MAChB9B,mBAAmB;MACnB+B,eAAe;MACfC,kBAAkB;MAClBE,uBAAuB,EAAEN,cAAc;MACvCO,0BAA0B,EAAEN,iBAAiB;MAC7CO,yBAAyB,EAAEN,gBAAgB;MAC3CO,4BAA4B,EAAErC,mBAAmB;MACjDsC,wBAAwB,EAAEP,eAAe;MACzCQ,2BAA2B,EAAEP;IAC/B,CAAC,EACD,+JAA+J;EAEnK,CAAC;AACH,CAAC;AAAC"}
@@ -4,11 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByDisplayValueQueries = void 0;
7
- var _reactNative = require("react-native");
8
7
  var _filterNodeByType = require("../helpers/filterNodeByType");
9
8
  var _findAll = require("../helpers/findAll");
10
9
  var _matches = require("../matches");
11
- var _config = require("../config");
12
10
  var _hostComponentNames = require("../helpers/host-component-names");
13
11
  var _makeQueries = require("./makeQueries");
14
12
  const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
@@ -17,9 +15,7 @@ const getTextInputNodeByDisplayValue = (node, value, options = {}) => {
17
15
  normalizer
18
16
  } = options;
19
17
  const nodeValue = node.props.value !== undefined ? node.props.value : node.props.defaultValue;
20
- const shouldReturnHostTextInput = (0, _config.getConfig)().useBreakingChanges;
21
- const textInputType = shouldReturnHostTextInput ? (0, _hostComponentNames.getHostComponentNames)().textInput : _reactNative.TextInput;
22
- return (0, _filterNodeByType.filterNodeByType)(node, textInputType) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
18
+ return (0, _filterNodeByType.filterNodeByType)(node, (0, _hostComponentNames.getHostComponentNames)().textInput) && (0, _matches.matches)(value, nodeValue, normalizer, exact);
23
19
  };
24
20
  const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
25
21
  return (0, _findAll.findAll)(instance, node => getTextInputNodeByDisplayValue(node, displayValue, queryOptions), queryOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"displayValue.js","names":["getTextInputNodeByDisplayValue","node","value","options","exact","normalizer","nodeValue","props","undefined","defaultValue","shouldReturnHostTextInput","getConfig","useBreakingChanges","textInputType","getHostComponentNames","textInput","TextInput","filterNodeByType","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 { getConfig } from '../config';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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 const shouldReturnHostTextInput = getConfig().useBreakingChanges;\n const textInputType = shouldReturnHostTextInput\n ? getHostComponentNames().textInput\n : TextInput;\n\n return (\n filterNodeByType(node, textInputType) &&\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(inst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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","getHostComponentNames","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 { filterNodeByType } from '../helpers/filterNodeByType';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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\n return (\n filterNodeByType(node, getHostComponentNames().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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CAAC;AAAC"}
@@ -4,10 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByPlaceholderTextQueries = void 0;
7
- var _reactNative = require("react-native");
8
7
  var _findAll = require("../helpers/findAll");
9
8
  var _matches = require("../matches");
10
- var _config = require("../config");
11
9
  var _filterNodeByType = require("../helpers/filterNodeByType");
12
10
  var _hostComponentNames = require("../helpers/host-component-names");
13
11
  var _makeQueries = require("./makeQueries");
@@ -16,9 +14,7 @@ const getTextInputNodeByPlaceholderText = (node, placeholder, options = {}) => {
16
14
  exact,
17
15
  normalizer
18
16
  } = options;
19
- const shouldReturnHostTextInput = (0, _config.getConfig)().useBreakingChanges;
20
- const textInputType = shouldReturnHostTextInput ? (0, _hostComponentNames.getHostComponentNames)().textInput : _reactNative.TextInput;
21
- return (0, _filterNodeByType.filterNodeByType)(node, textInputType) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
17
+ return (0, _filterNodeByType.filterNodeByType)(node, (0, _hostComponentNames.getHostComponentNames)().textInput) && (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
22
18
  };
23
19
  const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
24
20
  return (0, _findAll.findAll)(instance, node => getTextInputNodeByPlaceholderText(node, placeholder, queryOptions), queryOptions);
@@ -1 +1 @@
1
- {"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","shouldReturnHostTextInput","getConfig","useBreakingChanges","textInputType","getHostComponentNames","textInput","TextInput","filterNodeByType","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 { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { getConfig } from '../config';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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 const shouldReturnHostTextInput = getConfig().useBreakingChanges;\n const textInputType = shouldReturnHostTextInput\n ? getHostComponentNames().textInput\n : TextInput;\n\n return (\n filterNodeByType(node, textInputType) &&\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;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,MAAMG,yBAAyB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAChE,MAAMC,aAAa,GAAGH,yBAAyB,GAC3C,IAAAI,yCAAqB,GAAE,CAACC,SAAS,GACjCC,sBAAS;EAEb,OACE,IAAAC,kCAAgB,EAACZ,IAAI,EAAEQ,aAAa,CAAC,IACrC,IAAAK,gBAAO,EAACZ,WAAW,EAAED,IAAI,CAACc,KAAK,CAACb,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMY,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAAChB,WAAW,EAAEiB,YAAY,EAAE;EAC1D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPhB,IAAI,IACHD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEiB,YAAY,CAAC,EACpEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAInB,WAAsB,IAC7C,6CAA4CoB,MAAM,CAACpB,WAAW,CAAE,GAAE;AACrE,MAAMqB,eAAe,GAAIrB,WAAsB,IAC5C,+CAA8CoB,MAAM,CAACpB,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEsB,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
+ {"version":3,"file":"placeholderText.js","names":["getTextInputNodeByPlaceholderText","node","placeholder","options","exact","normalizer","filterNodeByType","getHostComponentNames","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 { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { getHostComponentNames } from '../helpers/host-component-names';\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\n return (\n filterNodeByType(node, getHostComponentNames().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;EAErC,OACE,IAAAG,kCAAgB,EAACL,IAAI,EAAE,IAAAM,yCAAqB,GAAE,CAACC,SAAS,CAAC,IACzD,IAAAC,gBAAO,EAACP,WAAW,EAAED,IAAI,CAACS,KAAK,CAACR,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AAEnE,CAAC;AAED,MAAMO,yBAAyB,GAC7BC,QAA2B,IAK3B,SAASC,uBAAuB,CAACX,WAAW,EAAEY,YAAY,EAAE;EAC1D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPX,IAAI,IACHD,iCAAiC,CAACC,IAAI,EAAEC,WAAW,EAAEY,YAAY,CAAC,EACpEA,YAAY,CACb;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAId,WAAsB,IAC7C,6CAA4Ce,MAAM,CAACf,WAAW,CAAE,GAAE;AACrE,MAAMgB,eAAe,GAAIhB,WAAsB,IAC5C,+CAA8Ce,MAAM,CAACf,WAAW,CAAE,EAAC;AAEtE,MAAM;EAAEiB,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"}
@@ -10,7 +10,6 @@ var _accessibilityState = require("../helpers/matchers/accessibilityState");
10
10
  var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
11
11
  var _matchStringProp = require("../helpers/matchers/matchStringProp");
12
12
  var _within = require("../within");
13
- var _config = require("../config");
14
13
  var _makeQueries = require("./makeQueries");
15
14
  const matchAccessibleNameIfNeeded = (node, name) => {
16
15
  if (name == null) return true;
@@ -27,10 +26,9 @@ const matchAccessibilityValueIfNeeded = (node, value) => {
27
26
  return value != null ? (0, _accessibilityValue.matchAccessibilityValue)(node, value) : true;
28
27
  };
29
28
  const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
30
- const shouldMatchOnlyAccessibilityElements = (0, _config.getConfig)().useBreakingChanges;
31
29
  return (0, _findAll.findAll)(instance, node =>
32
30
  // run the cheapest checks first, and early exit to avoid unneeded computations
33
- typeof node.type === 'string' && (!shouldMatchOnlyAccessibilityElements || (0, _accessiblity.isAccessibilityElement)(node)) && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
31
+ typeof node.type === 'string' && (0, _accessiblity.isAccessibilityElement)(node) && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
34
32
  };
35
33
  const formatQueryParams = (role, options = {}) => {
36
34
  const params = [`role: "${String(role)}"`];
@@ -1 +1 @@
1
- {"version":3,"file":"role.js","names":["matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","shouldMatchOnlyAccessibilityElements","getConfig","useBreakingChanges","findAll","type","isAccessibilityElement","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 isAccessibilityElement,\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 { getConfig } from '../config';\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 const shouldMatchOnlyAccessibilityElements = getConfig().useBreakingChanges;\n\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n typeof node.type === 'string' &&\n (!shouldMatchOnlyAccessibilityElements ||\n isAccessibilityElement(node)) &&\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;AAKA;AACA;AACA;AAIA;AAEA;AACA;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,MAAMS,oCAAoC,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;EAE3E,OAAO,IAAAC,gBAAO,EACZN,QAAQ,EACPb,IAAI;EACH;EACA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AAgB,GAAG,CAACrB,IAAe,EAAER,OAAuB,KAC/D,gCAA+BkB,iBAAiB,CAACV,IAAI,EAAER,OAAO,CAAE,EAAC;AAEpE,MAAM8B,eAAe,GAAG,CAACtB,IAAe,EAAER,OAAuB,KAC9D,kCAAiCkB,iBAAiB,CAACV,IAAI,EAAER,OAAO,CAAE,EAAC;AAEtE,MAAM;EAAE+B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EhC,cAAc,EACdyB,eAAe,EACfD,gBAAgB,CACjB;AAWM,MAAMS,iBAAiB,GAC5BhC,QAA2B,KACR;EACnBiC,SAAS,EAAER,KAAK,CAACzB,QAAQ,CAAC;EAC1BkC,YAAY,EAAER,QAAQ,CAAC1B,QAAQ,CAAC;EAChCmC,WAAW,EAAER,OAAO,CAAC3B,QAAQ,CAAC;EAC9BD,cAAc,EAAE6B,UAAU,CAAC5B,QAAQ,CAAC;EACpCoC,UAAU,EAAEP,MAAM,CAAC7B,QAAQ,CAAC;EAC5BqC,aAAa,EAAEP,SAAS,CAAC9B,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","isAccessibilityElement","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 isAccessibilityElement,\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 to avoid unneeded computations\n typeof node.type === 'string' &&\n isAccessibilityElement(node) &&\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;AAKA;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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AU,EAAEP,MAAM,CAAC1B,QAAQ,CAAC;EAC5BkC,aAAa,EAAEP,SAAS,CAAC3B,QAAQ;AACnC,CAAC,CAAC;AAAC"}
@@ -4,31 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.bindByTextQueries = void 0;
7
- var _reactNative = require("react-native");
8
- var _config = require("../config");
9
- var _componentTree = require("../helpers/component-tree");
10
7
  var _filterNodeByType = require("../helpers/filterNodeByType");
11
8
  var _findAll = require("../helpers/findAll");
12
9
  var _hostComponentNames = require("../helpers/host-component-names");
13
10
  var _matchTextContent = require("../helpers/matchers/matchTextContent");
14
11
  var _makeQueries = require("./makeQueries");
15
12
  const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
16
- const shouldReturnHostText = (0, _config.getConfig)().useBreakingChanges;
17
-
18
- // Legacy version: return composite Text
19
- if (!shouldReturnHostText) {
20
- const baseInstance = (0, _componentTree.isHostElementForType)(instance, _reactNative.Text) ? (0, _componentTree.getCompositeParentOfType)(instance, _reactNative.Text) : instance;
21
- if (!baseInstance) {
22
- return [];
23
- }
24
- const results = (0, _findAll.findAll)(baseInstance, node => (0, _filterNodeByType.filterNodeByType)(node, _reactNative.Text) && (0, _matchTextContent.matchTextContent)(node, text, options), {
25
- ...options,
26
- matchDeepestOnly: true
27
- });
28
- return results;
29
- }
30
-
31
- // vNext version: returns host Text
32
13
  return (0, _findAll.findAll)(instance, node => (0, _filterNodeByType.filterNodeByType)(node, (0, _hostComponentNames.getHostComponentNames)().text) && (0, _matchTextContent.matchTextContent)(node, text, options), {
33
14
  ...options,
34
15
  matchDeepestOnly: true
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["queryAllByText","instance","queryAllByTextFn","text","options","shouldReturnHostText","getConfig","useBreakingChanges","baseInstance","isHostElementForType","Text","getCompositeParentOfType","results","findAll","node","filterNodeByType","matchTextContent","matchDeepestOnly","getHostComponentNames","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { Text } from 'react-native';\nimport { getConfig } from '../config';\nimport {\n getCompositeParentOfType,\n isHostElementForType,\n} from '../helpers/component-tree';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { findAll } from '../helpers/findAll';\nimport { getHostComponentNames } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/matchTextContent';\nimport { 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 ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (\n instance: ReactTestInstance\n): ((text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, options = {}) {\n const shouldReturnHostText = getConfig().useBreakingChanges;\n\n // Legacy version: return composite Text\n if (!shouldReturnHostText) {\n const baseInstance = isHostElementForType(instance, Text)\n ? getCompositeParentOfType(instance, Text)\n : instance;\n\n if (!baseInstance) {\n return [];\n }\n\n const results = findAll(\n baseInstance,\n (node) =>\n filterNodeByType(node, Text) && matchTextContent(node, text, options),\n { ...options, matchDeepestOnly: true }\n );\n\n return results;\n }\n\n // vNext version: returns host Text\n return findAll(\n instance,\n (node) =>\n filterNodeByType(node, getHostComponentNames().text) &&\n matchTextContent(node, text, options),\n {\n ...options,\n matchDeepestOnly: true,\n }\n );\n };\n\nconst getMultipleError = (text: TextMatch) =>\n `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) =>\n `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (\n instance: ReactTestInstance\n): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AAIA;AACA;AACA;AACA;AAEA;AAaA,MAAMA,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,MAAMC,oBAAoB,GAAG,IAAAC,iBAAS,GAAE,CAACC,kBAAkB;;EAE3D;EACA,IAAI,CAACF,oBAAoB,EAAE;IACzB,MAAMG,YAAY,GAAG,IAAAC,mCAAoB,EAACR,QAAQ,EAAES,iBAAI,CAAC,GACrD,IAAAC,uCAAwB,EAACV,QAAQ,EAAES,iBAAI,CAAC,GACxCT,QAAQ;IAEZ,IAAI,CAACO,YAAY,EAAE;MACjB,OAAO,EAAE;IACX;IAEA,MAAMI,OAAO,GAAG,IAAAC,gBAAO,EACrBL,YAAY,EACXM,IAAI,IACH,IAAAC,kCAAgB,EAACD,IAAI,EAAEJ,iBAAI,CAAC,IAAI,IAAAM,kCAAgB,EAACF,IAAI,EAAEX,IAAI,EAAEC,OAAO,CAAC,EACvE;MAAE,GAAGA,OAAO;MAAEa,gBAAgB,EAAE;IAAK,CAAC,CACvC;IAED,OAAOL,OAAO;EAChB;;EAEA;EACA,OAAO,IAAAC,gBAAO,EACZZ,QAAQ,EACPa,IAAI,IACH,IAAAC,kCAAgB,EAACD,IAAI,EAAE,IAAAI,yCAAqB,GAAE,CAACf,IAAI,CAAC,IACpD,IAAAa,kCAAgB,EAACF,IAAI,EAAEX,IAAI,EAAEC,OAAO,CAAC,EACvC;IACE,GAAGA,OAAO;IACVa,gBAAgB,EAAE;EACpB,CAAC,CACF;AACH,CAAC;AAEH,MAAME,gBAAgB,GAAIhB,IAAe,IACtC,sCAAqCiB,MAAM,CAACjB,IAAI,CAAE,EAAC;AAEtD,MAAMkB,eAAe,GAAIlB,IAAe,IACrC,wCAAuCiB,MAAM,CAACjB,IAAI,CAAE,EAAC;AAExD,MAAM;EAAEmB,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E5B,cAAc,EACdqB,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,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
+ {"version":3,"file":"text.js","names":["queryAllByText","instance","queryAllByTextFn","text","options","findAll","node","filterNodeByType","getHostComponentNames","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { filterNodeByType } from '../helpers/filterNodeByType';\nimport { findAll } from '../helpers/findAll';\nimport { getHostComponentNames } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/matchTextContent';\nimport { 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 ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (\n instance: ReactTestInstance\n): ((text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>) =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(\n instance,\n (node) =>\n filterNodeByType(node, getHostComponentNames().text) &&\n matchTextContent(node, text, options),\n {\n ...options,\n matchDeepestOnly: true,\n }\n );\n };\n\nconst getMultipleError = (text: TextMatch) =>\n `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) =>\n `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (\n instance: ReactTestInstance\n): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AAEA;AAaA,MAAMA,cAAc,GAClBC,QAA2B,IAE3B,SAASC,gBAAgB,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EACZJ,QAAQ,EACPK,IAAI,IACH,IAAAC,kCAAgB,EAACD,IAAI,EAAE,IAAAE,yCAAqB,GAAE,CAACL,IAAI,CAAC,IACpD,IAAAM,kCAAgB,EAACH,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EACvC;IACE,GAAGA,OAAO;IACVM,gBAAgB,EAAE;EACpB,CAAC,CACF;AACH,CAAC;AAEH,MAAMC,gBAAgB,GAAIR,IAAe,IACtC,sCAAqCS,MAAM,CAACT,IAAI,CAAE,EAAC;AAEtD,MAAMU,eAAe,GAAIV,IAAe,IACrC,wCAAuCS,MAAM,CAACT,IAAI,CAAE,EAAC;AAExD,MAAM;EAAEW,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EpB,cAAc,EACda,eAAe,EACfF,gBAAgB,CACjB;AAWM,MAAMU,iBAAiB,GAC5BpB,QAA2B,KACR;EACnBqB,SAAS,EAAER,KAAK,CAACb,QAAQ,CAAC;EAC1BsB,YAAY,EAAER,QAAQ,CAACd,QAAQ,CAAC;EAChCuB,WAAW,EAAER,OAAO,CAACf,QAAQ,CAAC;EAC9BD,cAAc,EAAEiB,UAAU,CAAChB,QAAQ,CAAC;EACpCwB,UAAU,EAAEP,MAAM,CAACjB,QAAQ,CAAC;EAC5ByB,aAAa,EAAEP,SAAS,CAAClB,QAAQ;AACnC,CAAC,CAAC;AAAC"}
package/build/render.d.ts CHANGED
@@ -14,10 +14,12 @@ export type RenderResult = ReturnType<typeof render>;
14
14
  export default function render<T>(component: React.ReactElement<T>, { wrapper: Wrapper, createNodeMock, unstable_validateStringsRenderedWithinText, }?: RenderOptions): {
15
15
  update: (component: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => void;
16
16
  unmount: () => void;
17
- container: TestRenderer.ReactTestInstance;
18
17
  rerender: (component: React.ReactElement<any, string | React.JSXElementConstructor<any>>) => void;
19
18
  toJSON: () => TestRenderer.ReactTestRendererJSON | TestRenderer.ReactTestRendererJSON[] | null;
20
19
  debug: DebugFunction;
20
+ root: TestRenderer.ReactTestInstance;
21
+ UNSAFE_root: TestRenderer.ReactTestInstance;
22
+ container: TestRenderer.ReactTestInstance;
21
23
  UNSAFE_getByProps: (props: {
22
24
  [key: string]: any;
23
25
  }) => TestRenderer.ReactTestInstance;
package/build/render.js CHANGED
@@ -14,6 +14,8 @@ var _within = require("./within");
14
14
  var _screen = require("./screen");
15
15
  var _stringValidation = require("./helpers/stringValidation");
16
16
  var _config = require("./config");
17
+ var _componentTree = require("./helpers/component-tree");
18
+ var _hostComponentNames = require("./helpers/host-component-names");
17
19
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
21
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -26,6 +28,7 @@ function render(component, {
26
28
  createNodeMock,
27
29
  unstable_validateStringsRenderedWithinText
28
30
  } = {}) {
31
+ (0, _hostComponentNames.configureHostComponentNamesIfNeeded)();
29
32
  if (unstable_validateStringsRenderedWithinText) {
30
33
  return renderWithStringValidation(component, {
31
34
  wrapper: Wrapper,
@@ -70,11 +73,17 @@ function buildRenderResult(renderer, wrap) {
70
73
  ...(0, _within.getQueriesForElement)(instance),
71
74
  update,
72
75
  unmount,
73
- container: instance,
74
76
  rerender: update,
75
77
  // alias for `update`
76
78
  toJSON: renderer.toJSON,
77
- debug: debug(instance, renderer)
79
+ debug: debug(instance, renderer),
80
+ get root() {
81
+ return (0, _componentTree.getHostChildren)(instance)[0];
82
+ },
83
+ UNSAFE_root: instance,
84
+ get container() {
85
+ throw new Error("'container' property has been renamed to 'UNSAFE_root'.\n\n" + "Consider using 'root' property which returns root host element.");
86
+ }
78
87
  };
79
88
  (0, _screen.setRenderResult)(result);
80
89
  return result;
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","container","rerender","debug","setRenderResult","options","TestRenderer","create","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep, { DebugOptions } from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\nimport { getConfig } from './config';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n container: instance,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(\n instance: ReactTestInstance,\n renderer: ReactTestRenderer\n): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.'\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAqC;AAAA;AAAA;AAcrC;AACA;AACA;AACA;AACe,SAASA,MAAM,CAC5BC,SAAgC,EAChC;EACEC,OAAO,EAAEC,OAAO;EAChBC,cAAc;EACdC;AACa,CAAC,GAAG,CAAC,CAAC,EACrB;EACA,IAAIA,0CAA0C,EAAE;IAC9C,OAAOC,0BAA0B,CAACL,SAAS,EAAE;MAC3CC,OAAO,EAAEC,OAAO;MAChBC;IACF,CAAC,CAAC;EACJ;EAEA,MAAMG,IAAI,GAAIC,OAA2B,IACvCL,OAAO,gBAAG,oBAAC,OAAO,QAAEK,OAAO,CAAW,GAAGA,OAAO;EAElD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,EAAE;IAC9B,IAAIwB,IAAI,EAAE;MACR,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAEJ,YAAY,CAAC;IACtC;EACF;EACAH,SAAS,CAACS,OAAO,GAAIL,OAAgB,IAAK,IAAAM,qBAAY,EAACxB,QAAQ,EAAEkB,OAAO,CAAC;EACzE,OAAOJ,SAAS;AAClB"}
1
+ {"version":3,"file":"render.js","names":["render","component","wrapper","Wrapper","createNodeMock","unstable_validateStringsRenderedWithinText","configureHostComponentNamesIfNeeded","renderWithStringValidation","wrap","element","renderer","renderWithAct","undefined","buildRenderResult","handleRender","_","phase","validateStringsRenderedWithinText","screen","toJSON","update","updateWithAct","instance","root","unmount","act","addToCleanupQueue","result","getQueriesForElement","rerender","debug","getHostChildren","UNSAFE_root","container","Error","setRenderResult","options","TestRenderer","create","debugImpl","defaultDebugOptions","getConfig","debugOptions","message","console","warn","json","debugDeep","shallow","debugShallow"],"sources":["../src/render.tsx"],"sourcesContent":["import TestRenderer from 'react-test-renderer';\nimport type { ReactTestInstance, ReactTestRenderer } from 'react-test-renderer';\nimport * as React from 'react';\nimport { Profiler } from 'react';\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport debugShallow from './helpers/debugShallow';\nimport debugDeep, { DebugOptions } from './helpers/debugDeep';\nimport { getQueriesForElement } from './within';\nimport { setRenderResult, screen } from './screen';\nimport { validateStringsRenderedWithinText } from './helpers/stringValidation';\nimport { getConfig } from './config';\nimport { getHostChildren } from './helpers/component-tree';\nimport { configureHostComponentNamesIfNeeded } from './helpers/host-component-names';\n\nexport type RenderOptions = {\n wrapper?: React.ComponentType<any>;\n createNodeMock?: (element: React.ReactElement) => any;\n unstable_validateStringsRenderedWithinText?: boolean;\n};\n\ntype TestRendererOptions = {\n createNodeMock: (element: React.ReactElement) => any;\n};\n\nexport type RenderResult = ReturnType<typeof render>;\n\n/**\n * Renders test component deeply using react-test-renderer and exposes helpers\n * to assert on the output.\n */\nexport default function render<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n unstable_validateStringsRenderedWithinText,\n }: RenderOptions = {}\n) {\n configureHostComponentNamesIfNeeded();\n\n if (unstable_validateStringsRenderedWithinText) {\n return renderWithStringValidation(component, {\n wrapper: Wrapper,\n createNodeMock,\n });\n }\n\n const wrap = (element: React.ReactElement) =>\n Wrapper ? <Wrapper>{element}</Wrapper> : element;\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction renderWithStringValidation<T>(\n component: React.ReactElement<T>,\n {\n wrapper: Wrapper,\n createNodeMock,\n }: Omit<RenderOptions, 'unstable_validateStringsRenderedWithinText'> = {}\n) {\n const handleRender: React.ProfilerProps['onRender'] = (_, phase) => {\n if (phase === 'update') {\n validateStringsRenderedWithinText(screen.toJSON());\n }\n };\n\n const wrap = (element: React.ReactElement) => (\n <Profiler id=\"renderProfiler\" onRender={handleRender}>\n {Wrapper ? <Wrapper>{element}</Wrapper> : element}\n </Profiler>\n );\n\n const renderer = renderWithAct(\n wrap(component),\n createNodeMock ? { createNodeMock } : undefined\n );\n validateStringsRenderedWithinText(renderer.toJSON());\n\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: ReactTestRenderer,\n wrap: (element: React.ReactElement) => JSX.Element\n) {\n const update = updateWithAct(renderer, wrap);\n const instance = renderer.root;\n\n const unmount = () => {\n act(() => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(instance),\n update,\n unmount,\n rerender: update, // alias for `update`\n toJSON: renderer.toJSON,\n debug: debug(instance, renderer),\n get root() {\n return getHostChildren(instance)[0];\n },\n UNSAFE_root: instance,\n get container(): ReactTestInstance {\n throw new Error(\n \"'container' property has been renamed to 'UNSAFE_root'.\\n\\n\" +\n \"Consider using 'root' property which returns root host element.\"\n );\n },\n };\n\n setRenderResult(result);\n return result;\n}\n\nfunction renderWithAct(\n component: React.ReactElement,\n options?: TestRendererOptions\n): ReactTestRenderer {\n let renderer: ReactTestRenderer;\n\n act(() => {\n renderer = TestRenderer.create(component, options);\n });\n\n // @ts-ignore act is sync, so renderer is always initialised here\n return renderer;\n}\n\nfunction updateWithAct(\n renderer: ReactTestRenderer,\n wrap: (innerElement: React.ReactElement) => React.ReactElement\n) {\n return function (component: React.ReactElement) {\n act(() => {\n renderer.update(wrap(component));\n });\n };\n}\n\ninterface DebugFunction {\n (options?: DebugOptions | string): void;\n shallow: (message?: string) => void;\n}\n\nfunction debug(\n instance: ReactTestInstance,\n renderer: ReactTestRenderer\n): DebugFunction {\n function debugImpl(options?: DebugOptions | string) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions =\n typeof options === 'string'\n ? { ...defaultDebugOptions, message: options }\n : { ...defaultDebugOptions, ...options };\n\n if (typeof options === 'string') {\n // eslint-disable-next-line no-console\n console.warn(\n 'Using debug(\"message\") is deprecated and will be removed in future release, please use debug({ message; \"message\" }) instead.'\n );\n }\n\n const json = renderer.toJSON();\n if (json) {\n return debugDeep(json, debugOptions);\n }\n }\n debugImpl.shallow = (message?: string) => debugShallow(instance, message);\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA;AAEA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAqF;AAAA;AAAA;AAcrF;AACA;AACA;AACA;AACe,SAASA,MAAM,CAC5BC,SAAgC,EAChC;EACEC,OAAO,EAAEC,OAAO;EAChBC,cAAc;EACdC;AACa,CAAC,GAAG,CAAC,CAAC,EACrB;EACA,IAAAC,uDAAmC,GAAE;EAErC,IAAID,0CAA0C,EAAE;IAC9C,OAAOE,0BAA0B,CAACN,SAAS,EAAE;MAC3CC,OAAO,EAAEC,OAAO;MAChBC;IACF,CAAC,CAAC;EACJ;EAEA,MAAMI,IAAI,GAAIC,OAA2B,IACvCN,OAAO,gBAAG,oBAAC,OAAO,QAAEM,OAAO,CAAW,GAAGA,OA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AC5C;MAAE,GAAGI,mBAAmB;MAAE,GAAGJ;IAAQ,CAAC;IAE5C,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;MAC/B;MACAQ,OAAO,CAACC,IAAI,CACV,+HAA+H,CAChI;IACH;IAEA,MAAMC,IAAI,GAAGpC,QAAQ,CAACS,MAAM,EAAE;IAC9B,IAAI2B,IAAI,EAAE;MACR,OAAO,IAAAC,kBAAS,EAACD,IAAI,EAAEJ,YAAY,CAAC;IACtC;EACF;EACAH,SAAS,CAACS,OAAO,GAAIL,OAAgB,IAAK,IAAAM,qBAAY,EAAC3B,QAAQ,EAAEqB,OAAO,CAAC;EACzE,OAAOJ,SAAS;AAClB"}
package/build/screen.js CHANGED
@@ -18,6 +18,12 @@ const defaultScreen = {
18
18
  get container() {
19
19
  throw new Error(SCREEN_ERROR);
20
20
  },
21
+ get root() {
22
+ throw new Error(SCREEN_ERROR);
23
+ },
24
+ get UNSAFE_root() {
25
+ throw new Error(SCREEN_ERROR);
26
+ },
21
27
  debug: notImplementedDebug,
22
28
  update: notImplemented,
23
29
  unmount: notImplemented,
@@ -1 +1 @@
1
- {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","shallow","defaultScreen","container","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByA11yState","getAllByA11yState","queryByA11yState","queryAllByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState","getByA11yValue","getAllByA11yValue","queryByA11yValue","queryAllByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","setRenderResult","output","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\nnotImplementedDebug.shallow = notImplemented;\n\nconst defaultScreen: RenderResult = {\n get container(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByA11yState: notImplemented,\n getAllByA11yState: notImplemented,\n queryByA11yState: notImplemented,\n queryAllByA11yState: notImplemented,\n findByA11yState: notImplemented,\n findAllByA11yState: notImplemented,\n getByAccessibilityState: notImplemented,\n getAllByAccessibilityState: notImplemented,\n queryByAccessibilityState: notImplemented,\n queryAllByAccessibilityState: notImplemented,\n findByAccessibilityState: notImplemented,\n findAllByAccessibilityState: notImplemented,\n getByA11yValue: notImplemented,\n getAllByA11yValue: notImplemented,\n queryByA11yValue: notImplemented,\n queryAllByA11yValue: notImplemented,\n findByA11yValue: notImplemented,\n findAllByA11yValue: notImplemented,\n getByAccessibilityValue: notImplemented,\n getAllByAccessibilityValue: notImplemented,\n queryByAccessibilityValue: notImplemented,\n queryAllByAccessibilityValue: notImplemented,\n findByAccessibilityValue: notImplemented,\n findAllByAccessibilityValue: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: RenderResult = defaultScreen;\n\nexport function setRenderResult(output: RenderResult) {\n screen = output;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAAqC;AAE1D,MAAMC,cAAc,GAAG,MAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAED,MAAMG,mBAAmB,GAAG,MAAM;EAChC,MAAM,IAAID,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AACDG,mBAAmB,CAACC,OAAO,GAAGH,cAAc;AAE5C,MAAMI,aAA2B,GAAG;EAClC,IAAIC,SAAS,GAAsB;IACjC,MAAM,IAAIJ,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACDO,KAAK,EAAEJ,mBAAmB;EAC1BK,MAAM,EAAEP,cAAc;EACtBQ,OAAO,EAAER,cAAc;EACvBS,QAAQ,EAAET,cAAc;EACxBU,MAAM,EAAEV,cAAc;EACtBW,cAAc,EAAEX,cAAc;EAC9BY,iBAAiB,EAAEZ,cAAc;EACjCa,gBAAgB,EAAEb,cAAc;EAChCc,mBAAmB,EAAEd,cAAc;EACnCe,eAAe,EAAEf,cAAc;EAC/BgB,kBAAkB,EAAEhB,cAAc;EAClCiB,aAAa,EAAEjB,cAAc;EAC7BkB,gBAAgB,EAAElB,cAAc;EAChCmB,eAAe,EAAEnB,cAAc;EAC/BoB,kBAAkB,EAAEpB,cAAc;EAClCqB,cAAc,EA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AiB,GAAG;EAClC,iBAAAH,MAAM,GAAG7F,aAAa;AACxB"}
1
+ {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","shallow","defaultScreen","container","root","UNSAFE_root","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByA11yState","getAllByA11yState","queryByA11yState","queryAllByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState","getByA11yValue","getAllByA11yValue","queryByA11yValue","queryAllByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","setRenderResult","output","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\nnotImplementedDebug.shallow = notImplemented;\n\nconst defaultScreen: RenderResult = {\n get container(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get UNSAFE_root(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByA11yState: notImplemented,\n getAllByA11yState: notImplemented,\n queryByA11yState: notImplemented,\n queryAllByA11yState: notImplemented,\n findByA11yState: notImplemented,\n findAllByA11yState: notImplemented,\n getByAccessibilityState: notImplemented,\n getAllByAccessibilityState: notImplemented,\n queryByAccessibilityState: notImplemented,\n queryAllByAccessibilityState: notImplemented,\n findByAccessibilityState: notImplemented,\n findAllByAccessibilityState: notImplemented,\n getByA11yValue: notImplemented,\n getAllByA11yValue: notImplemented,\n queryByA11yValue: notImplemented,\n queryAllByA11yValue: notImplemented,\n findByA11yValue: notImplemented,\n findAllByA11yValue: notImplemented,\n getByAccessibilityValue: notImplemented,\n getAllByAccessibilityValue: notImplemented,\n queryByAccessibilityValue: notImplemented,\n queryAllByAccessibilityValue: notImplemented,\n findByAccessibilityValue: notImplemented,\n findAllByAccessibilityValue: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: RenderResult = defaultScreen;\n\nexport function setRenderResult(output: RenderResult) {\n screen = output;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAAqC;AAE1D,MAAMC,cAAc,GAAG,MAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;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C2E,oBAAoB,EAAE3E,cAAc;EACpC4E,uBAAuB,EAAE5E,cAAc;EACvC6E,sBAAsB,EAAE7E,cAAc;EACtC8E,yBAAyB,EAAE9E,cAAc;EACzC+E,qBAAqB,EAAE/E,cAAc;EACrCgF,wBAAwB,EAAEhF,cAAc;EACxCiF,iBAAiB,EAAEjF,cAAc;EACjCkF,oBAAoB,EAAElF,cAAc;EACpCmF,mBAAmB,EAAEnF,cAAc;EACnCoF,sBAAsB,EAAEpF,cAAc;EACtCqF,kBAAkB,EAAErF,cAAc;EAClCsF,qBAAqB,EAAEtF,cAAc;EACrCuF,WAAW,EAAEvF,cAAc;EAC3BwF,cAAc,EAAExF,cAAc;EAC9ByF,aAAa,EAAEzF,cAAc;EAC7B0F,gBAAgB,EAAE1F,cAAc;EAChC2F,YAAY,EAAE3F,cAAc;EAC5B4F,eAAe,EAAE5F,cAAc;EAC/B6F,SAAS,EAAE7F,cAAc;EACzB8F,YAAY,EAAE9F,cAAc;EAC5B+F,WAAW,EAAE/F,cAAc;EAC3BgG,cAAc,EAAEhG,cAAc;EAC9BiG,UAAU,EAAEjG,cAAc;EAC1BkG,aAAa,EAAElG;AACjB,CAAC;AAEM,IAAImG,MAAoB,GAAG/F,aAAa;AAAC;AAEzC,SAASgG,eAAe,CAACC,MAAoB,EAAE;EACpD,iBAAAF,MAAM,GAAGE,MAAM;AACjB;AAEO,SAASC,iBAAiB,GAAG;EAClC,iBAAAH,MAAM,GAAG/F,aAAa;AACxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "11.5.1",
3
+ "version": "12.0.0-rc.0",
4
4
  "description": "Simple and complete React Native testing utilities that encourage good testing practices.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -10,6 +10,12 @@
10
10
  },
11
11
  "homepage": "https://callstack.github.io/react-native-testing-library",
12
12
  "author": "Michał Pierzchała <thymikee@gmail.com>",
13
+ "contributors": [
14
+ "Maciej Jastrzębski <mdjastrzebski@gmail.com> (https://github.com/mdjastrzebski)",
15
+ "Augustin Le Fèvre <augustin.le-fevre@klarna.com> (https://github.com/AugustinLF)",
16
+ "Pierre Zimmermann <pierrez@nam.tech> (https://github.com/pierrezimmermannbam)",
17
+ "MattAgn <matthieua@bam.tech> (https://github.com/MattAgn)"
18
+ ],
13
19
  "license": "MIT",
14
20
  "private": false,
15
21
  "keywords": [
@@ -48,13 +54,13 @@
48
54
  "flow-copy-source": "^2.0.9",
49
55
  "jest": "^29.4.0",
50
56
  "react": "18.2.0",
51
- "react-native": "0.71.1",
57
+ "react-native": "0.71.3",
52
58
  "react-test-renderer": "18.2.0",
53
59
  "strip-ansi": "^6.0.0",
54
60
  "typescript": "^4.0.2"
55
61
  },
56
62
  "dependencies": {
57
- "pretty-format": "^29.4.0"
63
+ "pretty-format": "^29.0.0"
58
64
  },
59
65
  "peerDependencies": {
60
66
  "jest": ">=28.0.0",
@@ -436,7 +436,8 @@ declare module '@testing-library/react-native' {
436
436
  unmount(nextElement?: React.Element<any>): void;
437
437
  toJSON(): ReactTestRendererJSON[] | ReactTestRendererJSON | null;
438
438
  debug: Debug;
439
- container: ReactTestInstance;
439
+ root: ReactTestInstance;
440
+ UNSAFE_root: ReactTestInstance;
440
441
  }
441
442
 
442
443
  declare type RenderAPI = RenderResult;