@testing-library/react-native 11.3.0 → 11.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/README.md +5 -2
  2. package/build/act.js +9 -15
  3. package/build/act.js.map +1 -1
  4. package/build/cleanup.d.ts +1 -1
  5. package/build/cleanup.js +0 -4
  6. package/build/cleanup.js.map +1 -1
  7. package/build/config.d.ts +15 -2
  8. package/build/config.js +16 -8
  9. package/build/config.js.map +1 -1
  10. package/build/fireEvent.js +3 -31
  11. package/build/fireEvent.js.map +1 -1
  12. package/build/flushMicroTasks.d.ts +1 -1
  13. package/build/flushMicroTasks.js +0 -3
  14. package/build/flushMicroTasks.js.map +1 -1
  15. package/build/helpers/accessiblity.d.ts +10 -1
  16. package/build/helpers/accessiblity.js +28 -24
  17. package/build/helpers/accessiblity.js.map +1 -1
  18. package/build/helpers/component-tree.js +6 -27
  19. package/build/helpers/component-tree.js.map +1 -1
  20. package/build/helpers/debugDeep.d.ts +5 -1
  21. package/build/helpers/debugDeep.js +7 -6
  22. package/build/helpers/debugDeep.js.map +1 -1
  23. package/build/helpers/debugShallow.js +0 -5
  24. package/build/helpers/debugShallow.js.map +1 -1
  25. package/build/helpers/errors.js +4 -25
  26. package/build/helpers/errors.js.map +1 -1
  27. package/build/helpers/filterNodeByType.js +0 -2
  28. package/build/helpers/filterNodeByType.js.map +1 -1
  29. package/build/helpers/findAll.d.ts +10 -0
  30. package/build/helpers/findAll.js +44 -0
  31. package/build/helpers/findAll.js.map +1 -0
  32. package/build/helpers/format.d.ts +5 -1
  33. package/build/helpers/format.js +17 -7
  34. package/build/helpers/format.js.map +1 -1
  35. package/build/helpers/getTextContent.d.ts +2 -0
  36. package/build/helpers/getTextContent.js +20 -0
  37. package/build/helpers/getTextContent.js.map +1 -0
  38. package/build/helpers/matchers/accessibilityState.d.ts +3 -0
  39. package/build/helpers/matchers/accessibilityState.js +28 -0
  40. package/build/helpers/matchers/accessibilityState.js.map +1 -0
  41. package/build/helpers/matchers/accessibilityValue.d.ts +9 -0
  42. package/build/helpers/matchers/accessibilityValue.js +12 -0
  43. package/build/helpers/matchers/accessibilityValue.js.map +1 -0
  44. package/build/helpers/matchers/matchArrayProp.js +0 -3
  45. package/build/helpers/matchers/matchArrayProp.js.map +1 -1
  46. package/build/helpers/matchers/matchObjectProp.js +0 -2
  47. package/build/helpers/matchers/matchObjectProp.js.map +1 -1
  48. package/build/helpers/matchers/matchStringProp.js +0 -3
  49. package/build/helpers/matchers/matchStringProp.js.map +1 -1
  50. package/build/helpers/matchers/matchTextContent.d.ts +3 -0
  51. package/build/helpers/matchers/matchTextContent.js +22 -0
  52. package/build/helpers/matchers/matchTextContent.js.map +1 -0
  53. package/build/helpers/stringValidation.js +0 -7
  54. package/build/helpers/stringValidation.js.map +1 -1
  55. package/build/helpers/timers.js +10 -21
  56. package/build/helpers/timers.js.map +1 -1
  57. package/build/index.flow.js +169 -56
  58. package/build/index.js +0 -6
  59. package/build/index.js.map +1 -1
  60. package/build/matches.d.ts +7 -3
  61. package/build/matches.js +2 -4
  62. package/build/matches.js.map +1 -1
  63. package/build/pure.d.ts +12 -23
  64. package/build/pure.js +8 -15
  65. package/build/pure.js.map +1 -1
  66. package/build/queries/a11yState.d.ts +15 -14
  67. package/build/queries/a11yState.js +16 -13
  68. package/build/queries/a11yState.js.map +1 -1
  69. package/build/queries/a11yValue.d.ts +15 -20
  70. package/build/queries/a11yValue.js +16 -13
  71. package/build/queries/a11yValue.js.map +1 -1
  72. package/build/queries/displayValue.d.ts +11 -9
  73. package/build/queries/displayValue.js +2 -12
  74. package/build/queries/displayValue.js.map +1 -1
  75. package/build/queries/hintText.d.ts +23 -20
  76. package/build/queries/hintText.js +11 -11
  77. package/build/queries/hintText.js.map +1 -1
  78. package/build/queries/labelText.d.ts +11 -8
  79. package/build/queries/labelText.js +11 -11
  80. package/build/queries/labelText.js.map +1 -1
  81. package/build/queries/makeQueries.d.ts +9 -9
  82. package/build/queries/makeQueries.js +40 -24
  83. package/build/queries/makeQueries.js.map +1 -1
  84. package/build/queries/options.d.ts +11 -0
  85. package/build/queries/options.js +2 -0
  86. package/build/queries/options.js.map +1 -0
  87. package/build/queries/placeholderText.d.ts +11 -9
  88. package/build/queries/placeholderText.js +2 -12
  89. package/build/queries/placeholderText.js.map +1 -1
  90. package/build/queries/role.d.ts +7 -3
  91. package/build/queries/role.js +32 -13
  92. package/build/queries/role.js.map +1 -1
  93. package/build/queries/testId.d.ts +11 -9
  94. package/build/queries/testId.js +3 -11
  95. package/build/queries/testId.js.map +1 -1
  96. package/build/queries/text.d.ts +11 -13
  97. package/build/queries/text.js +6 -71
  98. package/build/queries/text.js.map +1 -1
  99. package/build/queries/unsafeProps.d.ts +1 -1
  100. package/build/queries/unsafeProps.js +2 -11
  101. package/build/queries/unsafeProps.js.map +1 -1
  102. package/build/queries/unsafeType.d.ts +1 -1
  103. package/build/queries/unsafeType.js +2 -9
  104. package/build/queries/unsafeType.js.map +1 -1
  105. package/build/react-versions.js +0 -4
  106. package/build/react-versions.js.map +1 -1
  107. package/build/render.d.ts +88 -141
  108. package/build/render.js +21 -31
  109. package/build/render.js.map +1 -1
  110. package/build/renderHook.d.ts +2 -2
  111. package/build/renderHook.js +2 -12
  112. package/build/renderHook.js.map +1 -1
  113. package/build/screen.js +0 -6
  114. package/build/screen.js.map +1 -1
  115. package/build/shallow.js +0 -6
  116. package/build/shallow.js.map +1 -1
  117. package/build/waitFor.d.ts +1 -1
  118. package/build/waitFor.js +29 -52
  119. package/build/waitFor.js.map +1 -1
  120. package/build/waitForElementToBeRemoved.js +2 -11
  121. package/build/waitForElementToBeRemoved.js.map +1 -1
  122. package/build/within.d.ts +84 -138
  123. package/build/within.js +2 -14
  124. package/build/within.js.map +1 -1
  125. package/package.json +12 -11
  126. package/typings/index.flow.js +169 -56
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
@@ -116,8 +117,8 @@ test('form submits two answers', () => {
116
117
  fireEvent.press(screen.getByText('Submit'));
117
118
 
118
119
  expect(mockFn).toBeCalledWith({
119
- '1': { q: 'q1', a: 'a1' },
120
- '2': { q: 'q2', a: 'a2' },
120
+ 1: { q: 'q1', a: 'a1' },
121
+ 2: { q: 'q2', a: 'a2' },
121
122
  });
122
123
  });
