@testing-library/react-native 14.0.0-alpha.0 → 14.0.0-alpha.2

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 (233) hide show
  1. package/README.md +8 -12
  2. package/build/act.d.ts +2 -4
  3. package/build/act.js +4 -5
  4. package/build/act.js.map +1 -1
  5. package/build/cleanup.d.ts +3 -1
  6. package/build/cleanup.js +8 -0
  7. package/build/cleanup.js.map +1 -1
  8. package/build/event-handler.d.ts +7 -0
  9. package/build/event-handler.js +30 -0
  10. package/build/event-handler.js.map +1 -0
  11. package/build/fire-event.d.ts +11 -4
  12. package/build/fire-event.js +43 -37
  13. package/build/fire-event.js.map +1 -1
  14. package/build/helpers/accessibility.d.ts +2 -2
  15. package/build/helpers/accessibility.js +5 -2
  16. package/build/helpers/accessibility.js.map +1 -1
  17. package/build/helpers/component-tree.d.ts +8 -8
  18. package/build/helpers/component-tree.js +19 -16
  19. package/build/helpers/component-tree.js.map +1 -1
  20. package/build/helpers/debug.d.ts +3 -3
  21. package/build/helpers/debug.js +8 -11
  22. package/build/helpers/debug.js.map +1 -1
  23. package/build/helpers/errors.js +4 -4
  24. package/build/helpers/errors.js.map +1 -1
  25. package/build/helpers/find-all.d.ts +1 -1
  26. package/build/helpers/find-all.js +7 -27
  27. package/build/helpers/find-all.js.map +1 -1
  28. package/build/helpers/format-element.d.ts +18 -0
  29. package/build/helpers/format-element.js +80 -0
  30. package/build/helpers/format-element.js.map +1 -0
  31. package/build/helpers/host-component-names.d.ts +1 -1
  32. package/build/helpers/host-component-names.js +6 -7
  33. package/build/helpers/host-component-names.js.map +1 -1
  34. package/build/helpers/logger.d.ts +28 -0
  35. package/build/helpers/logger.js +42 -0
  36. package/build/helpers/logger.js.map +1 -0
  37. package/build/helpers/{format-default.d.ts → map-props.d.ts} +1 -0
  38. package/build/helpers/{format-default.js → map-props.js} +2 -2
  39. package/build/helpers/map-props.js.map +1 -0
  40. package/build/helpers/matchers/match-accessibility-state.d.ts +1 -1
  41. package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
  42. package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
  43. package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
  44. package/build/helpers/matchers/match-label-text.d.ts +2 -2
  45. package/build/helpers/matchers/match-label-text.js.map +1 -1
  46. package/build/helpers/matchers/match-string-prop.d.ts +1 -1
  47. package/build/helpers/matchers/match-string-prop.js.map +1 -1
  48. package/build/helpers/matchers/match-text-content.d.ts +2 -2
  49. package/build/helpers/matchers/match-text-content.js.map +1 -1
  50. package/build/helpers/object.d.ts +1 -1
  51. package/build/helpers/object.js.map +1 -1
  52. package/build/helpers/pointer-events.d.ts +1 -1
  53. package/build/helpers/pointer-events.js +9 -5
  54. package/build/helpers/pointer-events.js.map +1 -1
  55. package/build/helpers/text-content.d.ts +1 -1
  56. package/build/helpers/text-content.js.map +1 -1
  57. package/build/helpers/text-input.d.ts +1 -1
  58. package/build/helpers/text-input.js.map +1 -1
  59. package/build/helpers/timers.d.ts +1 -1
  60. package/build/helpers/timers.js.map +1 -1
  61. package/build/helpers/wrap-async.d.ts +0 -1
  62. package/build/helpers/wrap-async.js +0 -1
  63. package/build/helpers/wrap-async.js.map +1 -1
  64. package/build/index.d.ts +0 -1
  65. package/build/index.flow.js +33 -36
  66. package/build/index.js +4 -16
  67. package/build/index.js.map +1 -1
  68. package/build/matchers/extend-expect.js +2 -2
  69. package/build/matchers/extend-expect.js.map +1 -1
  70. package/build/matchers/index.d.ts +1 -1
  71. package/build/matchers/index.js.map +1 -1
  72. package/build/matchers/to-be-busy.d.ts +1 -1
  73. package/build/matchers/to-be-busy.js +4 -1
  74. package/build/matchers/to-be-busy.js.map +1 -1
  75. package/build/matchers/to-be-checked.d.ts +1 -1
  76. package/build/matchers/to-be-checked.js +4 -1
  77. package/build/matchers/to-be-checked.js.map +1 -1
  78. package/build/matchers/to-be-disabled.d.ts +1 -1
  79. package/build/matchers/to-be-disabled.js +5 -2
  80. package/build/matchers/to-be-disabled.js.map +1 -1
  81. package/build/matchers/to-be-empty-element.d.ts +1 -1
  82. package/build/matchers/to-be-empty-element.js +9 -3
  83. package/build/matchers/to-be-empty-element.js.map +1 -1
  84. package/build/matchers/to-be-expanded.d.ts +1 -1
  85. package/build/matchers/to-be-expanded.js +5 -2
  86. package/build/matchers/to-be-expanded.js.map +1 -1
  87. package/build/matchers/to-be-on-the-screen.d.ts +1 -1
  88. package/build/matchers/to-be-on-the-screen.js +4 -1
  89. package/build/matchers/to-be-on-the-screen.js.map +1 -1
  90. package/build/matchers/to-be-partially-checked.d.ts +1 -1
  91. package/build/matchers/to-be-partially-checked.js +4 -1
  92. package/build/matchers/to-be-partially-checked.js.map +1 -1
  93. package/build/matchers/to-be-selected.d.ts +1 -1
  94. package/build/matchers/to-be-selected.js +4 -1
  95. package/build/matchers/to-be-selected.js.map +1 -1
  96. package/build/matchers/to-be-visible.d.ts +1 -1
  97. package/build/matchers/to-be-visible.js +8 -5
  98. package/build/matchers/to-be-visible.js.map +1 -1
  99. package/build/matchers/to-contain-element.d.ts +1 -1
  100. package/build/matchers/to-contain-element.js +5 -3
  101. package/build/matchers/to-contain-element.js.map +1 -1
  102. package/build/matchers/to-have-accessibility-value.d.ts +2 -2
  103. package/build/matchers/to-have-accessibility-value.js.map +1 -1
  104. package/build/matchers/to-have-accessible-name.d.ts +2 -2
  105. package/build/matchers/to-have-accessible-name.js.map +1 -1
  106. package/build/matchers/to-have-display-value.d.ts +2 -2
  107. package/build/matchers/to-have-display-value.js +1 -1
  108. package/build/matchers/to-have-display-value.js.map +1 -1
  109. package/build/matchers/to-have-prop.d.ts +1 -1
  110. package/build/matchers/to-have-prop.js.map +1 -1
  111. package/build/matchers/to-have-style.d.ts +2 -2
  112. package/build/matchers/to-have-style.js +1 -1
  113. package/build/matchers/to-have-style.js.map +1 -1
  114. package/build/matchers/to-have-text-content.d.ts +2 -2
  115. package/build/matchers/to-have-text-content.js.map +1 -1
  116. package/build/matchers/types.d.ts +4 -4
  117. package/build/matchers/types.js.map +1 -1
  118. package/build/matchers/utils.d.ts +1 -8
  119. package/build/matchers/utils.js +3 -48
  120. package/build/matchers/utils.js.map +1 -1
  121. package/build/native-state.d.ts +3 -3
  122. package/build/native-state.js +1 -1
  123. package/build/native-state.js.map +1 -1
  124. package/build/pure.d.ts +6 -4
  125. package/build/pure.js +28 -2
  126. package/build/pure.js.map +1 -1
  127. package/build/queries/display-value.d.ts +3 -3
  128. package/build/queries/display-value.js +9 -9
  129. package/build/queries/display-value.js.map +1 -1
  130. package/build/queries/hint-text.d.ts +4 -4
  131. package/build/queries/hint-text.js +9 -9
  132. package/build/queries/hint-text.js.map +1 -1
  133. package/build/queries/label-text.d.ts +4 -4
  134. package/build/queries/label-text.js +9 -9
  135. package/build/queries/label-text.js.map +1 -1
  136. package/build/queries/make-queries.d.ts +3 -3
  137. package/build/queries/make-queries.js +15 -18
  138. package/build/queries/make-queries.js.map +1 -1
  139. package/build/queries/options.d.ts +1 -1
  140. package/build/queries/options.js.map +1 -1
  141. package/build/queries/placeholder-text.d.ts +3 -3
  142. package/build/queries/placeholder-text.js +10 -10
  143. package/build/queries/placeholder-text.js.map +1 -1
  144. package/build/queries/role.d.ts +7 -7
  145. package/build/queries/role.js +16 -9
  146. package/build/queries/role.js.map +1 -1
  147. package/build/queries/test-id.d.ts +3 -3
  148. package/build/queries/test-id.js +9 -9
  149. package/build/queries/test-id.js.map +1 -1
  150. package/build/queries/text.d.ts +3 -3
  151. package/build/queries/text.js +9 -9
  152. package/build/queries/text.js.map +1 -1
  153. package/build/react-versions.js +1 -2
  154. package/build/react-versions.js.map +1 -1
  155. package/build/render-act.d.ts +3 -0
  156. package/build/render-act.js +29 -0
  157. package/build/render-act.js.map +1 -0
  158. package/build/render-async.d.ts +83 -0
  159. package/build/render-async.js +96 -0
  160. package/build/render-async.js.map +1 -0
  161. package/build/render-hook.d.ts +18 -6
  162. package/build/render-hook.js +56 -26
  163. package/build/render-hook.js.map +1 -1
  164. package/build/render.d.ts +54 -48
  165. package/build/render.js +42 -30
  166. package/build/render.js.map +1 -1
  167. package/build/screen.d.ts +1 -1
  168. package/build/screen.js +7 -7
  169. package/build/screen.js.map +1 -1
  170. package/build/test-utils/console.d.ts +1 -0
  171. package/build/test-utils/console.js +17 -0
  172. package/build/test-utils/console.js.map +1 -0
  173. package/build/test-utils/json.d.ts +6 -0
  174. package/build/test-utils/json.js +33 -0
  175. package/build/test-utils/json.js.map +1 -0
  176. package/build/tsconfig.release.tsbuildinfo +1 -1
  177. package/build/types.d.ts +4 -0
  178. package/build/types.js.map +1 -1
  179. package/build/user-event/clear.d.ts +2 -2
  180. package/build/user-event/clear.js +6 -6
  181. package/build/user-event/clear.js.map +1 -1
  182. package/build/user-event/event-builder/base.d.ts +2 -2
  183. package/build/user-event/event-builder/base.js.map +1 -1
  184. package/build/user-event/event-builder/scroll-view.d.ts +1 -1
  185. package/build/user-event/event-builder/scroll-view.js.map +1 -1
  186. package/build/user-event/event-builder/text-input.d.ts +2 -2
  187. package/build/user-event/event-builder/text-input.js.map +1 -1
  188. package/build/user-event/index.d.ts +4 -4
  189. package/build/user-event/index.js.map +1 -1
  190. package/build/user-event/paste.d.ts +2 -2
  191. package/build/user-event/paste.js +8 -8
  192. package/build/user-event/paste.js.map +1 -1
  193. package/build/user-event/press/index.d.ts +1 -1
  194. package/build/user-event/press/index.js.map +1 -1
  195. package/build/user-event/press/press.d.ts +2 -2
  196. package/build/user-event/press/press.js +48 -49
  197. package/build/user-event/press/press.js.map +1 -1
  198. package/build/user-event/scroll/index.d.ts +1 -1
  199. package/build/user-event/scroll/index.js.map +1 -1
  200. package/build/user-event/scroll/scroll-to.d.ts +3 -3
  201. package/build/user-event/scroll/scroll-to.js +8 -8
  202. package/build/user-event/scroll/scroll-to.js.map +1 -1
  203. package/build/user-event/scroll/utils.d.ts +1 -1
  204. package/build/user-event/scroll/utils.js.map +1 -1
  205. package/build/user-event/setup/setup.d.ts +4 -4
  206. package/build/user-event/setup/setup.js.map +1 -1
  207. package/build/user-event/type/type.d.ts +3 -2
  208. package/build/user-event/type/type.js +16 -14
  209. package/build/user-event/type/type.js.map +1 -1
  210. package/build/user-event/utils/content-size.d.ts +1 -1
  211. package/build/user-event/utils/content-size.js.map +1 -1
  212. package/build/user-event/utils/dispatch-event.d.ts +2 -2
  213. package/build/user-event/utils/dispatch-event.js +5 -15
  214. package/build/user-event/utils/dispatch-event.js.map +1 -1
  215. package/build/user-event/utils/wait.d.ts +6 -2
  216. package/build/user-event/utils/wait.js +1 -1
  217. package/build/user-event/utils/wait.js.map +1 -1
  218. package/build/wait-for-element-to-be-removed.js +1 -1
  219. package/build/wait-for-element-to-be-removed.js.map +1 -1
  220. package/build/wait-for.js +4 -5
  221. package/build/wait-for.js.map +1 -1
  222. package/build/within.d.ts +20 -20
  223. package/build/within.js +8 -8
  224. package/build/within.js.map +1 -1
  225. package/package.json +38 -32
  226. package/typings/index.flow.js +33 -36
  227. package/build/helpers/format-default.js.map +0 -1
  228. package/build/helpers/format.d.ts +0 -7
  229. package/build/helpers/format.js +0 -31
  230. package/build/helpers/format.js.map +0 -1
  231. package/build/test-utils/index.d.ts +0 -1
  232. package/build/test-utils/index.js +0 -17
  233. package/build/test-utils/index.js.map +0 -1
