@testing-library/react-native 11.2.0 → 11.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +3 -0
  2. package/build/act.js +9 -15
  3. package/build/act.js.map +1 -1
  4. package/build/cleanup.js +0 -4
  5. package/build/cleanup.js.map +1 -1
  6. package/build/config.d.ts +15 -0
  7. package/build/config.js +27 -0
  8. package/build/config.js.map +1 -0
  9. package/build/fireEvent.js +3 -33
  10. package/build/fireEvent.js.map +1 -1
  11. package/build/flushMicroTasks.js +0 -3
  12. package/build/flushMicroTasks.js.map +1 -1
  13. package/build/helpers/accessiblity.d.ts +3 -0
  14. package/build/helpers/accessiblity.js +14 -20
  15. package/build/helpers/accessiblity.js.map +1 -1
  16. package/build/helpers/component-tree.d.ts +15 -0
  17. package/build/helpers/component-tree.js +49 -15
  18. package/build/helpers/component-tree.js.map +1 -1
  19. package/build/helpers/debugDeep.d.ts +5 -1
  20. package/build/helpers/debugDeep.js +7 -6
  21. package/build/helpers/debugDeep.js.map +1 -1
  22. package/build/helpers/debugShallow.js +0 -5
  23. package/build/helpers/debugShallow.js.map +1 -1
  24. package/build/helpers/errors.js +4 -25
  25. package/build/helpers/errors.js.map +1 -1
  26. package/build/helpers/filterNodeByType.js +0 -2
  27. package/build/helpers/filterNodeByType.js.map +1 -1
  28. package/build/helpers/format.d.ts +5 -1
  29. package/build/helpers/format.js +17 -7
  30. package/build/helpers/format.js.map +1 -1
  31. package/build/helpers/matchers/accessibilityState.d.ts +3 -0
  32. package/build/helpers/matchers/accessibilityState.js +28 -0
  33. package/build/helpers/matchers/accessibilityState.js.map +1 -0
  34. package/build/helpers/matchers/matchArrayProp.js +0 -3
  35. package/build/helpers/matchers/matchArrayProp.js.map +1 -1
  36. package/build/helpers/matchers/matchObjectProp.js +0 -2
  37. package/build/helpers/matchers/matchObjectProp.js.map +1 -1
  38. package/build/helpers/matchers/matchStringProp.js +0 -3
  39. package/build/helpers/matchers/matchStringProp.js.map +1 -1
  40. package/build/helpers/stringValidation.js +0 -7
  41. package/build/helpers/stringValidation.js.map +1 -1
  42. package/build/helpers/timers.js +11 -22
  43. package/build/helpers/timers.js.map +1 -1
  44. package/build/index.flow.js +74 -21
  45. package/build/index.js +0 -6
  46. package/build/index.js.map +1 -1
  47. package/build/matches.js +2 -4
  48. package/build/matches.js.map +1 -1
  49. package/build/pure.d.ts +2 -0
  50. package/build/pure.js +13 -12
  51. package/build/pure.js.map +1 -1
  52. package/build/queries/a11yState.d.ts +1 -1
  53. package/build/queries/a11yState.js +15 -13
  54. package/build/queries/a11yState.js.map +1 -1
  55. package/build/queries/a11yValue.js +0 -8
  56. package/build/queries/a11yValue.js.map +1 -1
  57. package/build/queries/displayValue.js +7 -26
  58. package/build/queries/displayValue.js.map +1 -1
  59. package/build/queries/hintText.d.ts +19 -18
  60. package/build/queries/hintText.js +10 -11
  61. package/build/queries/hintText.js.map +1 -1
  62. package/build/queries/labelText.d.ts +7 -6
  63. package/build/queries/labelText.js +10 -11
  64. package/build/queries/labelText.js.map +1 -1
  65. package/build/queries/makeQueries.d.ts +3 -3
  66. package/build/queries/makeQueries.js +40 -24
  67. package/build/queries/makeQueries.js.map +1 -1
  68. package/build/queries/placeholderText.js +6 -25
  69. package/build/queries/placeholderText.js.map +1 -1
  70. package/build/queries/role.d.ts +3 -2
  71. package/build/queries/role.js +23 -13
  72. package/build/queries/role.js.map +1 -1
  73. package/build/queries/testId.js +0 -9
  74. package/build/queries/testId.js.map +1 -1
  75. package/build/queries/text.js +21 -45
  76. package/build/queries/text.js.map +1 -1
  77. package/build/queries/unsafeProps.js +2 -11
  78. package/build/queries/unsafeProps.js.map +1 -1
  79. package/build/queries/unsafeType.js +2 -9
  80. package/build/queries/unsafeType.js.map +1 -1
  81. package/build/react-versions.js +0 -4
  82. package/build/react-versions.js.map +1 -1
  83. package/build/render.d.ts +32 -31
  84. package/build/render.js +21 -31
  85. package/build/render.js.map +1 -1
  86. package/build/renderHook.js +2 -12
  87. package/build/renderHook.js.map +1 -1
  88. package/build/screen.js +0 -6
  89. package/build/screen.js.map +1 -1
  90. package/build/shallow.js +0 -6
  91. package/build/shallow.js.map +1 -1
  92. package/build/waitFor.js +31 -53
  93. package/build/waitFor.js.map +1 -1
  94. package/build/waitForElementToBeRemoved.js +2 -11
  95. package/build/waitForElementToBeRemoved.js.map +1 -1
  96. package/build/within.d.ts +30 -30
  97. package/build/within.js +2 -14
  98. package/build/within.js.map +1 -1
  99. package/package.json +18 -17
  100. package/typings/index.flow.js +74 -21
package/README.md CHANGED
@@ -12,6 +12,7 @@
12
12
  [![Version][version-badge]][package]
13
13
  [![PRs Welcome][prs-welcome-badge]][prs-welcome]
14
14
  [![Chat][chat-badge]][chat]
15
+ [![codecov][codecov-badge]][codecov]
15
16
  [![Sponsored by Callstack][callstack-badge]][callstack]
16
17
 
17
18
  ## The problem
@@ -171,3 +172,5 @@ Supported and used by [Rally Health](https://www.rallyhealth.com/careers-home).
171
172
  [chat]: https://discord.gg/QbGezWe
172
173
  [callstack-badge]: https://callstack.com/images/callstack-badge.svg
173
174
  [callstack]: https://callstack.com/open-source/?utm_source=github.com&utm_medium=referral&utm_campaign=react-native-testing-library&utm_term=readme
175
+ [codecov-badge]: https://codecov.io/gh/callstack/react-native-testing-library/branch/main/graph/badge.svg?token=tYVSWro1IP
176
+ [codecov]: https://codecov.io/gh/callstack/react-native-testing-library
package/build/act.js CHANGED
@@ -6,52 +6,49 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.default = void 0;
7
7
  exports.getIsReactActEnvironment = getIsReactActEnvironment;
8
8
  exports.setReactActEnvironment = setIsReactActEnvironment;
9
-
10
9
  var _reactTestRenderer = require("react-test-renderer");
11
-
12
10
  var _reactVersions = require("./react-versions");
13
-
14
11
  // This file and the act() implementation is sourced from react-testing-library
15
12
  // https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js
13
+
16
14
  const actMock = callback => {
17
15
  callback();
18
- }; // See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
16
+ };
19
17
 