123
124
  ```
@@ -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"}
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- declare type CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;
2
+ type CleanUpFunction = (nextElement?: React.ReactElement<any>) => void;
3
3
  export default function cleanup(): void;
4
4
  export declare function addToCleanupQueue(fn: CleanUpFunction): void;
5
5
  export {};
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"}
package/build/config.d.ts CHANGED
@@ -1,10 +1,23 @@
1
- export declare type Config = {
1
+ import { DebugOptions } from './helpers/debugDeep';
2
+ export type Config = {
2
3
  /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
3
4
  asyncUtilTimeout: number;
5
+ /** Default value for `includeHiddenElements` query option. */
6
+ defaultIncludeHiddenElements: boolean;
7
+ /** Default options for `debug` helper. */
8
+ defaultDebugOptions?: Partial<DebugOptions>;
4
9
  };
5
- export declare function configure(options: Partial<Config>): void;
10
+ export type ConfigAliasOptions = {
11
+ /** RTL-compatibility alias to `defaultIncludeHiddenElements` */
12
+ defaultHidden: boolean;
13
+ };
14
+ export declare function configure(options: Partial<Config & ConfigAliasOptions>): void;
6
15
  export declare function resetToDefaults(): void;
7
16
  export declare function getConfig(): {
8
17
  /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */
9
18
  asyncUtilTimeout: number;
19
+ /** Default value for `includeHiddenElements` query option. */
20
+ defaultIncludeHiddenElements: boolean;
21
+ /** Default options for `debug` helper. */
22
+ defaultDebugOptions?: Partial<DebugOptions> | undefined;
10
23
  };
package/build/config.js CHANGED
@@ -7,21 +7,29 @@ exports.configure = configure;
7
7
  exports.getConfig = getConfig;
8
8
  exports.resetToDefaults = resetToDefaults;
9
9
  const defaultConfig = {
10
- asyncUtilTimeout: 1000
10
+ asyncUtilTimeout: 1000,
11
+ defaultIncludeHiddenElements: true
11
12
  };
12
- let config = { ...defaultConfig
13
+ let config = {
14
+ ...defaultConfig
13
15
  };
14
-
15
16
  function configure(options) {
16
- config = { ...config,
17
- ...options
17
+ const {
18
+ defaultHidden,
19
+ ...restOptions
20
+ } = options;
21
+ const defaultIncludeHiddenElements = restOptions.defaultIncludeHiddenElements ?? defaultHidden ?? config.defaultIncludeHiddenElements;
22
+ config = {
23
+ ...config,
24
+ ...restOptions,
25
+ defaultIncludeHiddenElements
18
26
  };
19
27
  }
20
-
21
28
  function resetToDefaults() {
22
- config = defaultConfig;
29
+ config = {
30
+ ...defaultConfig
31
+ };
23
32
  }
24
-
25
33
  function getConfig() {
26
34
  return config;
27
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","config","configure","options","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["export type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\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":";;;;;;;;AAKA,MAAMA,aAAqB,GAAG;EAC5BC,gBAAgB,EAAE;AADU,CAA9B;AAIA,IAAIC,MAAM,GAAG,EACX,GAAGF;AADQ,CAAb;;AAIO,SAASG,SAAT,CAAmBC,OAAnB,EAA6C;EAClDF,MAAM,GAAG,EACP,GAAGA,MADI;IAEP,GAAGE;EAFI,CAAT;AAID;;AAEM,SAASC,eAAT,GAA2B;EAChCH,MAAM,GAAGF,aAAT;AACD;;AAEM,SAASM,SAAT,GAAqB;EAC1B,OAAOJ,MAAP;AACD"}
1
+ {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","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 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\nconst defaultConfig: Config = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: true,\n};\n\nlet config = { ...defaultConfig };\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 resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;AAkBA,MAAMA,aAAqB,GAAG;EAC5BC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;AAE1B,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,eAAe,GAAG;EAChCL,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASS,SAAS,GAAG;EAC1B,OAAON,MAAM;AACf"}
@@ -4,51 +4,39 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _reactNative = require("react-native");
9
-
10
8
  var _act = _interopRequireDefault(require("./act"));
11
-
12
9
  var _componentTree = require("./helpers/component-tree");
13
-
14
10
  var _filterNodeByType = require("./helpers/filterNodeByType");
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  const isTextInput = element => {
19
13
  if (!element) {
20
14
  return false;
21
- } // We have to test if the element type is either the TextInput component
15
+ }
16
+
17
+ // We have to test if the element type is either the TextInput component
22
18
  // (which would if it is a composite component) or the string
23
19
  // TextInput (which would be true if it is a host component)
24
20
  // All queries but the one by testID return composite component and event
25
21
  // if all queries returned host components, since fireEvent bubbles up
26
22
  // it would trigger the parent prop without the composite component check
27
-
28
-
29
23
  return (0, _filterNodeByType.filterNodeByType)(element, _reactNative.TextInput) || (0, _filterNodeByType.filterNodeByType)(element, 'TextInput');
30
24
  };
31
-
32
25
  const isTouchResponder = element => {
33
26
  if (!(0, _componentTree.isHostElement)(element)) return false;
34
27
  return !!element?.props.onStartShouldSetResponder || isTextInput(element);
35
28
  };
36
-
37
29
  const isPointerEventEnabled = (element, isParent) => {
38
30
  const parentCondition = isParent ? element?.props.pointerEvents === 'box-only' : element?.props.pointerEvents === 'box-none';
39
-
40
31
  if (element?.props.pointerEvents === 'none' || parentCondition) {
41
32
  return false;
42
33
  }
43
-
44
34
  if (!element?.parent) return true;
45
35
  return isPointerEventEnabled(element.parent, true);
46
36
  };
47
-
48
37
  const isTouchEvent = eventName => {
49
38
  return eventName === 'press';
50
39
  };
51
-
52
40
  const isEventEnabled = (element, touchResponder, eventName) => {
53
41
  if (isTextInput(element)) return element?.props.editable !== false;
54
42
  if (!isPointerEventEnabled(element) && isTouchEvent(eventName)) return false;
@@ -57,57 +45,41 @@ const isEventEnabled = (element, touchResponder, eventName) => {
57
45
  if (touchStart || touchMove) return true;
58
46
  return touchStart === undefined && touchMove === undefined;
59
47
  };
60
-
61
48
  const findEventHandler = (element, eventName, callsite, nearestTouchResponder) => {
62
49
  const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;
63
50
  const handler = getEventHandler(element, eventName);
64
51
  if (handler && isEventEnabled(element, touchResponder, eventName)) return handler;
65
-
66
52
  if (element.parent === null || element.parent.parent === null) {
67
53
  return null;
68
54
  }
69
-
70
55
  return findEventHandler(element.parent, eventName, callsite, touchResponder);
71
56
  };
72
-
73
57
  const getEventHandler = (element, eventName) => {
74
58
  const eventHandlerName = toEventHandlerName(eventName);
75
-
76
59
  if (typeof element.props[eventHandlerName] === 'function') {
77
60
  return element.props[eventHandlerName];
78
61
  }
79
-
80
62
  if (typeof element.props[eventName] === 'function') {
81
63
  return element.props[eventName];
82
64
  }
83
-
84
65
  return undefined;
85
66
  };
86
-
87
67
  const invokeEvent = (element, eventName, callsite, ...data) => {
88
68
  const handler = findEventHandler(element, eventName, callsite);
89
-
90
69
  if (!handler) {
91
70
  return;
92
71
  }
93
-
94
72
  let returnValue;
95
73
  (0, _act.default)(() => {
96
74
  returnValue = handler(...data);
97
75
  });
98
76
  return returnValue;
99
77
  };
100
-
101
78
  const toEventHandlerName = eventName => `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;