@@ -1,5 +1,5 @@
1
- import { HostElement } from 'universal-test-renderer';
2
- import { TextMatch, TextMatchOptions } from '../matches';
1
+ import type { HostElement } from 'universal-test-renderer';
2
+ import type { TextMatch, TextMatchOptions } from '../matches';
3
3
  import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
4
4
  import type { CommonQueryOptions } from './options';
5
5
  type ByTextOptions = CommonQueryOptions & TextMatchOptions;
@@ -11,5 +11,5 @@ export type ByTextQueries = {
11
11
  findByText: FindByQuery<TextMatch, ByTextOptions>;
12
12
  findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;
13
13
  };
14
- export declare const bindByTextQueries: (instance: HostElement) => ByTextQueries;
14
+ export declare const bindByTextQueries: (element: HostElement) => ByTextQueries;
15
15
  export {};
@@ -8,8 +8,8 @@ var _findAll = require("../helpers/find-all");
8
8
  var _hostComponentNames = require("../helpers/host-component-names");
9
9
  var _matchTextContent = require("../helpers/matchers/match-text-content");
10
10
  var _makeQueries = require("./make-queries");
11
- const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
12
- return (0, _findAll.findAll)(instance, node => (0, _hostComponentNames.isHostText)(node) && (0, _matchTextContent.matchTextContent)(node, text, options), {
11
+ const queryAllByText = element => function queryAllByTextFn(text, options = {}) {
12
+ return (0, _findAll.findAll)(element, node => (0, _hostComponentNames.isHostText)(node) && (0, _matchTextContent.matchTextContent)(node, text, options), {
13
13
  ...options,
14
14
  matchDeepestOnly: true
15
15
  });
@@ -24,13 +24,13 @@ const {
24
24
  findBy,
25
25
  findAllBy
26
26
  } = (0, _makeQueries.makeQueries)(queryAllByText, getMissingError, getMultipleError);
27
- const bindByTextQueries = instance => ({
28
- getByText: getBy(instance),
29
- getAllByText: getAllBy(instance),
30
- queryByText: queryBy(instance),
31
- queryAllByText: queryAllBy(instance),
32
- findByText: findBy(instance),
33
- findAllByText: findAllBy(instance)
27
+ const bindByTextQueries = element => ({
28
+ getByText: getBy(element),
29
+ getAllByText: getAllBy(element),
30
+ queryByText: queryBy(element),
31
+ queryAllByText: queryAllBy(element),
32
+ findByText: findBy(element),
33
+ findAllByText: findAllBy(element)
34
34
  });
35
35
  exports.bindByTextQueries = bindByTextQueries;
36
36
  //# sourceMappingURL=text.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","instance","queryAllByTextFn","text","options","findAll","node","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import { HostElement } from 'universal-test-renderer';\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './make-queries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (instance: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(instance, (node) => isHostText(node) && matchTextContent(node, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (instance: HostElement): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n findAllByText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAaA,MAAMI,cAAc,GAAIC,QAAqB,IAC3C,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,QAAQ,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC5F,GAAGA,OAAO;IACVK,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,IAAe,IAAK,sCAAsCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAElG,MAAMS,eAAe,GAAIT,IAAe,IAAK,wCAAwCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAEnG,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,cAAc,EACdY,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,iBAAiB,GAAInB,QAAqB,KAAqB;EAC1EoB,SAAS,EAAER,KAAK,CAACZ,QAAQ,CAAC;EAC1BqB,YAAY,EAAER,QAAQ,CAACb,QAAQ,CAAC;EAChCsB,WAAW,EAAER,OAAO,CAACd,QAAQ,CAAC;EAC9BD,cAAc,EAAEgB,UAAU,CAACf,QAAQ,CAAC;EACpCuB,UAAU,EAAEP,MAAM,CAAChB,QAAQ,CAAC;EAC5BwB,aAAa,EAAEP,SAAS,CAACjB,QAAQ;AACnC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","element","queryAllByTextFn","text","options","findAll","node","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (element: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(element, (node) => isHostText(node) && matchTextContent(node, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (element: HostElement): ByTextQueries => ({\n getByText: getBy(element),\n getAllByText: getAllBy(element),\n queryByText: queryBy(element),\n queryAllByText: queryAllBy(element),\n findByText: findBy(element),\n findAllByText: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,I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ersionAtLeast;
7
7
  var React = _interopRequireWildcard(require("react"));
8
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
9
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
8
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
9
  function checkReactVersionAtLeast(major, minor) {
11
10
  if (React.version === undefined) return false;
12
11
  const [actualMajor, actualMinor] = React.version.split('.').map(Number);
@@ -1 +1 @@
1
- {"version":3,"file":"react-versions.js","names":["React","_interopRequireWildcard","require","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","checkReactVersionAtLeast","major","minor","version","undefined","actualMajor","actualMinor","split","map","Number"],"sources":["../src/react-versions.ts"],"sourcesContent":["import * as React from 'react';\n\nexport function checkReactVersionAtLeast(major: number, minor: number): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,SAAAC,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAH,wBAAAG,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AAExB,SAASW,wBAAwBA,CAACC,KAAa,EAAEC,KAAa,EAAW;EAC9E,IAAIzB,KAAK,CAAC0B,OAAO,KAAKC,SAAS,EAAE,OAAO,KAAK;EAC7C,MAAM,CAACC,WAAW,EAAEC,WAAW,CAAC,GAAG7B,KAAK,CAAC0B,OAAO,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAEvE,OAAOJ,WAAW,GAAGJ,KAAK,IAAKI,WAAW,KAAKJ,KAAK,IAAIK,WAAW,IAAIJ,KAAM;AAC/E","ignoreList":[]}
1
+ {"version":3,"file":"react-versions.js","names":["React","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","checkReactVersionAtLeast","major","minor","version","undefined","actualMajor","actualMinor","split","map","Number"],"sources":["../src/react-versions.ts"],"sourcesContent":["import * as React from 'react';\n\nexport function checkReactVersionAtLeast(major: number, minor: number): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,SAAAD,wBAAAE,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAJ,uBAAA,YAAAA,CAAAE,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAAAR,CAAA,EAAAC,CAAA;AAExB,SAASkB,wBAAwBA,CAACC,KAAa,EAAEC,KAAa,EAAW;EAC9E,IAAIxB,KAAK,CAACyB,OAAO,KAAKC,SAAS,EAAE,OAAO,KAAK;EAC7C,MAAM,CAACC,WAAW,EAAEC,WAAW,CAAC,GAAG5B,KAAK,CAACyB,OAAO,CAACI,KAAK,CAAC,GAAG,CAAC,CAACC,GAAG,CAACC,MAAM,CAAC;EAEvE,OAAOJ,WAAW,GAAGJ,KAAK,IAAKI,WAAW,KAAKJ,KAAK,IAAIK,WAAW,IAAIJ,KAAM;AAC/E","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import type { Root, RootOptions } from 'universal-test-renderer';
2
+ export declare function renderWithAct(element: React.ReactElement, options?: RootOptions): Root;
3
+ export declare function renderWithAsyncAct(element: React.ReactElement, options?: RootOptions): Promise<Root>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.renderWithAct = renderWithAct;
7
+ exports.renderWithAsyncAct = renderWithAsyncAct;
8
+ var _universalTestRenderer = require("universal-test-renderer");
9
+ var _act = _interopRequireDefault(require("./act"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function renderWithAct(element, options) {
12
+ const root = (0, _universalTestRenderer.createRoot)(options);
13
+
14
+ // This will be called synchronously.
15
+ void (0, _act.default)(() => {
16
+ root.render(element);
17
+ });
18
+ return root;
19
+ }
20
+ async function renderWithAsyncAct(element, options) {
21
+ const root = (0, _universalTestRenderer.createRoot)(options);
22
+
23
+ // eslint-disable-next-line require-await
24
+ await (0, _act.default)(async () => {
25
+ root.render(element);
26
+ });
27
+ return root;
28
+ }
29
+ //# sourceMappingURL=render-act.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-act.js","names":["_universalTestRenderer","require","_act","_interopRequireDefault","e","__esModule","default","renderWithAct","element","options","root","createRoot","act","render","renderWithAsyncAct"],"sources":["../src/render-act.ts"],"sourcesContent":["import type { Root, RootOptions } from 'universal-test-renderer';\nimport { createRoot } from 'universal-test-renderer';\n\nimport act from './act';\n\nexport function renderWithAct(element: React.ReactElement, options?: RootOptions): Root {\n const root = createRoot(options);\n\n // This will be called synchronously.\n void act(() => {\n root.render(element);\n });\n\n return root;\n}\n\nexport async function renderWithAsyncAct(\n element: React.ReactElement,\n options?: RootOptions,\n): Promise<Root> {\n const root = createRoot(options);\n\n // eslint-disable-next-line require-await\n await act(async () => {\n root.render(element);\n });\n\n return root;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AAAwB,SAAAE,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEjB,SAASG,aAAaA,CAACC,OAA2B,EAAEC,OAAqB,EAAQ;EACtF,MAAMC,IAAI,GAAG,IAAAC,iCAAU,EAACF,OAAO,CAAC;;EAEhC;EACA,KAAK,IAAAG,YAAG,EAAC,MAAM;IACbF,IAAI,CAACG,MAAM,CAACL,OAAO,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOE,IAAI;AACb;AAEO,eAAeI,kBAAkBA,CACtCN,OAA2B,EAC3BC,OAAqB,EACN;EACf,MAAMC,IAAI,GAAG,IAAAC,iCAAU,EAACF,OAAO,CAAC;;EAEhC;EACA,MAAM,IAAAG,YAAG,EAAC,YAAY;IACpBF,IAAI,CAACG,MAAM,CAACL,OAAO,CAAC;EACtB,CAAC,CAAC;EAEF,OAAOE,IAAI;AACb","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ import * as React from 'react';
2
+ import type { HostElement } from 'universal-test-renderer';
3
+ import type { DebugOptions } from './helpers/debug';
4
+ export interface RenderAsyncOptions {
5
+ /**
6
+ * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
7
+ * reusable custom render functions for common data providers.
8
+ */
9
+ wrapper?: React.ComponentType<any>;
10
+ createNodeMock?: (element: React.ReactElement) => unknown;
11
+ }
12
+ export type RenderAsyncResult = ReturnType<typeof renderAsync>;
13
+ /**
14
+ * Renders test component deeply using React Test Renderer and exposes helpers
15
+ * to assert on the output.
16
+ */
17
+ export default function renderAsync<T>(component: React.ReactElement<T>, options?: RenderAsyncOptions): Promise<{
18
+ rerender: (_component: React.ReactElement) => never;
19
+ rerenderAsync: (component: React.ReactElement) => Promise<void>;
20
+ update: (_component: React.ReactElement) => never;
21
+ updateAsync: (component: React.ReactElement) => Promise<void>;
22
+ unmount: () => never;
23
+ unmountAsync: () => Promise<void>;
24
+ toJSON: () => import("universal-test-renderer").JsonNode | null;
25
+ debug: DebugFunction;
26
+ container: HostElement;
27
+ root: HostElement | null;
28
+ getByRole: import("./queries/make-queries").GetByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
29
+ getAllByRole: import("./queries/make-queries").GetAllByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
30
+ queryByRole: import("./queries/make-queries").QueryByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
31
+ queryAllByRole: import("./queries/make-queries").QueryAllByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
32
+ findByRole: import("./queries/make-queries").FindByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
33
+ findAllByRole: import("./queries/make-queries").FindAllByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
34
+ getByHintText: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
35
+ getAllByHintText: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
36
+ queryByHintText: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
37
+ queryAllByHintText: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
38
+ findByHintText: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
39
+ findAllByHintText: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
40
+ getByA11yHint: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
41
+ getAllByA11yHint: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
42
+ queryByA11yHint: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
43
+ queryAllByA11yHint: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
44
+ findByA11yHint: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
45
+ findAllByA11yHint: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
46
+ getByAccessibilityHint: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
47
+ getAllByAccessibilityHint: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
48
+ queryByAccessibilityHint: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
49
+ queryAllByAccessibilityHint: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
50
+ findByAccessibilityHint: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
51
+ findAllByAccessibilityHint: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
52
+ getByLabelText: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
53
+ getAllByLabelText: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
54
+ queryByLabelText: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
55
+ queryAllByLabelText: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
56
+ findByLabelText: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
57
+ findAllByLabelText: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
58
+ getByPlaceholderText: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
59
+ getAllByPlaceholderText: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
60
+ queryByPlaceholderText: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
61
+ queryAllByPlaceholderText: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
62
+ findByPlaceholderText: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
63
+ findAllByPlaceholderText: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
64
+ getByDisplayValue: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
65
+ getAllByDisplayValue: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
66
+ queryByDisplayValue: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
67
+ queryAllByDisplayValue: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
68
+ findByDisplayValue: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
69
+ findAllByDisplayValue: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
70
+ getByTestId: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
71
+ getAllByTestId: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
72
+ queryByTestId: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
73
+ queryAllByTestId: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
74
+ findByTestId: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
75
+ findAllByTestId: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
76
+ getByText: import("./queries/make-queries").GetByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
77
+ getAllByText: import("./queries/make-queries").GetAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
78
+ queryByText: import("./queries/make-queries").QueryByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
79
+ queryAllByText: import("./queries/make-queries").QueryAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
80
+ findByText: import("./queries/make-queries").FindByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
81
+ findAllByText: import("./queries/make-queries").FindAllByQuery<import("./matches").TextMatch, import("./queries/options").CommonQueryOptions & import("./matches").TextMatchOptions>;
82
+ }>;
83
+ export type DebugFunction = (options?: DebugOptions) => void;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = renderAsync;
7
+ var React = _interopRequireWildcard(require("react"));
8
+ var _act = _interopRequireDefault(require("./act"));
9
+ var _cleanup = require("./cleanup");
10
+ var _config = require("./config");
11
+ var _debug = require("./helpers/debug");
12
+ var _errors = require("./helpers/errors");
13
+ var _renderAct = require("./render-act");
14
+ var _screen = require("./screen");
15
+ var _within = require("./within");
16
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
18
+ /**
19
+ * Renders test component deeply using React Test Renderer and exposes helpers
20
+ * to assert on the output.
21
+ */
22
+ async function renderAsync(component, options = {}) {
23
+ const {
24
+ wrapper: Wrapper
25
+ } = options || {};
26
+
27
+ // TODO allow passing some options
28
+ const rendererOptions = {};
29
+ const wrap = element => Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element;
30
+ const renderer = await (0, _renderAct.renderWithAsyncAct)(wrap(component), rendererOptions);
31
+ return buildRenderResult(renderer, wrap);
32
+ }
33
+ function buildRenderResult(renderer, wrap) {
34
+ const container = renderer.container;
35
+ const rerender = _component => {
36
+ throw new _errors.ErrorWithStack('"rerender(...)" is not supported when using "renderAsync" use "await rerenderAsync(...)" instead', rerender);
37
+ };
38
+ const rerenderAsync = async component => {
39
+ // eslint-disable-next-line require-await
40
+ await (0, _act.default)(async () => {
41
+ renderer.render(wrap(component));
42
+ });
43
+ };
44
+ const unmount = () => {
45
+ throw new _errors.ErrorWithStack('"unmount()" is not supported when using "renderAsync" use "await unmountAsync()" instead', unmount);
46
+ };
47
+ const unmountAsync = async () => {
48
+ // eslint-disable-next-line require-await
49
+ await (0, _act.default)(async () => {
50
+ renderer.unmount();
51
+ });
52
+ };
53
+ (0, _cleanup.addToCleanupQueue)(unmountAsync);
54
+ const result = {
55
+ ...(0, _within.getQueriesForElement)(renderer.container),
56
+ rerender,
57
+ rerenderAsync,
58
+ update: rerender,
59
+ // alias for `rerender`
60
+ updateAsync: rerenderAsync,
61
+ // alias for `rerenderAsync`
62
+ unmount,
63
+ unmountAsync,
64
+ toJSON: () => renderer.container.toJSON(),
65
+ debug: makeDebug(renderer),
66
+ get container() {
67
+ return renderer.container;
68
+ },
69
+ get root() {
70
+ const firstChild = container.children[0];
71
+ if (typeof firstChild === 'string') {
72
+ throw new Error('Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.');
73
+ }
74
+ return firstChild;
75
+ }
76
+ };
77
+ (0, _screen.setRenderResult)(result);
78
+ return result;
79
+ }
80
+ function makeDebug(renderer) {
81
+ function debugImpl(options) {
82
+ const {
83
+ defaultDebugOptions
84
+ } = (0, _config.getConfig)();
85
+ const debugOptions = {
86
+ ...defaultDebugOptions,
87
+ ...options
88
+ };
89
+ const json = renderer.container.toJSON();
90
+ if (json) {
91
+ return (0, _debug.debug)(json, debugOptions);
92
+ }
93
+ }
94
+ return debugImpl;
95
+ }
96
+ //# sourceMappingURL=render-async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render-async.js","names":["React","_interopRequireWildcard","require","_act","_interopRequireDefault","_cleanup","_config","_debug","_errors","_renderAct","_screen","_within","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderAsync","component","options","wrapper","Wrapper","rendererOptions","wrap","element","createElement","renderer","renderWithAsyncAct","buildRenderResult","container","rerender","_component","ErrorWithStack","rerenderAsync","act","render","unmount","unmountAsync","addToCleanupQueue","result","getQueriesForElement","update","updateAsync","toJSON","debug","makeDebug","root","firstChild","children","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions","json"],"sources":["../src/render-async.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { HostElement, Root, RootOptions } from 'universal-test-renderer';\n\nimport act from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { ErrorWithStack } from './helpers/errors';\nimport { renderWithAsyncAct } from './render-act';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderAsyncOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n createNodeMock?: (element: React.ReactElement) => unknown;\n}\n\nexport type RenderAsyncResult = ReturnType<typeof renderAsync>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport default async function renderAsync<T>(\n component: React.ReactElement<T>,\n options: RenderAsyncOptions = {},\n) {\n const { wrapper: Wrapper } = options || {};\n\n // TODO allow passing some options\n const rendererOptions: RootOptions = {};\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = await renderWithAsyncAct(wrap(component), rendererOptions);\n return buildRenderResult(renderer, wrap);\n}\n\nfunction buildRenderResult(\n renderer: Root,\n wrap: (element: React.ReactElement) => React.JSX.Element,\n) {\n const container = renderer.container;\n\n const rerender = (_component: React.ReactElement) => {\n throw new ErrorWithStack(\n '\"rerender(...)\" is not supported when using \"renderAsync\" use \"await rerenderAsync(...)\" instead',\n rerender,\n );\n };\n const rerenderAsync = async (component: React.ReactElement) => {\n // eslint-disable-next-line require-await\n await act(async () => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = () => {\n throw new ErrorWithStack(\n '\"unmount()\" is not supported when using \"renderAsync\" use \"await unmountAsync()\" instead',\n unmount,\n );\n };\n const unmountAsync = async () => {\n // eslint-disable-next-line require-await\n await act(async () => {\n renderer.unmount();\n });\n };\n\n addToCleanupQueue(unmountAsync);\n\n const result = {\n ...getQueriesForElement(renderer.container),\n rerender,\n rerenderAsync,\n update: rerender, // alias for `rerender`\n updateAsync: rerenderAsync, // alias for `rerenderAsync`\n unmount,\n unmountAsync,\n toJSON: () => renderer.container.toJSON(),\n debug: makeDebug(renderer),\n get container(): HostElement {\n return renderer.container;\n },\n get root(): HostElement | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n throw new Error(\n 'Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.',\n );\n }\n\n return firstChild;\n },\n };\n\n setRenderResult(result);\n\n return result;\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: Root): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...defaultDebugOptions, ...options };\n const json = renderer.container.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,IAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,OAAA,GAAAN,OAAA;AACA,IAAAO,UAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAgD,SAAAE,uBAAAQ,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAX,wBAAAW,CAAA,EAAAG,CAAA,6BAA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C3B,OAAOH,QAAQ,CAACG,SAAS;IAC3B,CAAC;IACD,IAAIiB,IAAIA,CAAA,EAAuB;MAC7B,MAAMC,UAAU,GAAGlB,SAAS,CAACmB,QAAQ,CAAC,CAAC,CAAC;MACxC,IAAI,OAAOD,UAAU,KAAK,QAAQ,EAAE;QAClC,MAAM,IAAIE,KAAK,CACb,wHACF,CAAC;MACH;MAEA,OAAOF,UAAU;IACnB;EACF,CAAC;EAED,IAAAG,uBAAe,EAACX,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAIA,SAASM,SAASA,CAACnB,QAAc,EAAiB;EAChD,SAASyB,SAASA,CAAChC,OAAsB,EAAE;IACzC,MAAM;MAAEiC;IAAoB,CAAC,GAAG,IAAAC,iBAAS,EAAC,CAAC;IAC3C,MAAMC,YAAY,GAAG;MAAE,GAAGF,mBAAmB;MAAE,GAAGjC;IAAQ,CAAC;IAC3D,MAAMoC,IAAI,GAAG7B,QAAQ,CAACG,SAAS,CAACc,MAAM,CAAC,CAAC;IACxC,IAAIY,IAAI,EAAE;MACR,OAAO,IAAAX,YAAK,EAACW,IAAI,EAAED,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
@@ -1,13 +1,25 @@
1
- import type { ComponentType } from 'react';
1
+ import * as React from 'react';
2
+ import type { RefObject } from './types';
2
3
  export type RenderHookResult<Result, Props> = {
4
+ result: RefObject<Result>;
3
5
  rerender: (props: Props) => void;
4
- result: {
5
- current: Result;
6
- };
7
6
  unmount: () => void;
8
7
  };
8
+ export type RenderHookAsyncResult<Result, Props> = {
9
+ result: RefObject<Result>;
10
+ rerenderAsync: (props: Props) => Promise<void>;
11
+ unmountAsync: () => Promise<void>;
12
+ };
9
13
  export type RenderHookOptions<Props> = {
14
+ /**
15
+ * The initial props to pass to the hook.
16
+ */
10
17
  initialProps?: Props;
11
- wrapper?: ComponentType<any>;
18
+ /**
19
+ * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating
20
+ * reusable custom render functions for common data providers.
21
+ */
22
+ wrapper?: React.ComponentType<any>;
12
23
  };
13
- export declare function renderHook<Result, Props>(renderCallback: (props: Props) => Result, options?: RenderHookOptions<Props>): RenderHookResult<Result, Props>;
24
+ export declare function renderHook<Result, Props>(hookToRender: (props: Props) => Result, options?: RenderHookOptions<NoInfer<Props>>): RenderHookResult<Result, Props>;
25
+ export declare function renderHookAsync<Result, Props>(hookToRender: (props: Props) => Result, options?: RenderHookOptions<NoInfer<Props>>): Promise<RenderHookAsyncResult<Result, Props>>;
@@ -4,44 +4,74 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.renderHook = renderHook;
7
- var _react = _interopRequireDefault(require("react"));
8
- var _render = require("./render");
7
+ exports.renderHookAsync = renderHookAsync;
8
+ var React = _interopRequireWildcard(require("react"));
9
+ var _render = _interopRequireDefault(require("./render"));
10
+ var _renderAsync = _interopRequireDefault(require("./render-async"));
9
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- function renderHook(renderCallback, options) {
11
- const initialProps = options?.initialProps;
12
- const wrapper = options?.wrapper;
13
- const result = /*#__PURE__*/_react.default.createRef();
14
- function TestComponent({
15
- renderCallbackProps
12
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
13
+ function renderHook(hookToRender, options) {
14
+ const result = /*#__PURE__*/React.createRef();
15
+ function HookContainer({
16
+ hookProps
16
17
  }) {
17
- const renderResult = renderCallback(renderCallbackProps);
18
- _react.default.useEffect(() => {
18
+ const renderResult = hookToRender(hookProps);
19
+ React.useEffect(() => {
19
20
  result.current = renderResult;
20
21
  });
21
22
  return null;
22
23
  }
23
24
  const {
24
- rerender: baseRerender,
25
+ initialProps,
26
+ ...renderOptions
27
+ } = options ?? {};
28
+ const {
29
+ rerender: rerenderComponent,
25
30
  unmount
26
- } = (0, _render.renderInternal)(
31
+ } = (0, _render.default)(
27
32
  /*#__PURE__*/
28
33
  // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt
29
- _react.default.createElement(TestComponent, {
30
- renderCallbackProps: initialProps
31
- }), {
32
- wrapper
33
- });
34
- function rerender(rerenderCallbackProps) {
35
- return baseRerender(/*#__PURE__*/_react.default.createElement(TestComponent, {
36
- renderCallbackProps: rerenderCallbackProps
37
- }));
38
- }
39
-
40
- // @ts-expect-error result is ill typed because ref is initialized to null
34
+ React.createElement(HookContainer, {
35
+ hookProps: initialProps
36
+ }), renderOptions);
41
37
  return {
42
- result,
43
- rerender,
38
+ result: result,
39
+ rerender: hookProps => rerenderComponent(/*#__PURE__*/React.createElement(HookContainer, {
40
+ hookProps: hookProps
41
+ })),
44
42
  unmount
45
43
  };
46
44
  }
45
+ async function renderHookAsync(hookToRender, options) {
46
+ const result = /*#__PURE__*/React.createRef();
47
+ function TestComponent({
48
+ hookProps
49
+ }) {
50
+ const renderResult = hookToRender(hookProps);
51
+ React.useEffect(() => {
52
+ result.current = renderResult;
53
+ });
54
+ return null;
55
+ }
56
+ const {
57
+ initialProps,
58
+ ...renderOptions
59
+ } = options ?? {};
60
+ const {
61
+ rerenderAsync: rerenderComponentAsync,
62
+ unmountAsync
63
+ } = await (0, _renderAsync.default)(
64
+ /*#__PURE__*/
65
+ // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt
66
+ React.createElement(TestComponent, {
67
+ hookProps: initialProps
68
+ }), renderOptions);
69
+ return {
70
+ result: result,
71
+ rerenderAsync: hookProps => rerenderComponentAsync(/*#__PURE__*/React.createElement(TestComponent, {
72
+ hookProps: hookProps
73
+ })),
74
+ unmountAsync
75
+ };
76
+ }
47
77
  //# sourceMappingURL=render-hook.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC;EACF,CACF,CAAC;EAED,SAASS,QAAQA,CAACK,qBAA4B,EAAE;IAC9C,OAAOJ,YAAY,cAACrB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;MAACC,mBAAmB,EAAES;IAAsB,CAAE,CAAC,CAAC;EACpF;;EAEA;EACA,OAAO;IAAEb,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC","ignoreList":[]}
1
+ {"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_render","_interopRequireDefault","_renderAsync","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderHook","hookToRender","options","result","createRef","HookContainer","hookProps","renderResult","useEffect","current","initialProps","renderOptions","rerender","rerenderComponent","unmount","render","createElement","renderHookAsync","TestComponent","rerenderAsync","rerenderComponentAsync","unmountAsync","renderAsync"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport render from './render';\nimport renderAsync from './render-async';\nimport type { RefObject } from './types';\n\nexport type RenderHookResult<Result, Props> = {\n result: RefObject<Result>;\n rerender: (props: Props) => void;\n unmount: () => void;\n};\n\nexport type RenderHookAsyncResult<Result, Props> = {\n result: RefObject<Result>;\n rerenderAsync: (props: Props) => Promise<void>;\n unmountAsync: () => Promise<void>;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): RenderHookResult<Result, Props> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function HookContainer({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, ...renderOptions } = options ?? {};\n const { rerender: rerenderComponent, unmount } = render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <HookContainer hookProps={initialProps} />,\n renderOptions,\n );\n\n return {\n result: result,\n rerender: (hookProps: Props) => rerenderComponent(<HookContainer hookProps={hookProps} />),\n unmount,\n };\n}\n\nexport async function renderHookAsync<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): Promise<RenderHookAsyncResult<Result, Props>> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function TestComponent({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, ...renderOptions } = options ?? {};\n const { rerenderAsync: rerenderComponentAsync, unmountAsync } = await renderAsync(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent hookProps={initialProps} />,\n renderOptions,\n );\n\n return {\n result: result,\n rerenderAsync: (hookProps: Props) =>\n rerenderComponentAsync(<TestComponent hookProps={hookProps} />),\n unmountAsync,\n };\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,YAAA,GAAAD,sBAAA,CAAAF,OAAA;AAAyC,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAG,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAT,uBAAA,YAAAA,CAAAK,CAAA,EAAAG,CAAA,SAAAA,CAAA,IAAAH,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,MAAAO,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAR,OAAA,EAAAF,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAS,CAAA,MAAAF,CAAA,GAAAJ,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAE,CAAA,CAAAI,GAAA,CAAAX,CAAA,UAAAO,CAAA,CAAAK,GAAA,CAAAZ,CAAA,GAAAO,CAAA,CAAAM,GAAA,CAAAb,CAAA,EAAAS,CAAA,gBAAAN,CAAA,IAAAH,CAAA,gBAAAG,CAAA,OAAAW,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAG,CAAA,OAAAK,CAAA,IAAAD,CAAA,GAAAS,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAG,CAAA,OAAAK,CAAA,CAAAI,GAAA,IAAAJ,CAAA,CAAAK,GAAA,I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