18
+ // See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
20
19
 
21
20
  function setIsReactActEnvironment(isReactActEnvironment) {
22
21
  globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
23
22
  }
24
-
25
23
  function getIsReactActEnvironment() {
26
24
  return globalThis.IS_REACT_ACT_ENVIRONMENT;
27
25
  }
28
-
29
26
  function withGlobalActEnvironment(actImplementation) {
30
27
  return callback => {
31
28
  const previousActEnvironment = getIsReactActEnvironment();
32
- setIsReactActEnvironment(true); // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do
29
+ setIsReactActEnvironment(true);
33
30
 
31
+ // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do
34
32
  try {
35
33
  // The return value of `act` is always a thenable.
36
34
  let callbackNeedsToBeAwaited = false;
37
35
  const actResult = actImplementation(() => {
38
36
  const result = callback();
39
-
40
- if (result !== null && typeof result === 'object' && // @ts-expect-error this should be a promise or thenable
37
+ if (result !== null && typeof result === 'object' &&
38
+ // @ts-expect-error this should be a promise or thenable
41
39
  // eslint-disable-next-line promise/prefer-await-to-then
42
40
  typeof result.then === 'function') {
43
41
  callbackNeedsToBeAwaited = true;
44
42
  }
45
-
46
43
  return result;
47
44
  });
48
-
49
45
  if (callbackNeedsToBeAwaited) {
50
46
  const thenable = actResult;
51
47
  return {
52
48
  then: (resolve, reject) => {
53
49
  // eslint-disable-next-line
54
- thenable.then( // eslint-disable-next-line promise/always-return
50
+ thenable.then(
51
+ // eslint-disable-next-line promise/always-return
55
52
  returnValue => {
56
53
  setIsReactActEnvironment(previousActEnvironment);
57
54
  resolve(returnValue);
@@ -73,15 +70,12 @@ function withGlobalActEnvironment(actImplementation) {
73
70
  }
74
71
  };
75
72
  }
76
-
77
73
  const getAct = () => {
78
74
  if (!_reactTestRenderer.act) {
79
75
  return actMock;
80
76
  }
81
-
82
77
  return (0, _reactVersions.checkReactVersionAtLeast)(18, 0) ? withGlobalActEnvironment(_reactTestRenderer.act) : _reactTestRenderer.act;
83
78
  };
84
-
85
79
  const act = getAct();
86
80
  var _default = act;
87
81
  exports.default = _default;
package/build/act.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"act.js","names":["actMock","callback","setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","getAct","reactTestRendererAct","checkReactVersionAtLeast","act"],"sources":["../src/act.ts"],"sourcesContent":["// This file and the act() implementation is sourced from react-testing-library\n// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js\nimport { act as reactTestRendererAct } from 'react-test-renderer';\nimport { checkReactVersionAtLeast } from './react-versions';\n\nconst actMock = (callback: () => void) => {\n callback();\n};\n\n// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\nfunction setIsReactActEnvironment(isReactActEnvironment: boolean | undefined) {\n globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;\n}\n\nfunction getIsReactActEnvironment() {\n return globalThis.IS_REACT_ACT_ENVIRONMENT;\n}\n\ntype Act = typeof reactTestRendererAct;\n\nfunction withGlobalActEnvironment(actImplementation: Act) {\n return (callback: Parameters<Act>[0]) => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(true);\n\n // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do\n try {\n // The return value of `act` is always a thenable.\n let callbackNeedsToBeAwaited = false;\n const actResult = actImplementation(() => {\n const result = callback();\n if (\n result !== null &&\n typeof result === 'object' &&\n // @ts-expect-error this should be a promise or thenable\n // eslint-disable-next-line promise/prefer-await-to-then\n typeof result.then === 'function'\n ) {\n callbackNeedsToBeAwaited = true;\n }\n return result;\n });\n if (callbackNeedsToBeAwaited) {\n const thenable = actResult;\n return {\n then: (\n resolve: (value: never) => never,\n reject: (value: never) => never\n ) => {\n // eslint-disable-next-line\n thenable.then(\n // eslint-disable-next-line promise/always-return\n (returnValue) => {\n setIsReactActEnvironment(previousActEnvironment);\n resolve(returnValue);\n },\n (error) => {\n setIsReactActEnvironment(previousActEnvironment);\n reject(error);\n }\n );\n },\n };\n } else {\n setIsReactActEnvironment(previousActEnvironment);\n return actResult;\n }\n } catch (error) {\n // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT\n // or if we have to await the callback first.\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n };\n}\nconst getAct = () => {\n if (!reactTestRendererAct) {\n return actMock;\n }\n\n return checkReactVersionAtLeast(18, 0)\n ? withGlobalActEnvironment(reactTestRendererAct)\n : reactTestRendererAct;\n};\nconst act = getAct();\n\nexport default act;\nexport {\n setIsReactActEnvironment as setReactActEnvironment,\n getIsReactActEnvironment,\n};\n"],"mappings":";;;;;;;;;AAEA;;AACA;;AAHA;AACA;AAIA,MAAMA,OAAO,GAAIC,QAAD,IAA0B;EACxCA,QAAQ;AACT,CAFD,C,CAIA;;;AAKA,SAASC,wBAAT,CAAkCC,qBAAlC,EAA8E;EAC5EC,UAAU,CAACC,wBAAX,GAAsCF,qBAAtC;AACD;;AAED,SAASG,wBAAT,GAAoC;EAClC,OAAOF,UAAU,CAACC,wBAAlB;AACD;;AAID,SAASE,wBAAT,CAAkCC,iBAAlC,EAA0D;EACxD,OAAQP,QAAD,IAAkC;IACvC,MAAMQ,sBAAsB,GAAGH,wBAAwB,EAAvD;IACAJ,wBAAwB,CAAC,IAAD,CAAxB,CAFuC,CAIvC;;IACA,IAAI;MACF;MACA,IAAIQ,wBAAwB,GAAG,KAA/B;MACA,MAAMC,SAAS,GAAGH,iBAAiB,CAAC,MAAM;QACxC,MAAMI,MAAM,GAAGX,QAAQ,EAAvB;;QACA,IACEW,MAAM,KAAK,IAAX,IACA,OAAOA,MAAP,KAAkB,QADlB,IAEA;QACA;QACA,OAAOA,MAAM,CAACC,IAAd,KAAuB,UALzB,EAME;UACAH,wBAAwB,GAAG,IAA3B;QACD;;QACD,OAAOE,MAAP;MACD,CAZkC,CAAnC;;MAaA,IAAIF,wBAAJ,EAA8B;QAC5B,MAAMI,QAAQ,GAAGH,SAAjB;QACA,OAAO;UACLE,IAAI,EAAE,CACJE,OADI,EAEJC,MAFI,KAGD;YACH;YACAF,QAAQ,CAACD,IAAT,EACE;YACCI,WAAD,IAAiB;cACff,wBAAwB,CAACO,sBAAD,CAAxB;cACAM,OAAO,CAACE,WAAD,CAAP;YACD,CALH,EAMGC,KAAD,IAAW;cACThB,wBAAwB,CAACO,sBAAD,CAAxB;cACAO,MAAM,CAACE,KAAD,CAAN;YACD,CATH;UAWD;QAjBI,CAAP;MAmBD,CArBD,MAqBO;QACLhB,wBAAwB,CAACO,sBAAD,CAAxB;QACA,OAAOE,SAAP;MACD;IACF,CAzCD,CAyCE,OAAOO,KAAP,EAAc;MACd;MACA;MACAhB,wBAAwB,CAACO,sBAAD,CAAxB;MACA,MAAMS,KAAN;IACD;EACF,CApDD;AAqDD;;AACD,MAAMC,MAAM,GAAG,MAAM;EACnB,IAAI,CAACC,sBAAL,EAA2B;IACzB,OAAOpB,OAAP;EACD;;EAED,OAAO,IAAAqB,uCAAA,EAAyB,EAAzB,EAA6B,CAA7B,IACHd,wBAAwB,CAACa,sBAAD,CADrB,GAEHA,sBAFJ;AAGD,CARD;;AASA,MAAME,GAAG,GAAGH,MAAM,EAAlB;eAEeG,G"}
1
+ {"version":3,"file":"act.js","names":["actMock","callback","setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","getAct","reactTestRendererAct","checkReactVersionAtLeast","act"],"sources":["../src/act.ts"],"sourcesContent":["// This file and the act() implementation is sourced from react-testing-library\n// https://github.com/testing-library/react-testing-library/blob/c80809a956b0b9f3289c4a6fa8b5e8cc72d6ef6d/src/act-compat.js\nimport { act as reactTestRendererAct } from 'react-test-renderer';\nimport { checkReactVersionAtLeast } from './react-versions';\n\nconst actMock = (callback: () => void) => {\n callback();\n};\n\n// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\nfunction setIsReactActEnvironment(isReactActEnvironment: boolean | undefined) {\n globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;\n}\n\nfunction getIsReactActEnvironment() {\n return globalThis.IS_REACT_ACT_ENVIRONMENT;\n}\n\ntype Act = typeof reactTestRendererAct;\n\nfunction withGlobalActEnvironment(actImplementation: Act) {\n return (callback: Parameters<Act>[0]) => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(true);\n\n // this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do\n try {\n // The return value of `act` is always a thenable.\n let callbackNeedsToBeAwaited = false;\n const actResult = actImplementation(() => {\n const result = callback();\n if (\n result !== null &&\n typeof result === 'object' &&\n // @ts-expect-error this should be a promise or thenable\n // eslint-disable-next-line promise/prefer-await-to-then\n typeof result.then === 'function'\n ) {\n callbackNeedsToBeAwaited = true;\n }\n return result;\n });\n if (callbackNeedsToBeAwaited) {\n const thenable = actResult;\n return {\n then: (\n resolve: (value: never) => never,\n reject: (value: never) => never\n ) => {\n // eslint-disable-next-line\n thenable.then(\n // eslint-disable-next-line promise/always-return\n (returnValue) => {\n setIsReactActEnvironment(previousActEnvironment);\n resolve(returnValue);\n },\n (error) => {\n setIsReactActEnvironment(previousActEnvironment);\n reject(error);\n }\n );\n },\n };\n } else {\n setIsReactActEnvironment(previousActEnvironment);\n return actResult;\n }\n } catch (error) {\n // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT\n // or if we have to await the callback first.\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n };\n}\nconst getAct = () => {\n if (!reactTestRendererAct) {\n return actMock;\n }\n\n return checkReactVersionAtLeast(18, 0)\n ? withGlobalActEnvironment(reactTestRendererAct)\n : reactTestRendererAct;\n};\nconst act = getAct();\n\nexport default act;\nexport {\n setIsReactActEnvironment as setReactActEnvironment,\n getIsReactActEnvironment,\n};\n"],"mappings":";;;;;;;;AAEA;AACA;AAHA;AACA;;AAIA,MAAMA,OAAO,GAAIC,QAAoB,IAAK;EACxCA,QAAQ,EAAE;AACZ,CAAC;;AAED;;AAKA,SAASC,wBAAwB,CAACC,qBAA0C,EAAE;EAC5EC,UAAU,CAACC,wBAAwB,GAAGF,qBAAqB;AAC7D;AAEA,SAASG,wBAAwB,GAAG;EAClC,OAAOF,UAAU,CAACC,wBAAwB;AAC5C;AAIA,SAASE,wBAAwB,CAACC,iBAAsB,EAAE;EACxD,OAAQP,QAA4B,IAAK;IACvC,MAAMQ,sBAAsB,GAAGH,wBAAwB,EAAE;IACzDJ,wBAAwB,CAAC,IAAI,CAAC;;IAE9B;IACA,IAAI;MACF;MACA,IAAIQ,wBAAwB,GAAG,KAAK;MACpC,MAAMC,SAAS,GAAGH,iBAAiB,CAAC,MAAM;QACxC,MAAMI,MAAM,GAAGX,QAAQ,EAAE;QACzB,IACEW,MAAM,KAAK,IAAI,IACf,OAAOA,MAAM,KAAK,QAAQ;QAC1B;QACA;QACA,OAAOA,MAAM,CAACC,IAAI,KAAK,UAAU,EACjC;UACAH,wBAAwB,GAAG,IAAI;QACjC;QACA,OAAOE,MAAM;MACf,CAAC,CAAC;MACF,IAAIF,wBAAwB,EAAE;QAC5B,MAAMI,QAAQ,GAAGH,SAAS;QAC1B,OAAO;UACLE,IAAI,EAAE,CACJE,OAAgC,EAChCC,MAA+B,KAC5B;YACH;YACAF,QAAQ,CAACD,IAAI;YACX;YACCI,WAAW,IAAK;cACff,wBAAwB,CAACO,sBAAsB,CAAC;cAChDM,OAAO,CAACE,WAAW,CAAC;YACtB,CAAC,EACAC,KAAK,IAAK;cACThB,wBAAwB,CAACO,sBAAsB,CAAC;cAChDO,MAAM,CAACE,KAAK,CAAC;YACf,CAAC,CACF;UACH;QACF,CAAC;MACH,CAAC,MAAM;QACLhB,wBAAwB,CAACO,sBAAsB,CAAC;QAChD,OAAOE,SAAS;MAClB;IACF,CAAC,CAAC,OAAOO,KAAK,EAAE;MACd;MACA;MACAhB,wBAAwB,CAACO,sBAAsB,CAAC;MAChD,MAAMS,KAAK;IACb;EACF,CAAC;AACH;AACA,MAAMC,MAAM,GAAG,MAAM;EACnB,IAAI,CAACC,sBAAoB,EAAE;IACzB,OAAOpB,OAAO;EAChB;EAEA,OAAO,IAAAqB,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,GAClCd,wBAAwB,CAACa,sBAAoB,CAAC,GAC9CA,sBAAoB;AAC1B,CAAC;AACD,MAAME,GAAG,GAAGH,MAAM,EAAE;AAAC,eAENG,GAAG;AAAA"}
package/build/cleanup.js CHANGED
@@ -5,17 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.addToCleanupQueue = addToCleanupQueue;
7
7
  exports.default = cleanup;
8
-
9
8
  var _screen = require("./screen");
10
-
11
9
  let cleanupQueue = new Set();
12
-
13
10
  function cleanup() {
14
11
  (0, _screen.clearRenderResult)();
15
12
  cleanupQueue.forEach(fn => fn());
16
13
  cleanupQueue.clear();
17
14
  }
18
-
19
15
  function addToCleanupQueue(fn) {
20
16
  cleanupQueue.add(fn);
21
17
  }
@@ -1 +1 @@
1
- {"version":3,"file":"cleanup.js","names":["cleanupQueue","Set","cleanup","clearRenderResult","forEach","fn","clear","addToCleanupQueue","add"],"sources":["../src/cleanup.ts"],"sourcesContent":["import * as React from 'react';\nimport { clearRenderResult } from './screen';\n\ntype CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;\nlet cleanupQueue = new Set<CleanUpFunction>();\n\nexport default function cleanup() {\n clearRenderResult();\n cleanupQueue.forEach((fn) => fn());\n cleanupQueue.clear();\n}\n\nexport function addToCleanupQueue(fn: CleanUpFunction) {\n cleanupQueue.add(fn);\n}\n"],"mappings":";;;;;;;;AACA;;AAGA,IAAIA,YAAY,GAAG,IAAIC,GAAJ,EAAnB;;AAEe,SAASC,OAAT,GAAmB;EAChC,IAAAC,yBAAA;EACAH,YAAY,CAACI,OAAb,CAAsBC,EAAD,IAAQA,EAAE,EAA/B;EACAL,YAAY,CAACM,KAAb;AACD;;AAEM,SAASC,iBAAT,CAA2BF,EAA3B,EAAgD;EACrDL,YAAY,CAACQ,GAAb,CAAiBH,EAAjB;AACD"}
1
+ {"version":3,"file":"cleanup.js","names":["cleanupQueue","Set","cleanup","clearRenderResult","forEach","fn","clear","addToCleanupQueue","add"],"sources":["../src/cleanup.ts"],"sourcesContent":["import * as React from 'react';\nimport { clearRenderResult } from './screen';\n\ntype CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;\nlet cleanupQueue = new Set<CleanUpFunction>();\n\nexport default function cleanup() {\n clearRenderResult();\n cleanupQueue.forEach((fn) => fn());\n cleanupQueue.clear();\n}\n\nexport function addToCleanupQueue(fn: CleanUpFunction) {\n cleanupQueue.add(fn);\n}\n"],"mappings":";;;;;;;AACA;AAGA,IAAIA,YAAY,GAAG,IAAIC,GAAG,EAAmB;AAE9B,SAASC,OAAO,GAAG;EAChC,IAAAC,yBAAiB,GAAE;EACnBH,YAAY,CAACI,OAAO,CAAEC,EAAE,IAAKA,EAAE,EAAE,CAAC;EAClCL,YAAY,CAACM,KAAK,EAAE;AACtB;AAEO,SAASC,iBAAiB,CAACF,EAAmB,EAAE;EACrDL,YAAY,CAACQ,GAAG,CAACH,EAAE,CAAC;AACtB"}
@@ -0,0 +1,15 @@
1
+ import { DebugOptions } from './helpers/debugDeep';
2
+ export declare type Config = {
3
+ /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
4
+ asyncUtilTimeout: number;
5
+ /** Default options for `debug` helper. */
6
+ defaultDebugOptions?: Partial<DebugOptions>;
7
+ };
8
+ export declare function configure(options: Partial<Config>): void;
9
+ export declare function resetToDefaults(): void;
10
+ export declare function getConfig(): {
11
+ /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
12
+ asyncUtilTimeout: number;
13
+ /** Default options for `debug` helper. */
14
+ defaultDebugOptions?: Partial<DebugOptions> | undefined;
15
+ };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.configure = configure;
7
+ exports.getConfig = getConfig;
8
+ exports.resetToDefaults = resetToDefaults;
9
+ const defaultConfig = {
10
+ asyncUtilTimeout: 1000
11
+ };
12
+ let config = {
13
+ ...defaultConfig
14
+ };
15
+ function configure(options) {
16
+ config = {
17
+ ...config,
18
+ ...options
19
+ };
20
+ }
21
+ function resetToDefaults() {
22
+ config = defaultConfig;
23
+ }
24
+ function getConfig() {
25
+ return config;
26
+ }
27
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","config","configure","options","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debugDeep';\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nconst defaultConfig: Config = {\n asyncUtilTimeout: 1000,\n};\n\nlet config = {\n ...defaultConfig,\n};\n\nexport function configure(options: Partial<Config>) {\n config = {\n ...config,\n ...options,\n };\n}\n\nexport function resetToDefaults() {\n config = defaultConfig;\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;AAUA,MAAMA,aAAqB,GAAG;EAC5BC,gBAAgB,EAAE;AACpB,CAAC;AAED,IAAIC,MAAM,GAAG;EACX,GAAGF;AACL,CAAC;AAEM,SAASG,SAAS,CAACC,OAAwB,EAAE;EAClDF,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGE;EACL,CAAC;AACH;AAEO,SAASC,eAAe,GAAG;EAChCH,MAAM,GAAGF,aAAa;AACxB;AAEO,SAASM,SAAS,GAAG;EAC1B,OAAOJ,MAAM;AACf"}
@@ -4,53 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
7
+ var _reactNative = require("react-native");
8
8
  var _act = _interopRequireDefault(require("./act"));
9
-
10
9
  var _componentTree = require("./helpers/component-tree");
11
-
12
10
  var _filterNodeByType = require("./helpers/filterNodeByType");
13
-
14
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
12
  const isTextInput = element => {
17
13
  if (!element) {
18
14
  return false;
19
15
  }
20
16
 
21
- const {
22
- TextInput
23
- } = require('react-native'); // We have to test if the element type is either the TextInput component
17
+ // We have to test if the element type is either the TextInput component
24
18
  // (which would if it is a composite component) or the string
25
19
  // TextInput (which would be true if it is a host component)
26
20
  // All queries but the one by testID return composite component and event
27
21
  // if all queries returned host components, since fireEvent bubbles up
28
22
  // it would trigger the parent prop without the composite component check
29
-
30
-
31
- return (0, _filterNodeByType.filterNodeByType)(element, TextInput) || (0, _filterNodeByType.filterNodeByType)(element, 'TextInput');
23
+ return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element, 'TextInput');
32
24
  };
33
-
34
25
  const isTouchResponder = element => {
35
26
  if (!(0, _componentTree.isHostElement)(element)) return false;
36
27
  return !!element?.props.onStartShouldSetResponder || isTextInput(element);
37
28
  };
38
-
39
29
  const isPointerEventEnabled = (element, isParent) => {
40
30
  const parentCondition = isParent ? element?.props.pointerEvents === 'box-only' : element?.props.pointerEvents === 'box-none';
41
-
42
31
  if (element?.props.pointerEvents === 'none' || parentCondition) {
43
32
  return false;
44
33
  }
45
-
46
34
  if (!element?.parent) return true;
47
35
  return isPointerEventEnabled(element.parent, true);
48
36
  };
49
-
50
37
  const isTouchEvent = eventName => {
51
38
  return eventName === 'press';
52
39
  };
53
-
54
40
  const isEventEnabled = (element, touchResponder, eventName) => {
55
41
  if (isTextInput(element)) return element?.props.editable !== false;
56
42
  if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;
@@ -59,57 +45,41 @@ const isEventEnabled = (element, touchResponder, eventName) => {
59
45
  if (touchStart || touchMove) return true;
60
46
  return touchStart === undefined && touchMove === undefined;
61
47
  };
62
-
63
48
  const findEventHandler = (element, eventName, callsite, nearestTouchResponder) => {
64
49
  const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;
65
50
  const handler = getEventHandler(element, eventName);
66
51
  if (handler && isEventEnabled(element, touchResponder, eventName)) return handler;
67
-
68
52
  if (element.parent === null || element.parent.parent === null) {
69
53
  return null;
70
54
  }
71
-
72
55
  return findEventHandler(element.parent, eventName, callsite, touchResponder);
73
56
  };
74
-
75
57
  const getEventHandler = (element, eventName) => {
76
58
  const eventHandlerName = toEventHandlerName(eventName);
77
-
78
59
  if (typeof element.props[eventHandlerName] === 'function') {
79
60
  return element.props[eventHandlerName];
80
61
  }
81
-
82
62
  if (typeof element.props[eventName] === 'function') {
83
63
  return element.props[eventName];
84
64
  }
85
-
86
65
  return undefined;
87
66
  };
88
-
89
67
  const invokeEvent = (element, eventName, callsite, ...data) => {
90
68
  const handler = findEventHandler(element, eventName, callsite);
91
-
92
69
  if (!handler) {
93
70
  return;
94
71
  }
95
-
96
72
  let returnValue;
97
73
  (0, _act.default)(() => {
98
74
  returnValue = handler(...data);
99
75
  });
100
76
  return returnValue;
101
77
  };
102
-
103
78
  const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
104
-
105
79
  const pressHandler = (element, ...data) => invokeEvent(element, 'press', pressHandler, ...data);
106
-
107
80
  const changeTextHandler = (element, ...data) => invokeEvent(element, 'changeText', changeTextHandler, ...data);
108
-
109
81
  const scrollHandler = (element, ...data) => invokeEvent(element, 'scroll', scrollHandler, ...data);
110
-
111
82
  const fireEvent = (element, eventName, ...data) => invokeEvent(element, eventName, fireEvent, ...data);
112
-
113
83
  fireEvent.press = pressHandler;
114
84
  fireEvent.changeText = changeTextHandler;
115
85
  fireEvent.scroll = scrollHandler;
@@ -1 +1 @@
1
- {"version":3,"file":"fireEvent.js","names":["isTextInput","element","TextInput","require","filterNodeByType","isTouchResponder","isHostElement","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isTouchEvent","eventName","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","callsite","nearestTouchResponder","handler","getEventHandler","eventHandlerName","toEventHandlerName","invokeEvent","data","returnValue","act","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"sources":["../src/fireEvent.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\n const { TextInput } = require('react-native');\n // We have to test if the element type is either the TextInput component\n // (which would if it is a composite component) or the string\n // TextInput (which would be true if it is a host component)\n // All queries but the one by testID return composite component and event\n // if all queries returned host components, since fireEvent bubbles up\n // it would trigger the parent prop without the composite component check\n return (\n filterNodeByType(element, TextInput) ||\n filterNodeByType(element, 'TextInput')\n );\n};\n\nconst isTouchResponder = (element?: ReactTestInstance) => {\n if (!isHostElement(element)) return false;\n\n return !!element?.props.onStartShouldSetResponder || isTextInput(element);\n};\n\nconst isPointerEventEnabled = (\n element?: ReactTestInstance,\n isParent?: boolean\n): boolean => {\n const parentCondition = isParent\n ? element?.props.pointerEvents === 'box-only'\n : element?.props.pointerEvents === 'box-none';\n\n if (element?.props.pointerEvents === 'none' || parentCondition) {\n return false;\n }\n\n if (!element?.parent) return true;\n\n return isPointerEventEnabled(element.parent, true);\n};\n\nconst isTouchEvent = (eventName?: string) => {\n return eventName === 'press';\n};\n\nconst isEventEnabled = (\n element?: ReactTestInstance,\n touchResponder?: ReactTestInstance,\n eventName?: string\n) => {\n if (isTextInput(element)) return element?.props.editable !== false;\n if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;\n\n const touchStart = touchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();\n\n if (touchStart || touchMove) return true;\n\n return touchStart === undefined && touchMove === undefined;\n};\n\nconst findEventHandler = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n nearestTouchResponder?: ReactTestInstance\n): EventHandler | null => {\n const touchResponder = isTouchResponder(element)\n ? element\n : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, touchResponder, eventName))\n return handler;\n\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, callsite, touchResponder);\n};\n\nconst getEventHandler = (\n element: ReactTestInstance,\n eventName: string\n): EventHandler | undefined => {\n const eventHandlerName = toEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n};\n\nconst invokeEvent = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n ...data: Array<any>\n) => {\n const handler = findEventHandler(element, eventName, callsite);\n\n if (!handler) {\n return;\n }\n\n let returnValue;\n\n act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n};\n\nconst toEventHandlerName = (eventName: string) =>\n `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n\nconst pressHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'press', pressHandler, ...data);\nconst changeTextHandler = (\n element: ReactTestInstance,\n ...data: Array<any>\n): void => invokeEvent(element, 'changeText', changeTextHandler, ...data);\nconst scrollHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'scroll', scrollHandler, ...data);\n\nconst fireEvent = (\n element: ReactTestInstance,\n eventName: string,\n ...data: Array<any>\n): void => invokeEvent(element, eventName, fireEvent, ...data);\n\nfireEvent.press = pressHandler;\nfireEvent.changeText = changeTextHandler;\nfireEvent.scroll = scrollHandler;\n\nexport default fireEvent;\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;;;AAIA,MAAMA,WAAW,GAAIC,OAAD,IAAiC;EACnD,IAAI,CAACA,OAAL,EAAc;IACZ,OAAO,KAAP;EACD;;EAED,MAAM;IAAEC;EAAF,IAAgBC,OAAO,CAAC,cAAD,CAA7B,CALmD,CAMnD;EACA;EACA;EACA;EACA;EACA;;;EACA,OACE,IAAAC,kCAAA,EAAiBH,OAAjB,EAA0BC,SAA1B,KACA,IAAAE,kCAAA,EAAiBH,OAAjB,EAA0B,WAA1B,CAFF;AAID,CAhBD;;AAkBA,MAAMI,gBAAgB,GAAIJ,OAAD,IAAiC;EACxD,IAAI,CAAC,IAAAK,4BAAA,EAAcL,OAAd,CAAL,EAA6B,OAAO,KAAP;EAE7B,OAAO,CAAC,CAACA,OAAO,EAAEM,KAAT,CAAeC,yBAAjB,IAA8CR,WAAW,CAACC,OAAD,CAAhE;AACD,CAJD;;AAMA,MAAMQ,qBAAqB,GAAG,CAC5BR,OAD4B,EAE5BS,QAF4B,KAGhB;EACZ,MAAMC,eAAe,GAAGD,QAAQ,GAC5BT,OAAO,EAAEM,KAAT,CAAeK,aAAf,KAAiC,UADL,GAE5BX,O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CAAmB,EAD9D;;AAGA,MAAMC,YAAY,GAAG,CAACpC,OAAD,EAA6B,GAAG8B,IAAhC,KACnBD,WAAW,CAAC7B,OAAD,EAAU,OAAV,EAAmBoC,YAAnB,EAAiC,GAAGN,IAApC,CADb;;AAEA,MAAMO,iBAAiB,GAAG,CACxBrC,OADwB,EAExB,GAAG8B,IAFqB,KAGfD,WAAW,CAAC7B,OAAD,EAAU,YAAV,EAAwBqC,iBAAxB,EAA2C,GAAGP,IAA9C,CAHtB;;AAIA,MAAMQ,aAAa,GAAG,CAACtC,OAAD,EAA6B,GAAG8B,IAAhC,KACpBD,WAAW,CAAC7B,OAAD,EAAU,QAAV,EAAoBsC,aAApB,EAAmC,GAAGR,IAAtC,CADb;;AAGA,MAAMS,SAAS,GAAG,CAChBvC,OADgB,EAEhBc,SAFgB,EAGhB,GAAGgB,IAHa,KAIPD,WAAW,CAAC7B,OAAD,EAAUc,SAAV,EAAqByB,SAArB,EAAgC,GAAGT,IAAnC,CAJtB;;AAMAS,SAAS,CAACC,KAAV,GAAkBJ,YAAlB;AACAG,SAAS,CAACE,UAAV,GAAuBJ,iBAAvB;AACAE,SAAS,CAACG,MAAV,GAAmBJ,aAAnB;eAEeC,S"}
1
+ {"version":3,"file":"fireEvent.js","names":["isTextInput","element","filterNodeByType","TextInput","isTouchResponder","isHostElement","props","onStartShouldSetResponder","isPointerEventEnabled","isParent","parentCondition","pointerEvents","parent","isTouchEvent","eventName","isEventEnabled","touchResponder","editable","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","callsite","nearestTouchResponder","handler","getEventHandler","eventHandlerName","toEventHandlerName","invokeEvent","data","returnValue","act","charAt","toUpperCase","slice","pressHandler","changeTextHandler","scrollHandler","fireEvent","press","changeText","scroll"],"sources":["../src/fireEvent.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { TextInput } from 'react-native';\nimport act from './act';\nimport { isHostElement } from './helpers/component-tree';\nimport { filterNodeByType } from './helpers/filterNodeByType';\n\ntype EventHandler = (...args: any) => unknown;\n\nconst isTextInput = (element?: ReactTestInstance) => {\n if (!element) {\n return false;\n }\n\n // We have to test if the element type is either the TextInput component\n // (which would if it is a composite component) or the string\n // TextInput (which would be true if it is a host component)\n // All queries but the one by testID return composite component and event\n // if all queries returned host components, since fireEvent bubbles up\n // it would trigger the parent prop without the composite component check\n return (\n filterNodeByType(element, TextInput) ||\n filterNodeByType(element, 'TextInput')\n );\n};\n\nconst isTouchResponder = (element?: ReactTestInstance) => {\n if (!isHostElement(element)) return false;\n\n return !!element?.props.onStartShouldSetResponder || isTextInput(element);\n};\n\nconst isPointerEventEnabled = (\n element?: ReactTestInstance,\n isParent?: boolean\n): boolean => {\n const parentCondition = isParent\n ? element?.props.pointerEvents === 'box-only'\n : element?.props.pointerEvents === 'box-none';\n\n if (element?.props.pointerEvents === 'none' || parentCondition) {\n return false;\n }\n\n if (!element?.parent) return true;\n\n return isPointerEventEnabled(element.parent, true);\n};\n\nconst isTouchEvent = (eventName?: string) => {\n return eventName === 'press';\n};\n\nconst isEventEnabled = (\n element?: ReactTestInstance,\n touchResponder?: ReactTestInstance,\n eventName?: string\n) => {\n if (isTextInput(element)) return element?.props.editable !== false;\n if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;\n\n const touchStart = touchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = touchResponder?.props.onMoveShouldSetResponder?.();\n\n if (touchStart || touchMove) return true;\n\n return touchStart === undefined && touchMove === undefined;\n};\n\nconst findEventHandler = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n nearestTouchResponder?: ReactTestInstance\n): EventHandler | null => {\n const touchResponder = isTouchResponder(element)\n ? element\n : nearestTouchResponder;\n\n const handler = getEventHandler(element, eventName);\n if (handler && isEventEnabled(element, touchResponder, eventName))\n return handler;\n\n if (element.parent === null || element.parent.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, callsite, touchResponder);\n};\n\nconst getEventHandler = (\n element: ReactTestInstance,\n eventName: string\n): EventHandler | undefined => {\n const eventHandlerName = toEventHandlerName(eventName);\n if (typeof element.props[eventHandlerName] === 'function') {\n return element.props[eventHandlerName];\n }\n\n if (typeof element.props[eventName] === 'function') {\n return element.props[eventName];\n }\n\n return undefined;\n};\n\nconst invokeEvent = (\n element: ReactTestInstance,\n eventName: string,\n callsite?: any,\n ...data: Array<any>\n) => {\n const handler = findEventHandler(element, eventName, callsite);\n\n if (!handler) {\n return;\n }\n\n let returnValue;\n\n act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n};\n\nconst toEventHandlerName = (eventName: string) =>\n `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n\nconst pressHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'press', pressHandler, ...data);\nconst changeTextHandler = (\n element: ReactTestInstance,\n ...data: Array<any>\n): void => invokeEvent(element, 'changeText', changeTextHandler, ...data);\nconst scrollHandler = (element: ReactTestInstance, ...data: Array<any>): void =>\n invokeEvent(element, 'scroll', scrollHandler, ...data);\n\nconst fireEvent = (\n element: ReactTestInstance,\n eventName: string,\n ...data: Array<any>\n): void => invokeEvent(element, eventName, fireEvent, ...data);\n\nfireEvent.press = pressHandler;\nfireEvent.changeText = changeTextHandler;\nfireEvent.scroll = scrollHandler;\n\nexport default fireEvent;\n"],"mappings":";;;;;;AACA;AACA;AACA;AACA;AAA8D;AAI9D,MAAMA,WAAW,GAAIC,OAA2B,IAAK;EACnD,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,KAAK;EACd;;EAEA;EACA;EACA;EACA;EACA;EACA;EACA,OACE,IAAAC,kCAAgB,EAACD,OAAO,EAAEE,sBAAS,CAAC,IACpC,IAAAD,kCAAgB,EAACD,OAAO,EAAE,WAAW,CAAC;AAE1C,CAAC;AAED,MAAMG,gBAAgB,GAAIH,OAA2B,IAAK;EACxD,IAAI,CAAC,IAAAI,4BAAa,EAACJ,OAAO,CAAC,EAAE,OAAO,KA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AAC;EAEF,OAAOC,WAAW;AACpB,CAAC;AAED,MAAMH,kBAAkB,GAAId,SAAiB,IAC1C,KAAIA,SAAS,CAACmB,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,EAAG,GAAEpB,SAAS,CAACqB,KAAK,CAAC,CAAC,CAAE,EAAC;AAE/D,MAAMC,YAAY,GAAG,CAACnC,OAA0B,EAAE,GAAG6B,IAAgB,KACnED,WAAW,CAAC5B,OAAO,EAAE,OAAO,EAAEmC,YAAY,EAAE,GAAGN,IAAI,CAAC;AACtD,MAAMO,iBAAiB,GAAG,CACxBpC,OAA0B,EAC1B,GAAG6B,IAAgB,KACVD,WAAW,CAAC5B,OAAO,EAAE,YAAY,EAAEoC,iBAAiB,EAAE,GAAGP,IAAI,CAAC;AACzE,MAAMQ,aAAa,GAAG,CAACrC,OAA0B,EAAE,GAAG6B,IAAgB,KACpED,WAAW,CAAC5B,OAAO,EAAE,QAAQ,EAAEqC,aAAa,EAAE,GAAGR,IAAI,CAAC;AAExD,MAAMS,SAAS,GAAG,CAChBtC,OAA0B,EAC1Ba,SAAiB,EACjB,GAAGgB,IAAgB,KACVD,WAAW,CAAC5B,OAAO,EAAEa,SAAS,EAAEyB,SAAS,EAAE,GAAGT,IAAI,CAAC;AAE9DS,SAAS,CAACC,KAAK,GAAGJ,YAAY;AAC9BG,SAAS,CAACE,UAAU,GAAGJ,iBAAiB;AACxCE,SAAS,CAACG,MAAM,GAAGJ,aAAa;AAAC,eAElBC,SAAS;AAAA"}
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.flushMicroTasks = flushMicroTasks;
7
-
8
7
  var _timers = require("./helpers/timers");
9
-
10
8
  function flushMicroTasks() {
11
9
  return {
12
10
  // using "thenable" instead of a Promise, because otherwise it breaks when
@@ -14,7 +12,6 @@ function flushMicroTasks() {
14
12
  then(resolve) {
15
13
  (0, _timers.setImmediate)(resolve);
16
14
  }
17
-
18
15
  };
19
16
  }
20
17
  //# sourceMappingURL=flushMicroTasks.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"flushMicroTasks.js","names":["flushMicroTasks","then","resolve","setImmediate"],"sources":["../src/flushMicroTasks.ts"],"sourcesContent":["import { setImmediate } from './helpers/timers';\n\ntype Thenable<T> = { then: (callback: () => T) => unknown };\n\nexport function flushMicroTasks<T>(): Thenable<T> {\n return {\n // using \"thenable\" instead of a Promise, because otherwise it breaks when\n // using \"modern\" fake timers\n then(resolve) {\n setImmediate(resolve);\n },\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAIO,SAASA,eAAT,GAA2C;EAChD,OAAO;IACL;IACA;IACAC,IAAI,CAACC,OAAD,EAAU;MACZ,IAAAC,oBAAA,EAAaD,OAAb;IACD;;EALI,CAAP;AAOD"}
1
+ {"version":3,"file":"flushMicroTasks.js","names":["flushMicroTasks","then","resolve","setImmediate"],"sources":["../src/flushMicroTasks.ts"],"sourcesContent":["import { setImmediate } from './helpers/timers';\n\ntype Thenable<T> = { then: (callback: () => T) => unknown };\n\nexport function flushMicroTasks<T>(): Thenable<T> {\n return {\n // using \"thenable\" instead of a Promise, because otherwise it breaks when\n // using \"modern\" fake timers\n then(resolve) {\n setImmediate(resolve);\n },\n };\n}\n"],"mappings":";;;;;;AAAA;AAIO,SAASA,eAAe,GAAmB;EAChD,OAAO;IACL;IACA;IACAC,IAAI,CAACC,OAAO,EAAE;MACZ,IAAAC,oBAAY,EAACD,OAAO,CAAC;IACvB;EACF,CAAC;AACH"}
@@ -1,2 +1,5 @@
1
+ import { AccessibilityState } from 'react-native';
1
2
  import { ReactTestInstance } from 'react-test-renderer';
3
+ export declare type AccessibilityStateKey = keyof AccessibilityState;
4
+ export declare const accessibilityStateKeys: AccessibilityStateKey[];
2
5
  export declare function isInaccessible(element: ReactTestInstance | null): boolean;
@@ -3,58 +3,52 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.accessibilityStateKeys = void 0;
6
7
  exports.isInaccessible = isInaccessible;
7
-
8
8
  var _reactNative = require("react-native");
9
-
10
9
  var _componentTree = require("./component-tree");
11
-
10
+ const accessibilityStateKeys = ['disabled', 'selected', 'checked', 'busy', 'expanded'];
11
+ exports.accessibilityStateKeys = accessibilityStateKeys;
12
12
  function isInaccessible(element) {
13
13
  if (element == null) {
14
14
  return true;
15
15
  }
16
-
17
16
  let current = element;
18
-
19
17
  while (current) {
20
18
  if (isSubtreeInaccessible(current)) {
21
19
  return true;
22
20
  }
23
-
24
21
  current = current.parent;
25
22
  }
26
-
27
23
  return false;
28
24
  }
29
-
30
25
  function isSubtreeInaccessible(element) {
31
26
  if (element == null) {
32
27
  return true;
33
- } // iOS: accessibilityElementsHidden
34
- // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
35
-
28
+ }
36
29
 
30
+ // iOS: accessibilityElementsHidden
31
+ // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
37
32
  if (element.props.accessibilityElementsHidden) {
38
33
  return true;
39
- } // Android: importantForAccessibility
40
- // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android
41
-
34
+ }
42
35
 
36
+ // Android: importantForAccessibility
37
+ // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android
43
38
  if (element.props.importantForAccessibility === 'no-hide-descendants') {
44
39
  return true;
45
- } // Note that `opacity: 0` is not threated as inassessible on iOS
46
-
40
+ }
47
41
 
42
+ // Note that `opacity: 0` is not threated as inassessible on iOS
48
43
  const flatStyle = _reactNative.StyleSheet.flatten(element.props.style) ?? {};
49
- if (flatStyle.display === 'none') return true; // iOS: accessibilityViewIsModal
50
- // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
44
+ if (flatStyle.display === 'none') return true;
51
45
 
46
+ // iOS: accessibilityViewIsModal
47
+ // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
52
48
  const hostSiblings = (0, _componentTree.getHostSiblings)(element);
53
-
54
49
  if (hostSiblings.some(sibling => sibling.props.accessibilityViewIsModal)) {
55
50
  return true;
56
51
  }
57
-
58
52
  return false;
59
53
  }
60
54
  //# sourceMappingURL=accessiblity.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessiblity.js","names":["isInaccessible","element","current","isSubtreeInaccessible","parent","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings } from './component-tree';\n\nexport function isInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n if (isSubtreeInaccessible(current)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\nfunction isSubtreeInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\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 threated as inassessible 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"],"mappings":";;;;;;;AAAA;;AAEA;;AAEO,SAASA,cAAT,CAAwBC,OAAxB,EAAoE;EACzE,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,IAAP;EACD;;EAED,IAAIC,OAAiC,GAAGD,OAAxC;;EACA,OAAOC,OAAP,EAAgB;IACd,IAAIC,qBAAqB,CAACD,OAAD,CAAzB,EAAoC;MAClC,OAAO,IAAP;IACD;;IAEDA,OAAO,GAAGA,OAAO,CAACE,MAAlB;EACD;;EAED,OAAO,KAAP;AACD;;AAED,SAASD,qBAAT,CAA+BF,OAA/B,EAA2E;EACzE,IAAIA,OAAO,IAAI,IAAf,EAAqB;IACnB,OAAO,IAAP;EACD,CAHwE,CAKzE;EACA;;;EACA,IAAIA,OAAO,CAACI,KAAR,CAAcC,2BAAlB,EAA+C;IAC7C,OAAO,IAAP;EACD,CATwE,CAWzE;EACA;;;EACA,IAAIL,OAAO,CAACI,KAAR,CAAcE,yBAAd,KAA4C,qBAAhD,EAAuE;IACrE,OAAO,IAAP;EACD,CAfwE,CAiBzE;;;EACA,MAAMC,SAAS,GAAGC,uBAAA,CAAWC,OAAX,CAAmBT,OAAO,CAACI,KAAR,CAAcM,KAAjC,KAA2C,EAA7D;EACA,IAAIH,SAAS,CAACI,OAAV,KAAsB,MAA1B,EAAkC,OAAO,IAAP,CAnBuC,CAqBzE;EACA;;EACA,MAAMC,YAAY,GAAG,IAAAC,8BAAA,EAAgBb,OAAhB,CAArB;;EACA,IAAIY,YAAY,CAACE,IAAb,CAAmBC,OAAD,IAAaA,OAAO,CAACX,KAAR,CAAcY,wBAA7C,CAAJ,EAA4E;IAC1E,OAAO,IAAP;EACD;;EAED,OAAO,KAAP;AACD"}
1
+ {"version":3,"file":"accessiblity.js","names":["accessibilityStateKeys","isInaccessible","element","current","isSubtreeInaccessible","parent","props","accessibilityElementsHidden","importantForAccessibility","flatStyle","StyleSheet","flatten","style","display","hostSiblings","getHostSiblings","some","sibling","accessibilityViewIsModal"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import { AccessibilityState, StyleSheet } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings } from './component-tree';\n\nexport type AccessibilityStateKey = keyof AccessibilityState;\n\nexport const accessibilityStateKeys: AccessibilityStateKey[] = [\n 'disabled',\n 'selected',\n 'checked',\n 'busy',\n 'expanded',\n];\n\nexport function isInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\n }\n\n let current: ReactTestInstance | null = element;\n while (current) {\n if (isSubtreeInaccessible(current)) {\n return true;\n }\n\n current = current.parent;\n }\n\n return false;\n}\n\nfunction isSubtreeInaccessible(element: ReactTestInstance | null): boolean {\n if (element == null) {\n return true;\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 threated as inassessible 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"],"mappings":";;;;;;;AAAA;AAEA;AAIO,MAAMA,sBAA+C,GAAG,CAC7D,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,SAASC,cAAc,CAACC,OAAiC,EAAW;EACzE,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIC,OAAiC,GAAGD,OAAO;EAC/C,OAAOC,OAAO,EAAE;IACd,IAAIC,qBAAqB,CAACD,OAAO,CAAC,EAAE;MAClC,OAAO,IAAI;IACb;IAEAA,OAAO,GAAGA,OAAO,CAACE,MAAM;EAC1B;EAEA,OAAO,KAAK;AACd;AAEA,SAASD,qBAAqB,CAACF,OAAiC,EAAW;EACzE,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;;EAEA;EACA;EACA,IAAIA,OAAO,CAACI,KAAK,CAACC,2BAA2B,EAAE;IAC7C,OAAO,IAAI;EACb;;EAEA;EACA;EACA,IAAIL,OAAO,CAACI,KAAK,CAACE,yBAAyB,KAAK,qBAAqB,EAAE;IACrE,OAAO,IAAI;EACb;;EAEA;EACA,MAAMC,SAAS,GAAGC,uBAAU,CAACC,OAAO,CAACT,OAAO,CAACI,KAAK,CAACM,KAAK,CAAC,IAAI,CAAC,CAAC;EAC/D,IAAIH,SAAS,CAACI,OAAO,KAAK,MAAM,EAAE,OAAO,IAAI;;EAE7C;EACA;EACA,MAAMC,YAAY,GAAG,IAAAC,8BAAe,EAACb,OAAO,CAAC;EAC7C,IAAIY,YAAY,CAACE,IAAI,CAAEC,OAAO,IAAKA,OAAO,CAACX,KAAK,CAACY,wBAAwB,CAAC,EAAE;IAC1E,OAAO,IAAI;EACb;EAEA,OAAO,KAAK;AACd"}
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  import { ReactTestInstance } from 'react-test-renderer';
2
3
  /**
3
4
  * Checks if the given element is a host element.
@@ -14,6 +15,15 @@ export declare function getHostParent(element: ReactTestInstance | null): ReactT
14
15
  * @param element The element start traversing from.
15
16
  */
16
17
  export declare function getHostChildren(element: ReactTestInstance | null): ReactTestInstance[];
18
+ /**
19
+ * Return a single host element that represent the passed host or composite element.
20
+ *
21
+ * @param element The element start traversing from.
22
+ * @throws Error if the passed element is a composite element and has no host children or has more than one host child.
23
+ * @returns If the passed element is a host element, it will return itself, if the passed element is a composite
24
+ * element, it will return a single host descendant.
25
+ */
26
+ export declare function getHostSelf(element: ReactTestInstance | null): ReactTestInstance;
17
27
  /**
18
28
  * Return the array of host elements that represent the passed element.
19
29
  *
@@ -27,3 +37,8 @@ export declare function getHostSelves(element: ReactTestInstance | null): ReactT
27
37
  * @param element The element start traversing from.
28
38
  */
29
39
  export declare function getHostSiblings(element: ReactTestInstance | null): ReactTestInstance[];
40
+ export declare function getCompositeParentOfType(element: ReactTestInstance, type: React.ComponentType): ReactTestInstance | null;
41
+ /**
42
+ * Note: this function should be generally used for core React Native types like `View`, `Text`, `TextInput`, etc.
43
+ */
44
+ export declare function isHostElementForType(element: ReactTestInstance, type: React.ComponentType): boolean;