102
-
103
79
  const pressHandler = (element, ...data) => invokeEvent(element, 'press', pressHandler, ...data);
104
-
105
80
  const changeTextHandler = (element, ...data) => invokeEvent(element, 'changeText', changeTextHandler, ...data);
106
-
107
81
  const scrollHandler = (element, ...data) => invokeEvent(element, 'scroll', scrollHandler, ...data);
108
-
109
82
  const fireEvent = (element, eventName, ...data) => invokeEvent(element, eventName, fireEvent, ...data);
110
-
111
83
  fireEvent.press = pressHandler;
112
84
  fireEvent.changeText = changeTextHandler;
113
85
  fireEvent.scroll = scrollHandler;
@@ -1 +1 @@
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;;;;AAIA,MAAMA,WAAW,GAAIC,OAAD,IAAiC;EACnD,IAAI,CAACA,OAAL,EAAc;IACZ,OAAO,KAAP;EACD,CAHkD,CAKnD;EACA;EACA;EACA;EACA;EACA;;;EACA,OACE,IAAAC,kCAAA,EAAiBD,OAAjB,EAA0BE,sBAA1B,KACA,IAAAD,kCAAA,EAAiBD,OAAjB,EAA0B,WAA1B,CAFF;AAID,CAfD;;AAiBA,MAAM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Ua,SAAV,EAAqBS,QAArB,CAAhC;;EAEA,IAAI,CAACE,OAAL,EAAc;IACZ;EACD;;EAED,IAAIM,WAAJ;EAEA,IAAAC,YAAA,EAAI,MAAM;IACRD,WAAW,GAAGN,OAAO,CAAC,GAAGK,IAAJ,CAArB;EACD,CAFD;EAIA,OAAOC,WAAP;AACD,CAnBD;;AAqBA,MAAMH,kBAAkB,GAAId,SAAD,IACxB,KAAIA,SAAS,CAACmB,MAAV,CAAiB,CAAjB,EAAoBC,WAApB,EAAkC,GAAEpB,SAAS,CAACqB,KAAV,CAAgB,CAAhB,CAAmB,EAD9D;;AAGA,MAAMC,YAAY,GAAG,CAACnC,OAAD,EAA6B,GAAG6B,IAAhC,KACnBD,WAAW,CAAC5B,OAAD,EAAU,OAAV,EAAmBmC,YAAnB,EAAiC,GAAGN,IAApC,CADb;;AAEA,MAAMO,iBAAiB,GAAG,CACxBpC,OADwB,EAExB,GAAG6B,IAFqB,KAGfD,WAAW,CAAC5B,OAAD,EAAU,YAAV,EAAwBoC,iBAAxB,EAA2C,GAAGP,IAA9C,CAHtB;;AAIA,MAAMQ,aAAa,GAAG,CAACrC,OAAD,EAA6B,GAAG6B,IAAhC,KACpBD,WAAW,CAAC5B,OAAD,EAAU,QAAV,EAAoBqC,aAApB,EAAmC,GAAGR,IAAtC,CADb;;AAGA,MAAMS,SAAS,GAAG,CAChBtC,OADgB,EAEhBa,SAFgB,EAGhB,GAAGgB,IAHa,KAIPD,WAAW,CAAC5B,OAAD,EAAUa,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;A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xCE,SAAS,CAACG,MAAM,GAAGJ,aAAa;AAAC,eAElBC,SAAS;AAAA"}
@@ -1,4 +1,4 @@
1
- declare type Thenable<T> = {
1
+ type Thenable<T> = {
2
2
  then: (callback: () => T) => unknown;
3
3
  };
4
4
  export declare function flushMicroTasks<T>(): Thenable<T>;
@@ -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,11 @@
1
+ import { AccessibilityState, AccessibilityValue } from 'react-native';
1
2
  import { ReactTestInstance } from 'react-test-renderer';
2
- export declare function isInaccessible(element: ReactTestInstance | null): boolean;
3
+ type IsInaccessibleOptions = {
4
+ cache?: WeakMap<ReactTestInstance, boolean>;
5
+ };
6
+ export declare const accessibilityStateKeys: (keyof AccessibilityState)[];
7
+ export declare const accessiblityValueKeys: (keyof AccessibilityValue)[];
8
+ export declare function isHiddenFromAccessibility(element: ReactTestInstance | null, { cache }?: IsInaccessibleOptions): boolean;
9
+ /** RTL-compatitibility alias for `isHiddenFromAccessibility` */
10
+ export declare const isInaccessible: typeof isHiddenFromAccessibility;
11
+ export {};
@@ -3,58 +3,62 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.isInaccessible = isInaccessible;
7
-
6
+ exports.accessiblityValueKeys = exports.accessibilityStateKeys = void 0;
7
+ exports.isHiddenFromAccessibility = isHiddenFromAccessibility;
8
+ exports.isInaccessible = void 0;
8
9
  var _reactNative = require("react-native");
9
-
10
10
  var _componentTree = require("./component-tree");
11
-
12
- function isInaccessible(element) {
11
+ const accessibilityStateKeys = ['disabled', 'selected', 'checked', 'busy', 'expanded'];
12
+ exports.accessibilityStateKeys = accessibilityStateKeys;
13
+ const accessiblityValueKeys = ['min', 'max', 'now', 'text'];
14
+ exports.accessiblityValueKeys = accessiblityValueKeys;
15
+ function isHiddenFromAccessibility(element, {
16
+ cache
17
+ } = {}) {
13
18
  if (element == null) {
14
19
  return true;
15
20
  }
16
-
17
21
  let current = element;
18
-
19
22
  while (current) {
20
- if (isSubtreeInaccessible(current)) {
23
+ let isCurrentSubtreeInaccessible = cache?.get(current);
24
+ if (isCurrentSubtreeInaccessible === undefined) {
25
+ isCurrentSubtreeInaccessible = isSubtreeInaccessible(current);
26
+ cache?.set(current, isCurrentSubtreeInaccessible);
27
+ }
28
+ if (isCurrentSubtreeInaccessible) {
21
29
  return true;
22
30
  }
23
-
24
31
  current = current.parent;
25
32
  }
26
-
27
33
  return false;
28
34
  }
29
35
 
36
+ /** RTL-compatitibility alias for `isHiddenFromAccessibility` */
37
+ const isInaccessible = isHiddenFromAccessibility;
38
+ exports.isInaccessible = isInaccessible;
30
39
  function isSubtreeInaccessible(element) {
31
- if (element == null) {
32
- return true;
33
- } // iOS: accessibilityElementsHidden
40
+ // iOS: accessibilityElementsHidden
34
41
  // See: https://reactnative.dev/docs/accessibility#accessibilityelementshidden-ios
35
-
36
-
37
42
  if (element.props.accessibilityElementsHidden) {
38
43
  return true;
39
- } // Android: importantForAccessibility
40
- // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android
41
-
44
+ }
42
45
 
46
+ // Android: importantForAccessibility
47
+ // See: https://reactnative.dev/docs/accessibility#importantforaccessibility-android
43
48
  if (element.props.importantForAccessibility === 'no-hide-descendants') {
44
49
  return true;
45
- } // Note that `opacity: 0` is not threated as inassessible on iOS
46
-
50
+ }
47
51
 
52
+ // Note that `opacity: 0` is not treated as inaccessible on iOS
48
53
  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
54
+ if (flatStyle.display === 'none') return true;
51
55
 
56
+ // iOS: accessibilityViewIsModal
57
+ // See: https://reactnative.dev/docs/accessibility#accessibilityviewismodal-ios
52
58
  const hostSiblings = (0, _componentTree.getHostSiblings)(element);
53
-
54
59
  if (hostSiblings.some(sibling => sibling.props.accessibilityViewIsModal)) {
55
60
  return true;
56
61
  }
57
-
58
62
  return false;
59
63
  }
60
64
  //# 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","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"],"sources":["../../src/helpers/accessiblity.ts"],"sourcesContent":["import {\n AccessibilityState,\n AccessibilityValue,\n StyleSheet,\n} from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { getHostSiblings } 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"],"mappings":";;;;;;;;AAAA;AAMA;AAMO,MAAMA,sBAAoD,GAAG,CAClE,UAAU,EACV,UAAU,EACV,SAAS,EACT,MAAM,EACN,UAAU,CACX;AAAC;AAEK,MAAMC,qBAAmD,GAA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