@testing-library/react-native 13.2.0 → 14.0.0-alpha.1

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 (159) hide show
  1. package/build/act.d.ts +5 -4
  2. package/build/act.js +3 -6
  3. package/build/act.js.map +1 -1
  4. package/build/config.d.ts +0 -10
  5. package/build/config.js +1 -2
  6. package/build/config.js.map +1 -1
  7. package/build/event-handler.d.ts +2 -2
  8. package/build/event-handler.js.map +1 -1
  9. package/build/fire-event.d.ts +7 -7
  10. package/build/fire-event.js +26 -4
  11. package/build/fire-event.js.map +1 -1
  12. package/build/helpers/accessibility.d.ts +14 -14
  13. package/build/helpers/accessibility.js +2 -2
  14. package/build/helpers/accessibility.js.map +1 -1
  15. package/build/helpers/component-tree.d.ts +7 -31
  16. package/build/helpers/component-tree.js +15 -73
  17. package/build/helpers/component-tree.js.map +1 -1
  18. package/build/helpers/debug.d.ts +2 -2
  19. package/build/helpers/debug.js +5 -4
  20. package/build/helpers/debug.js.map +1 -1
  21. package/build/helpers/find-all.d.ts +2 -3
  22. package/build/helpers/find-all.js +5 -5
  23. package/build/helpers/find-all.js.map +1 -1
  24. package/build/helpers/format-element.d.ts +4 -4
  25. package/build/helpers/format-element.js +6 -7
  26. package/build/helpers/format-element.js.map +1 -1
  27. package/build/helpers/host-component-names.d.ts +8 -8
  28. package/build/helpers/host-component-names.js +9 -7
  29. package/build/helpers/host-component-names.js.map +1 -1
  30. package/build/helpers/matchers/match-accessibility-state.d.ts +2 -2
  31. package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
  32. package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
  33. package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
  34. package/build/helpers/matchers/match-label-text.d.ts +2 -2
  35. package/build/helpers/matchers/match-label-text.js.map +1 -1
  36. package/build/helpers/matchers/match-text-content.d.ts +2 -2
  37. package/build/helpers/matchers/match-text-content.js.map +1 -1
  38. package/build/helpers/pointer-events.d.ts +2 -2
  39. package/build/helpers/pointer-events.js +1 -2
  40. package/build/helpers/pointer-events.js.map +1 -1
  41. package/build/helpers/text-content.d.ts +2 -2
  42. package/build/helpers/text-content.js.map +1 -1
  43. package/build/helpers/text-input.d.ts +3 -3
  44. package/build/helpers/text-input.js.map +1 -1
  45. package/build/helpers/wrap-async.d.ts +1 -0
  46. package/build/helpers/wrap-async.js +1 -0
  47. package/build/helpers/wrap-async.js.map +1 -1
  48. package/build/index.d.ts +1 -1
  49. package/build/index.flow.js +0 -1
  50. package/build/index.js +11 -1
  51. package/build/index.js.map +1 -1
  52. package/build/matchers/to-be-busy.d.ts +2 -2
  53. package/build/matchers/to-be-busy.js.map +1 -1
  54. package/build/matchers/to-be-checked.d.ts +2 -2
  55. package/build/matchers/to-be-checked.js.map +1 -1
  56. package/build/matchers/to-be-disabled.d.ts +3 -3
  57. package/build/matchers/to-be-disabled.js +1 -2
  58. package/build/matchers/to-be-disabled.js.map +1 -1
  59. package/build/matchers/to-be-empty-element.d.ts +2 -2
  60. package/build/matchers/to-be-empty-element.js +2 -3
  61. package/build/matchers/to-be-empty-element.js.map +1 -1
  62. package/build/matchers/to-be-expanded.d.ts +3 -3
  63. package/build/matchers/to-be-expanded.js.map +1 -1
  64. package/build/matchers/to-be-on-the-screen.d.ts +2 -2
  65. package/build/matchers/to-be-on-the-screen.js +1 -1
  66. package/build/matchers/to-be-on-the-screen.js.map +1 -1
  67. package/build/matchers/to-be-partially-checked.d.ts +2 -2
  68. package/build/matchers/to-be-partially-checked.js.map +1 -1
  69. package/build/matchers/to-be-selected.d.ts +2 -2
  70. package/build/matchers/to-be-selected.js.map +1 -1
  71. package/build/matchers/to-be-visible.d.ts +2 -2
  72. package/build/matchers/to-be-visible.js +1 -2
  73. package/build/matchers/to-be-visible.js.map +1 -1
  74. package/build/matchers/to-contain-element.d.ts +2 -2
  75. package/build/matchers/to-contain-element.js +2 -1
  76. package/build/matchers/to-contain-element.js.map +1 -1
  77. package/build/matchers/to-have-accessibility-value.d.ts +2 -2
  78. package/build/matchers/to-have-accessibility-value.js.map +1 -1
  79. package/build/matchers/to-have-accessible-name.d.ts +2 -2
  80. package/build/matchers/to-have-accessible-name.js.map +1 -1
  81. package/build/matchers/to-have-display-value.d.ts +2 -2
  82. package/build/matchers/to-have-display-value.js.map +1 -1
  83. package/build/matchers/to-have-prop.d.ts +2 -2
  84. package/build/matchers/to-have-prop.js.map +1 -1
  85. package/build/matchers/to-have-style.d.ts +2 -2
  86. package/build/matchers/to-have-style.js.map +1 -1
  87. package/build/matchers/to-have-text-content.d.ts +2 -2
  88. package/build/matchers/to-have-text-content.js.map +1 -1
  89. package/build/matchers/types.d.ts +2 -2
  90. package/build/matchers/types.js.map +1 -1
  91. package/build/matchers/utils.d.ts +3 -3
  92. package/build/matchers/utils.js +3 -4
  93. package/build/matchers/utils.js.map +1 -1
  94. package/build/native-state.d.ts +3 -3
  95. package/build/native-state.js.map +1 -1
  96. package/build/pure.d.ts +1 -1
  97. package/build/pure.js +2 -2
  98. package/build/pure.js.map +1 -1
  99. package/build/queries/display-value.d.ts +2 -2
  100. package/build/queries/display-value.js.map +1 -1
  101. package/build/queries/hint-text.d.ts +2 -2
  102. package/build/queries/hint-text.js.map +1 -1
  103. package/build/queries/label-text.d.ts +2 -2
  104. package/build/queries/label-text.js.map +1 -1
  105. package/build/queries/make-queries.d.ts +9 -9
  106. package/build/queries/make-queries.js.map +1 -1
  107. package/build/queries/placeholder-text.d.ts +2 -2
  108. package/build/queries/placeholder-text.js.map +1 -1
  109. package/build/queries/role.d.ts +2 -2
  110. package/build/queries/role.js.map +1 -1
  111. package/build/queries/test-id.d.ts +2 -2
  112. package/build/queries/test-id.js.map +1 -1
  113. package/build/queries/text.d.ts +2 -2
  114. package/build/queries/text.js.map +1 -1
  115. package/build/render-hook.js +1 -1
  116. package/build/render-hook.js.map +1 -1
  117. package/build/render.d.ts +20 -121
  118. package/build/render.js +27 -67
  119. package/build/render.js.map +1 -1
  120. package/build/screen.js +1 -9
  121. package/build/screen.js.map +1 -1
  122. package/build/tsconfig.release.tsbuildinfo +1 -1
  123. package/build/user-event/clear.d.ts +2 -2
  124. package/build/user-event/clear.js.map +1 -1
  125. package/build/user-event/index.d.ts +7 -7
  126. package/build/user-event/index.js.map +1 -1
  127. package/build/user-event/paste.d.ts +2 -2
  128. package/build/user-event/paste.js.map +1 -1
  129. package/build/user-event/press/press.d.ts +3 -3
  130. package/build/user-event/press/press.js +1 -10
  131. package/build/user-event/press/press.js.map +1 -1
  132. package/build/user-event/scroll/scroll-to.d.ts +2 -2
  133. package/build/user-event/scroll/scroll-to.js.map +1 -1
  134. package/build/user-event/setup/setup.d.ts +7 -7
  135. package/build/user-event/setup/setup.js.map +1 -1
  136. package/build/user-event/type/type.d.ts +3 -3
  137. package/build/user-event/type/type.js.map +1 -1
  138. package/build/user-event/utils/dispatch-event.d.ts +2 -2
  139. package/build/user-event/utils/dispatch-event.js.map +1 -1
  140. package/build/within.d.ts +20 -36
  141. package/build/within.js +3 -7
  142. package/build/within.js.map +1 -1
  143. package/package.json +8 -8
  144. package/typings/index.flow.js +0 -1
  145. package/build/helpers/ensure-peer-deps.d.ts +0 -3
  146. package/build/helpers/ensure-peer-deps.js +0 -32
  147. package/build/helpers/ensure-peer-deps.js.map +0 -1
  148. package/build/helpers/string-validation.d.ts +0 -2
  149. package/build/helpers/string-validation.js +0 -31
  150. package/build/helpers/string-validation.js.map +0 -1
  151. package/build/queries/unsafe-props.d.ts +0 -10
  152. package/build/queries/unsafe-props.js +0 -49
  153. package/build/queries/unsafe-props.js.map +0 -1
  154. package/build/queries/unsafe-type.d.ts +0 -10
  155. package/build/queries/unsafe-type.js +0 -49
  156. package/build/queries/unsafe-type.js.map +0 -1
  157. package/build/render-act.d.ts +0 -2
  158. package/build/render-act.js +0 -22
  159. package/build/render-act.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"component-tree.js","names":["_screen","require","isHostElement","element","type","isElementMounted","getUnsafeRootElement","screen","UNSAFE_root","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelves","getHostSiblings","hostParent","hostSelves","filter","sibling","includes"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport { screen } from '../screen';\n/**\n * ReactTestInstance referring to host element.\n */\nexport type HostTestInstance = ReactTestInstance & { type: string };\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(element?: ReactTestInstance | null): element is HostTestInstance {\n return typeof element?.type === 'string';\n}\n\nexport function isElementMounted(element: ReactTestInstance) {\n return getUnsafeRootElement(element) === screen.UNSAFE_root;\n}\n\n/**\n * Returns first host ancestor for given element.\n * @param element The element start traversing from.\n */\nexport function getHostParent(element: ReactTestInstance | null): HostTestInstance | null {\n if (element == null) {\n return null;\n }\n\n let current = element.parent;\n while (current) {\n if (isHostElement(current)) {\n return current;\n }\n\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Returns host children for given element.\n * @param element The element start traversing from.\n */\nexport function getHostChildren(element: ReactTestInstance | null): HostTestInstance[] {\n if (element == null) {\n return [];\n }\n\n const hostChildren: HostTestInstance[] = [];\n\n element.children.forEach((child) => {\n if (typeof child !== 'object') {\n return;\n }\n\n if (isHostElement(child)) {\n hostChildren.push(child);\n } else {\n hostChildren.push(...getHostChildren(child));\n }\n });\n\n return hostChildren;\n}\n\n/**\n * Return the array of host elements that represent the passed element.\n *\n * @param element The element start traversing from.\n * @returns If the passed element is a host element, it will return an array containing only that element,\n * if the passed element is a composite element, it will return an array containing its host children (zero, one or many).\n */\nexport function getHostSelves(element: ReactTestInstance | null): HostTestInstance[] {\n return isHostElement(element) ? [element] : getHostChildren(element);\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(element: ReactTestInstance | null): HostTestInstance[] {\n const hostParent = getHostParent(element);\n const hostSelves = getHostSelves(element);\n return getHostChildren(hostParent).filter((sibling) => !hostSelves.includes(sibling));\n}\n\n/**\n * Returns the unsafe root element of the tree (probably composite).\n *\n * @param element The element start traversing from.\n * @returns The root element of the tree (host or composite).\n */\nexport function getUnsafeRootElement(element: ReactTestInstance) {\n let current = element;\n while (current.parent) {\n current = current.parent;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,OAAkC,EAA+B;EAC7F,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ;AAC1C;AAEO,SAASC,gBAAgBA,CAACF,OAA0B,EAAE;EAC3D,OAAOG,oBAAoB,CAACH,OAAO,CAAC,KAAKI,cAAM,CAACC,WAAW;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACN,OAAiC,EAA2B;EACxF,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIO,OAAO,GAAGP,OAAO,CAACQ,MAAM;EAC5B,OAAOD,OAAO,EAAE;IACd,IAAIR,aAAa,CAACQ,OAAO,CAAC,EAAE;MAC1B,OAAOA,OAAO;IAChB;IAEAA,OAAO,GAAGA,OAAO,CAACC,MAAM;EAC1B;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACT,OAAiC,EAAsB;EACrF,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,EAAE;EACX;EAEA,MAAMU,YAAgC,GAAG,EAAE;EAE3CV,OAAO,CAACW,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;IAClC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IAEA,IAAId,aAAa,CAACc,KAAK,CAAC,EAAE;MACxBH,YAAY,CAACI,IAAI,CAACD,KAAK,CAAC;IAC1B,CAAC,MAAM;MACLH,YAAY,CAACI,IAAI,CAAC,GAAGL,eAAe,CAACI,KAAK,CAAC,CAAC;IAC9C;EACF,CAAC,CAAC;EAEF,OAAOH,YAAY;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,aAAaA,CAACf,OAAiC,EAAsB;EACnF,OAAOD,aAAa,CAACC,OAAO,CAAC,GAAG,CAACA,OAAO,CAAC,GAAGS,eAAe,CAACT,OAAO,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACO,SAASgB,eAAeA,CAAChB,OAAiC,EAAsB;EACrF,MAAMiB,UAAU,GAAGX,aAAa,CAACN,OAAO,CAAC;EACzC,MAAMkB,UAAU,GAAGH,aAAa,CAACf,OAAO,CAAC;EACzC,OAAOS,eAAe,CAACQ,UAAU,CAAC,CAACE,MAAM,CAAEC,OAAO,IAAK,CAACF,UAAU,CAACG,QAAQ,CAACD,OAAO,CAAC,CAAC;AACvF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASjB,oBAAoBA,CAACH,OAA0B,EAAE;EAC/D,IAAIO,OAAO,GAAGP,OAAO;EACrB,OAAOO,OAAO,CAACC,MAAM,EAAE;IACrBD,OAAO,GAAGA,OAAO,CAACC,MAAM;EAC1B;EAEA,OAAOD,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"component-tree.js","names":["_universalTestRenderer","require","_screen","isValidElement","element","type","CONTAINER_TYPE","isElementMounted","getContainerElement","screen","container","current","parent","getHostSiblings","hostParent","children","filter","sibling"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\nimport { CONTAINER_TYPE } from 'universal-test-renderer';\n\nimport { screen } from '../screen';\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isValidElement(element?: HostElement | null): element is HostElement {\n return typeof element?.type === 'string' && element.type !== CONTAINER_TYPE;\n}\n\nexport function isElementMounted(element: HostElement) {\n return getContainerElement(element) === screen.container;\n}\n\n/**\n * Returns the unsafe root element of the tree (probably composite).\n *\n * @param element The element start traversing from.\n * @returns The root element of the tree (host or composite).\n */\nexport function getContainerElement(element: HostElement) {\n let current: HostElement | null = element;\n while (current?.parent) {\n current = current.parent;\n }\n\n return current;\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(element: HostElement | null): HostElement[] {\n const hostParent = element?.parent ?? null;\n return (\n hostParent?.children.filter(\n (sibling): sibling is HostElement => typeof sibling === 'object' && sibling !== element,\n ) ?? []\n );\n}\n"],"mappings":";;;;;;;;;AACA,IAAAA,sBAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASE,cAAcA,CAACC,OAA4B,EAA0B;EACnF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAID,OAAO,CAACC,IAAI,KAAKC,qCAAc;AAC7E;AAEO,SAASC,gBAAgBA,CAACH,OAAoB,EAAE;EACrD,OAAOI,mBAAmB,CAACJ,OAAO,CAAC,KAAKK,cAAM,CAACC,SAAS;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASF,mBAAmBA,CAACJ,OAAoB,EAAE;EACxD,IAAIO,OAA2B,GAAGP,OAAO;EACzC,OAAOO,OAAO,EAAEC,MAAM,EAAE;IACtBD,OAAO,GAAGA,OAAO,CAACC,MAAM;EAC1B;EAEA,OAAOD,OAAO;AAChB;;AAEA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAACT,OAA2B,EAAiB;EAC1E,MAAMU,UAAU,GAAGV,OAAO,EAAEQ,MAAM,IAAI,IAAI;EAC1C,OACEE,UAAU,EAAEC,QAAQ,CAACC,MAAM,CACxBC,OAAO,IAA6B,OAAOA,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAKb,OAClF,CAAC,IAAI,EAAE;AAEX","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestRendererJSON } from 'react-test-renderer';
1
+ import type { JsonNode } from 'universal-test-renderer';
2
2
  import type { FormatElementOptions } from './format-element';
3
3
  export type DebugOptions = {
4
4
  message?: string;
@@ -6,4 +6,4 @@ export type DebugOptions = {
6
6
  /**
7
7
  * Log pretty-printed deep test component instance
8
8
  */
9
- export declare function debug(instance: ReactTestRendererJSON | ReactTestRendererJSON[], { message, ...formatOptions }?: DebugOptions): void;
9
+ export declare function debug(instance: JsonNode | JsonNode[], options?: DebugOptions): void;
@@ -9,10 +9,11 @@ var _logger = require("./logger");
9
9
  /**
10
10
  * Log pretty-printed deep test component instance
11
11
  */
12
- function debug(instance, {
13
- message,
14
- ...formatOptions
15
- } = {}) {
12
+ function debug(instance, options) {
13
+ const message = options?.message;
14
+ const formatOptions = {
15
+ mapProps: options?.mapProps
16
+ };
16
17
  if (message) {
17
18
  _logger.logger.info(`${message}\n\n`, (0, _formatElement.formatJson)(instance, formatOptions));
18
19
  } else {
@@ -1 +1 @@
1
- {"version":3,"file":"debug.js","names":["_formatElement","require","_logger","debug","instance","message","formatOptions","logger","info","formatJson"],"sources":["../../src/helpers/debug.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\n\nimport type { FormatElementOptions } from './format-element';\nimport { formatJson } from './format-element';\nimport { logger } from './logger';\n\nexport type DebugOptions = {\n message?: string;\n} & FormatElementOptions;\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport function debug(\n instance: ReactTestRendererJSON | ReactTestRendererJSON[],\n { message, ...formatOptions }: DebugOptions = {},\n) {\n if (message) {\n logger.info(`${message}\\n\\n`, formatJson(instance, formatOptions));\n } else {\n logger.info(formatJson(instance, formatOptions));\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA;AACA;AACA;AACO,SAASE,KAAKA,CACnBC,QAAyD,EACzD;EAAEC,OAAO;EAAE,GAAGC;AAA4B,CAAC,GAAG,CAAC,CAAC,EAChD;EACA,IAAID,OAAO,EAAE;IACXE,cAAM,CAACC,IAAI,CAAC,GAAGH,OAAO,MAAM,EAAE,IAAAI,yBAAU,EAACL,QAAQ,EAAEE,aAAa,CAAC,CAAC;EACpE,CAAC,MAAM;IACLC,cAAM,CAACC,IAAI,CAAC,IAAAC,yBAAU,EAACL,QAAQ,EAAEE,aAAa,CAAC,CAAC;EAClD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"debug.js","names":["_formatElement","require","_logger","debug","instance","options","message","formatOptions","mapProps","logger","info","formatJson"],"sources":["../../src/helpers/debug.ts"],"sourcesContent":["import type { JsonNode } from 'universal-test-renderer';\n\nimport type { FormatElementOptions } from './format-element';\nimport { formatJson } from './format-element';\nimport { logger } from './logger';\n\nexport type DebugOptions = {\n message?: string;\n} & FormatElementOptions;\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport function debug(instance: JsonNode | JsonNode[], options?: DebugOptions) {\n const message = options?.message;\n const formatOptions = { mapProps: options?.mapProps };\n\n if (message) {\n logger.info(`${message}\\n\\n`, formatJson(instance, formatOptions));\n } else {\n logger.info(formatJson(instance, formatOptions));\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA;AACA;AACA;AACO,SAASE,KAAKA,CAACC,QAA+B,EAAEC,OAAsB,EAAE;EAC7E,MAAMC,OAAO,GAAGD,OAAO,EAAEC,OAAO;EAChC,MAAMC,aAAa,GAAG;IAAEC,QAAQ,EAAEH,OAAO,EAAEG;EAAS,CAAC;EAErD,IAAIF,OAAO,EAAE;IACXG,cAAM,CAACC,IAAI,CAAC,GAAGJ,OAAO,MAAM,EAAE,IAAAK,yBAAU,EAACP,QAAQ,EAAEG,aAAa,CAAC,CAAC;EACpE,CAAC,MAAM;IACLE,cAAM,CAACC,IAAI,CAAC,IAAAC,yBAAU,EAACP,QAAQ,EAAEG,aAAa,CAAC,CAAC;EAClD;AACF","ignoreList":[]}
@@ -1,5 +1,4 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import type { HostTestInstance } from './component-tree';
1
+ import type { HostElement } from 'universal-test-renderer';
3
2
  interface FindAllOptions {
4
3
  /** Match elements hidden from accessibility */
5
4
  includeHiddenElements?: boolean;
@@ -7,5 +6,5 @@ interface FindAllOptions {
7
6
  hidden?: boolean;
8
7
  matchDeepestOnly?: boolean;
9
8
  }
10
- export declare function findAll(root: ReactTestInstance, predicate: (element: ReactTestInstance) => boolean, options?: FindAllOptions): HostTestInstance[];
9
+ export declare function findAll(root: HostElement, predicate: (element: HostElement) => boolean, options?: FindAllOptions): HostElement[];
11
10
  export {};
@@ -21,21 +21,21 @@ function findAll(root, predicate, options) {
21
21
 
22
22
  // Extracted from React Test Renderer
23
23
  // src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402
24
- function findAllInternal(root, predicate, options) {
24
+ function findAllInternal(node, predicate, options, indent = '') {
25
25
  const results = [];
26
26
 
27
27
  // Match descendants first but do not add them to results yet.
28
28
  const matchingDescendants = [];
29
- root.children.forEach(child => {
29
+ node.children.forEach(child => {
30
30
  if (typeof child === 'string') {
31
31
  return;
32
32
  }
33
- matchingDescendants.push(...findAllInternal(child, predicate, options));
33
+ matchingDescendants.push(...findAllInternal(child, predicate, options, indent + ' '));
34
34
  });
35
35
  if (
36
36
  // When matchDeepestOnly = true: add current element only if no descendants match
37
- (!options?.matchDeepestOnly || matchingDescendants.length === 0) && (0, _componentTree.isHostElement)(root) && predicate(root)) {
38
- results.push(root);
37
+ (!options?.matchDeepestOnly || matchingDescendants.length === 0) && (0, _componentTree.isValidElement)(node) && predicate(node)) {
38
+ results.push(node);
39
39
  }
40
40
 
41
41
  // Add matching descendants after element to preserve original tree walk order.
@@ -1 +1 @@
1
- {"version":3,"file":"find-all.js","names":["_config","require","_accessibility","_componentTree","findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length","isHostElement"],"sources":["../../src/helpers/find-all.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessibility';\nimport type { HostTestInstance } from './component-tree';\nimport { isHostElement } from './component-tree';\n\ninterface FindAllOptions {\n /** Match elements hidden from accessibility */\n includeHiddenElements?: boolean;\n\n /** RTL-compatible alias to `includeHiddenElements` */\n hidden?: boolean;\n\n /* Exclude any ancestors of deepest matched elements even if they match the predicate */\n matchDeepestOnly?: boolean;\n}\n\nexport function findAll(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions,\n): HostTestInstance[] {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ?? options?.hidden ?? getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<ReactTestInstance>();\n return results.filter((element) => !isHiddenFromAccessibility(element, { cache }));\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions,\n): HostTestInstance[] {\n const results: HostTestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: HostTestInstance[] = [];\n root.children.forEach((child) => {\n if (typeof child === 'string') {\n return;\n }\n matchingDescendants.push(...findAllInternal(child, predicate, options));\n });\n\n if (\n // When matchDeepestOnly = true: add current element only if no descendants match\n (!options?.matchDeepestOnly || matchingDescendants.length === 0) &&\n isHostElement(root) &&\n predicate(root)\n ) {\n results.push(root);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n"],"mappings":";;;;;;A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AAI,CAAC,GAAGJ,mBAAmB,CAAC;EAEpC,OAAOX,OAAO;AAChB","ignoreList":[]}
1
+ {"version":3,"file":"find-all.js","names":["_config","require","_accessibility","_componentTree","findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","node","indent","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length","isValidElement"],"sources":["../../src/helpers/find-all.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessibility';\nimport { isValidElement } from './component-tree';\n\ninterface FindAllOptions {\n /** Match elements hidden from accessibility */\n includeHiddenElements?: boolean;\n\n /** RTL-compatible alias to `includeHiddenElements` */\n hidden?: boolean;\n\n /* Exclude any ancestors of deepest matched elements even if they match the predicate */\n matchDeepestOnly?: boolean;\n}\n\nexport function findAll(\n root: HostElement,\n predicate: (element: HostElement) => boolean,\n options?: FindAllOptions,\n): HostElement[] {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ?? options?.hidden ?? getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<HostElement>();\n return results.filter((element) => !isHiddenFromAccessibility(element, { cache }));\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n node: HostElement,\n predicate: (element: HostElement) => boolean,\n options?: FindAllOptions,\n indent: string = '',\n): HostElement[] {\n const results: HostElement[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: HostElement[] = [];\n node.children.forEach((child) => {\n if (typeof child === 'string') {\n return;\n }\n matchingDescendants.push(...findAllInternal(child, predicate, options, indent + ' '));\n });\n\n if (\n // When matchDeepestOnly = true: add current element only if no descendants match\n (!options?.matchDeepestOnly || matchingDescendants.length === 0) &&\n isValidElement(node) &&\n predicate(node)\n ) {\n results.push(node);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AAaO,SAASG,OAAOA,CACrBC,IAAiB,EACjBC,SAA4C,EAC5CC,OAAwB,EACT;EACf,MAAMC,OAAO,GAAGC,eAAe,CAACJ,IAAI,EAAEC,SAAS,EAAEC,OAAO,CAAC;EAEzD,MAAMG,qBAAqB,GACzBH,OAAO,EAAEG,qBAAqB,IAAIH,OAAO,EAAEI,MAAM,IAAI,IAAAC,iBAAS,EAAC,CAAC,EAAEC,4BAA4B;EAEhG,IAAIH,qBAAqB,EAAE;IACzB,OAAOF,OAAO;EAChB;EAEA,MAAMM,KAAK,GAAG,IAAIC,OAAO,CAAc,CAAC;EACxC,OAAOP,OAAO,CAACQ,MAAM,CAAEC,OAAO,IAAK,CAAC,IAAAC,wCAAyB,EAACD,OAAO,EAAE;IAAEH;EAAM,CAAC,CAAC,CAAC;AACpF;;AAEA;AACA;AACA,SAASL,eAAeA,CACtBU,IAAiB,EACjBb,SAA4C,EAC5CC,OAAwB,EACxBa,MAAc,GAAG,EAAE,EACJ;EACf,MAAMZ,OAAsB,GAAG,EAAE;;EAEjC;EACA,MAAMa,mBAAkC,GAAG,EAAE;EAC7CF,IAAI,CAACG,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;IAC/B,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IACAH,mBAAmB,CAACI,IAAI,CAAC,GAAGhB,eAAe,CAACe,KAAK,EAAElB,SAAS,EAAEC,OAAO,EAAEa,MAAM,GAAG,IAAI,CAAC,CAAC;EACxF,CAAC,CAAC;EAEF;EACE;EACA,CAAC,CAACb,OAAO,EAAEmB,gBAAgB,IAAIL,mBAAmB,CAACM,MAAM,KAAK,CAAC,KAC/D,IAAAC,6BAAc,EAACT,IAAI,CAAC,IACpBb,SAAS,CAACa,IAAI,CAAC,EACf;IACAX,OAAO,CAACiB,IAAI,CAACN,IAAI,CAAC;EACpB;;EAEA;EACAX,OAAO,CAACiB,IAAI,CAAC,GAAGJ,mBAAmB,CAAC;EAEpC,OAAOb,OAAO;AAChB","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestInstance, ReactTestRendererJSON } from 'react-test-renderer';
1
+ import type { HostNode, JsonNode } from 'universal-test-renderer';
2
2
  import type { MapPropsFunction } from './map-props';
3
3
  export type FormatElementOptions = {
4
4
  /** Minimize used space. */
@@ -13,6 +13,6 @@ export type FormatElementOptions = {
13
13
  *
14
14
  * @param element Element to format.
15
15
  */
16
- export declare function formatElement(element: ReactTestInstance | null, { compact, highlight, mapProps }?: FormatElementOptions): string;
17
- export declare function formatElementList(elements: ReactTestInstance[], options?: FormatElementOptions): string;
18
- export declare function formatJson(json: ReactTestRendererJSON | ReactTestRendererJSON[], { compact, highlight, mapProps }?: FormatElementOptions): string;
16
+ export declare function formatElement(element: HostNode | null, { compact, highlight, mapProps }?: FormatElementOptions): string;
17
+ export declare function formatElementList(elements: HostNode[], options?: FormatElementOptions): string;
18
+ export declare function formatJson(json: JsonNode | JsonNode[], { compact, highlight, mapProps }?: FormatElementOptions): string;
@@ -23,22 +23,21 @@ function formatElement(element, {
23
23
  if (element == null) {
24
24
  return '(null)';
25
25
  }
26
- const {
27
- children,
28
- ...props
29
- } = element.props;
30
- const childrenToDisplay = typeof children === 'string' ? [children] : undefined;
26
+ if (typeof element === 'string') {
27
+ return element;
28
+ }
29
+ const childrenToDisplay = element.children.filter(child => typeof child === 'string');
31
30
  return (0, _prettyFormat.default)({
32
31
  // This prop is needed persuade the prettyFormat that the element is
33
32
  // a ReactTestRendererJSON instance, so it is formatted as JSX.
34
33
  $$typeof: Symbol.for('react.test.json'),
35
34
  type: `${element.type}`,
36
- props: mapProps ? mapProps(props) : props,
35
+ props: mapProps ? mapProps(element.props) : element.props,
37
36
  children: childrenToDisplay
38
37
  },
39
38
  // See: https://www.npmjs.com/package/pretty-format#usage-with-options
40
39
  {
41
- plugins: [_prettyFormat.plugins.ReactTestComponent, _prettyFormat.plugins.ReactElement],
40
+ plugins: [_prettyFormat.plugins.ReactTestComponent],
42
41
  printFunctionName: false,
43
42
  printBasicPrototype: false,
44
43
  highlight: highlight,
@@ -1 +1 @@
1
- {"version":3,"file":"format-element.js","names":["_prettyFormat","_interopRequireWildcard","require","_mapProps","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","formatElement","element","compact","highlight","mapProps","defaultMapProps","children","props","childrenToDisplay","undefined","prettyFormat","$$typeof","Symbol","for","type","plugins","ReactTestComponent","ReactElement","printFunctionName","printBasicPrototype","min","formatElementList","elements","options","length","map","join","formatJson","json","getElementJsonPlugin","test","val","serialize","config","indentation","depth","refs","printer","newVal"],"sources":["../../src/helpers/format-element.ts"],"sourcesContent":["import type { ReactTestInstance, ReactTestRendererJSON } from 'react-test-renderer';\nimport type { NewPlugin } from 'pretty-format';\nimport prettyFormat, { plugins } from 'pretty-format';\n\nimport type { MapPropsFunction } from './map-props';\nimport { defaultMapProps } from './map-props';\n\nexport type FormatElementOptions = {\n /** Minimize used space. */\n compact?: boolean;\n\n /** Highlight the output. */\n highlight?: boolean;\n\n /** Filter or map props to display. */\n mapProps?: MapPropsFunction | null;\n};\n\n/***\n * Format given element as a pretty-printed string.\n *\n * @param element Element to format.\n */\nexport function formatElement(\n element: ReactTestInstance | null,\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n if (element == null) {\n return '(null)';\n }\n\n const { children, ...props } = element.props;\n const childrenToDisplay = typeof children === 'string' ? [children] : undefined;\n\n return prettyFormat(\n {\n // This prop is needed persuade the prettyFormat that the element is\n // a ReactTestRendererJSON instance, so it is formatted as JSX.\n $$typeof: Symbol.for('react.test.json'),\n type: `${element.type}`,\n props: mapProps ? mapProps(props) : props,\n children: childrenToDisplay,\n },\n // See: https://www.npmjs.com/package/pretty-format#usage-with-options\n {\n plugins: [plugins.ReactTestComponent, plugins.ReactElement],\n printFunctionName: false,\n printBasicPrototype: false,\n highlight: highlight,\n min: compact,\n },\n );\n}\n\nexport function formatElementList(elements: ReactTestInstance[], options?: FormatElementOptions) {\n if (elements.length === 0) {\n return '(no elements)';\n }\n\n return elements.map((element) => formatElement(element, options)).join('\\n');\n}\n\nexport function formatJson(\n json: ReactTestRendererJSON | ReactTestRendererJSON[],\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n return prettyFormat(json, {\n plugins: [getElementJsonPlugin(mapProps), plugins.ReactElement],\n highlight: highlight,\n printBasicPrototype: false,\n min: compact,\n });\n}\n\nfunction getElementJsonPlugin(mapProps?: MapPropsFunction | null): NewPlugin {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer,\n );\n },\n };\n}\n"],"mappings":";;;;;;;;AAEA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AAA8C,SAAAE,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,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAA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,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,KAAK;MAC7D,IAAIC,MAAM,GAAGP,GAAG;MAChB,IAAI3B,QAAQ,IAAI2B,GAAG,CAACxB,KAAK,EAAE;QACzB+B,MAAM,GAAG;UAAE,GAAGP,GAAG;UAAExB,KAAK,EAAEH,QAAQ,CAAC2B,GAAG,CAACxB,KAAK;QAAE,CAAC;MACjD;MACA,OAAOQ,qBAAO,CAACC,kBAAkB,CAACgB,SAAS,CACzCM,MAAM,EACNL,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,IAAI,EACJC,OACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"format-element.js","names":["_prettyFormat","_interopRequireWildcard","require","_mapProps","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","formatElement","element","compact","highlight","mapProps","defaultMapProps","childrenToDisplay","children","filter","child","prettyFormat","$$typeof","Symbol","for","type","props","plugins","ReactTestComponent","printFunctionName","printBasicPrototype","min","formatElementList","elements","options","length","map","join","formatJson","json","getElementJsonPlugin","ReactElement","test","val","serialize","config","indentation","depth","refs","printer","newVal"],"sources":["../../src/helpers/format-element.ts"],"sourcesContent":["import type { NewPlugin } from 'pretty-format';\nimport prettyFormat, { plugins } from 'pretty-format';\nimport type { HostNode, JsonNode } from 'universal-test-renderer';\n\nimport type { MapPropsFunction } from './map-props';\nimport { defaultMapProps } from './map-props';\n\nexport type FormatElementOptions = {\n /** Minimize used space. */\n compact?: boolean;\n\n /** Highlight the output. */\n highlight?: boolean;\n\n /** Filter or map props to display. */\n mapProps?: MapPropsFunction | null;\n};\n\n/***\n * Format given element as a pretty-printed string.\n *\n * @param element Element to format.\n */\nexport function formatElement(\n element: HostNode | null,\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n if (element == null) {\n return '(null)';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const childrenToDisplay = element.children.filter((child) => typeof child === 'string');\n\n return prettyFormat(\n {\n // This prop is needed persuade the prettyFormat that the element is\n // a ReactTestRendererJSON instance, so it is formatted as JSX.\n $$typeof: Symbol.for('react.test.json'),\n type: `${element.type}`,\n props: mapProps ? mapProps(element.props) : element.props,\n children: childrenToDisplay,\n },\n // See: https://www.npmjs.com/package/pretty-format#usage-with-options\n {\n plugins: [plugins.ReactTestComponent],\n printFunctionName: false,\n printBasicPrototype: false,\n highlight: highlight,\n min: compact,\n },\n );\n}\n\nexport function formatElementList(elements: HostNode[], options?: FormatElementOptions) {\n if (elements.length === 0) {\n return '(no elements)';\n }\n\n return elements.map((element) => formatElement(element, options)).join('\\n');\n}\n\nexport function formatJson(\n json: JsonNode | JsonNode[],\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n return prettyFormat(json, {\n plugins: [getElementJsonPlugin(mapProps), plugins.ReactElement],\n highlight: highlight,\n printBasicPrototype: false,\n min: compact,\n });\n}\n\nfunction getElementJsonPlugin(mapProps?: MapPropsFunction | null): NewPlugin {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer,\n );\n },\n };\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAA8C,SAAAE,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,SAAAJ,wBAAAI,CAAA,EAAAE,CA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qBAAO,CAACC,kBAAkB,CAACc,IAAI,CAACC,GAAG,CAAC;IACnDC,SAAS,EAAEA,CAACD,GAAG,EAAEE,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,KAAK;MAC7D,IAAIC,MAAM,GAAGP,GAAG;MAChB,IAAI5B,QAAQ,IAAI4B,GAAG,CAACjB,KAAK,EAAE;QACzBwB,MAAM,GAAG;UAAE,GAAGP,GAAG;UAAEjB,KAAK,EAAEX,QAAQ,CAAC4B,GAAG,CAACjB,KAAK;QAAE,CAAC;MACjD;MACA,OAAOC,qBAAO,CAACC,kBAAkB,CAACgB,SAAS,CACzCM,MAAM,EACNL,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,IAAI,EACJC,OACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,32 +1,32 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- import type { HostTestInstance } from './component-tree';
1
+ import type { HostElement } from 'universal-test-renderer';
2
+ export declare const HOST_TEXT_NAMES: string[];
3
3
  /**
4
4
  * Checks if the given element is a host Text element.
5
5
  * @param element The element to check.
6
6
  */
7
- export declare function isHostText(element: ReactTestInstance): element is HostTestInstance;
7
+ export declare function isHostText(element: HostElement | null): boolean;
8
8
  /**
9
9
  * Checks if the given element is a host TextInput element.
10
10
  * @param element The element to check.
11
11
  */
12
- export declare function isHostTextInput(element: ReactTestInstance): element is HostTestInstance;
12
+ export declare function isHostTextInput(element: HostElement | null): boolean;
13
13
  /**
14
14
  * Checks if the given element is a host Image element.
15
15
  * @param element The element to check.
16
16
  */
17
- export declare function isHostImage(element: ReactTestInstance): element is HostTestInstance;
17
+ export declare function isHostImage(element: HostElement | null): boolean;
18
18
  /**
19
19
  * Checks if the given element is a host Switch element.
20
20
  * @param element The element to check.
21
21
  */
22
- export declare function isHostSwitch(element: ReactTestInstance): element is HostTestInstance;
22
+ export declare function isHostSwitch(element: HostElement | null): boolean;
23
23
  /**
24
24
  * Checks if the given element is a host ScrollView element.
25
25
  * @param element The element to check.
26
26
  */
27
- export declare function isHostScrollView(element: ReactTestInstance): element is HostTestInstance;
27
+ export declare function isHostScrollView(element: HostElement | null): boolean;
28
28
  /**
29
29
  * Checks if the given element is a host Modal element.
30
30
  * @param element The element to check.
31
31
  */
32
- export declare function isHostModal(element: ReactTestInstance): element is HostTestInstance;
32
+ export declare function isHostModal(element: HostElement | null): boolean;
@@ -3,13 +3,15 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ exports.HOST_TEXT_NAMES = void 0;
6
7
  exports.isHostImage = isHostImage;
7
8
  exports.isHostModal = isHostModal;
8
9
  exports.isHostScrollView = isHostScrollView;
9
10
  exports.isHostSwitch = isHostSwitch;
10
11
  exports.isHostText = isHostText;
11
12
  exports.isHostTextInput = isHostTextInput;
12
- const HOST_TEXT_NAMES = ['Text', 'RCTText'];
13
+ var _componentTree = require("./component-tree");
14
+ const HOST_TEXT_NAMES = exports.HOST_TEXT_NAMES = ['Text', 'RCTText'];
13
15
  const HOST_TEXT_INPUT_NAMES = ['TextInput'];
14
16
  const HOST_IMAGE_NAMES = ['Image'];
15
17
  const HOST_SWITCH_NAMES = ['RCTSwitch'];
@@ -21,7 +23,7 @@ const HOST_MODAL_NAMES = ['Modal'];
21
23
  * @param element The element to check.
22
24
  */
23
25
  function isHostText(element) {
24
- return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);
26
+ return (0, _componentTree.isValidElement)(element) && HOST_TEXT_NAMES.includes(element.type);
25
27
  }
26
28
 
27
29
  /**
@@ -29,7 +31,7 @@ function isHostText(element) {
29
31
  * @param element The element to check.
30
32
  */
31
33
  function isHostTextInput(element) {
32
- return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);
34
+ return (0, _componentTree.isValidElement)(element) && HOST_TEXT_INPUT_NAMES.includes(element.type);
33
35
  }
34
36
 
35
37
  /**
@@ -37,7 +39,7 @@ function isHostTextInput(element) {
37
39
  * @param element The element to check.
38
40
  */
39
41
  function isHostImage(element) {
40
- return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);
42
+ return (0, _componentTree.isValidElement)(element) && HOST_IMAGE_NAMES.includes(element.type);
41
43
  }
42
44
 
43
45
  /**
@@ -45,7 +47,7 @@ function isHostImage(element) {
45
47
  * @param element The element to check.
46
48
  */
47
49
  function isHostSwitch(element) {
48
- return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);
50
+ return (0, _componentTree.isValidElement)(element) && HOST_SWITCH_NAMES.includes(element.type);
49
51
  }
50
52
 
51
53
  /**
@@ -53,7 +55,7 @@ function isHostSwitch(element) {
53
55
  * @param element The element to check.
54
56
  */
55
57
  function isHostScrollView(element) {
56
- return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);
58
+ return (0, _componentTree.isValidElement)(element) && HOST_SCROLL_VIEW_NAMES.includes(element.type);
57
59
  }
58
60
 
59
61
  /**
@@ -61,6 +63,6 @@ function isHostScrollView(element) {
61
63
  * @param element The element to check.
62
64
  */
63
65
  function isHostModal(element) {
64
- return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);
66
+ return (0, _componentTree.isValidElement)(element) && HOST_MODAL_NAMES.includes(element.type);
65
67
  }
66
68
  //# sourceMappingURL=host-component-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-component-names.js","names":["HOST_TEXT_NAMES","HOST_TEXT_INPUT_NAMES","HOST_IMAGE_NAMES","HOST_SWITCH_NAMES","HOST_SCROLL_VIEW_NAMES","HOST_MODAL_NAMES","isHostText","element","type","includes","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport type { HostTestInstance } from './component-tree';\n\nconst HOST_TEXT_NAMES = ['Text', 'RCTText'];\nconst HOST_TEXT_INPUT_NAMES = ['TextInput'];\nconst HOST_IMAGE_NAMES = ['Image'];\nconst HOST_SWITCH_NAMES = ['RCTSwitch'];\nconst HOST_SCROLL_VIEW_NAMES = ['RCTScrollView'];\nconst HOST_MODAL_NAMES = ['Modal'];\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);\n}\n"],"mappings":";;;;;;;;;;;AAIA,MAAMA,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;AAC3C,MAAMC,qBAAqB,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;AAClC,MAAMC,iBAAiB,GAAG,CAAC,WAAW,CAAC;AACvC,MAAMC,sBAAsB,GAAG,CAAC,eAAe,CAAC;AAChD,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;;AAElC;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACC,OAA0B,EAA+B;EAClF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIR,eAAe,CAACS,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACpF;;AAEA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAACH,OAA0B,EAA+B;EACvF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIP,qBAAqB,CAACQ,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC1F;;AAEA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACJ,OAA0B,EAA+B;EACnF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIN,gBAAgB,CAACO,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAACL,OAA0B,EAA+B;EACpF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIL,iBAAiB,CAACM,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACtF;;AAEA;AACA;AACA;AACA;AACO,SAASK,gBAAgBA,CAACN,OAA0B,EAA+B;EACxF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIJ,sBAAsB,CAACK,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC3F;;AAEA;AACA;AACA;AACA;AACO,SAASM,WAAWA,CAACP,OAA0B,EAA+B;EACnF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIH,gBAAgB,CAACI,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF","ignoreList":[]}
1
+ {"version":3,"file":"host-component-names.js","names":["_componentTree","require","HOST_TEXT_NAMES","exports","HOST_TEXT_INPUT_NAMES","HOST_IMAGE_NAMES","HOST_SWITCH_NAMES","HOST_SCROLL_VIEW_NAMES","HOST_MODAL_NAMES","isHostText","element","isValidElement","includes","type","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { isValidElement } from './component-tree';\n\nexport const HOST_TEXT_NAMES = ['Text', 'RCTText'];\nconst HOST_TEXT_INPUT_NAMES = ['TextInput'];\nconst HOST_IMAGE_NAMES = ['Image'];\nconst HOST_SWITCH_NAMES = ['RCTSwitch'];\nconst HOST_SCROLL_VIEW_NAMES = ['RCTScrollView'];\nconst HOST_MODAL_NAMES = ['Modal'];\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element: HostElement | null) {\n return isValidElement(element) && HOST_TEXT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element: HostElement | null) {\n return isValidElement(element) && HOST_TEXT_INPUT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element: HostElement | null) {\n return isValidElement(element) && HOST_IMAGE_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element: HostElement | null) {\n return isValidElement(element) && HOST_SWITCH_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element: HostElement | null) {\n return isValidElement(element) && HOST_SCROLL_VIEW_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element: HostElement | null) {\n return isValidElement(element) && HOST_MODAL_NAMES.includes(element.type);\n}\n"],"mappings":";;;;;;;;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAEO,MAAMC,eAAe,GAAAC,OAAA,CAAAD,eAAA,GAAG,CA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,QAAQ,CAACF,OAAO,CAACG,IAAI,CAAC;AAC3E","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
1
+ import type { HostElement } from 'universal-test-renderer';
2
2
  export interface AccessibilityStateMatcher {
3
3
  disabled?: boolean;
4
4
  selected?: boolean;
@@ -6,4 +6,4 @@ export interface AccessibilityStateMatcher {
6
6
  busy?: boolean;
7
7
  expanded?: boolean;
8
8
  }
9
- export declare function matchAccessibilityState(node: ReactTestInstance, matcher: AccessibilityStateMatcher): boolean;
9
+ export declare function matchAccessibilityState(node: HostElement, matcher: AccessibilityStateMatcher): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","matchAccessibilityState","node","matcher","busy","undefined","computeAriaBusy","checked","computeAriaChecked","disabled","computeAriaDisabled","expanded","computeAriaExpanded","selected","computeAriaSelected"],"sources":["../../../src/helpers/matchers/match-accessibility-state.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport {\n computeAriaBusy,\n computeAriaChecked,\n computeAriaDisabled,\n computeAriaExpanded,\n computeAriaSelected,\n} from '../accessibility';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\nexport function matchAccessibilityState(\n node: ReactTestInstance,\n matcher: AccessibilityStateMatcher,\n) {\n if (matcher.busy !== undefined && matcher.busy !== computeAriaBusy(node)) {\n return false;\n }\n if (matcher.checked !== undefined && matcher.checked !== computeAriaChecked(node)) {\n return false;\n }\n if (matcher.disabled !== undefined && matcher.disabled !== computeAriaDisabled(node)) {\n return false;\n }\n if (matcher.expanded !== undefined && matcher.expanded !== computeAriaExpanded(node)) {\n return false;\n }\n if (matcher.selected !== undefined && matcher.selected !== computeAriaSelected(node)) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA;;AASO,SAASC,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EAClC;EACA,IAAIA,OAAO,CAACC,IAAI,KAAKC,SAAS,IAAIF,OAAO,CAACC,IAAI,KAAK,IAAAE,8BAAe,EAACJ,IAAI,CAAC,EAAE;IACxE,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACI,OAAO,KAAKF,SAAS,IAAIF,OAAO,CAACI,OAAO,KAAK,IAAAC,iCAAkB,EAACN,IAAI,CAAC,EAAE;IACjF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACM,QAAQ,KAAKJ,SAAS,IAAIF,OAAO,CAACM,QAAQ,KAAK,IAAAC,kCAAmB,EAACR,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACQ,QAAQ,KAAKN,SAAS,IAAIF,OAAO,CAACQ,QAAQ,KAAK,IAAAC,kCAAmB,EAACV,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACU,QAAQ,KAAKR,SAAS,IAAIF,OAAO,CAACU,QAAQ,KAAK,IAAAC,kCAAmB,EAACZ,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","matchAccessibilityState","node","matcher","busy","undefined","computeAriaBusy","checked","computeAriaChecked","disabled","computeAriaDisabled","expanded","computeAriaExpanded","selected","computeAriaSelected"],"sources":["../../../src/helpers/matchers/match-accessibility-state.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport {\n computeAriaBusy,\n computeAriaChecked,\n computeAriaDisabled,\n computeAriaExpanded,\n computeAriaSelected,\n} from '../accessibility';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\nexport function matchAccessibilityState(node: HostElement, matcher: AccessibilityStateMatcher) {\n if (matcher.busy !== undefined && matcher.busy !== computeAriaBusy(node)) {\n return false;\n }\n if (matcher.checked !== undefined && matcher.checked !== computeAriaChecked(node)) {\n return false;\n }\n if (matcher.disabled !== undefined && matcher.disabled !== computeAriaDisabled(node)) {\n return false;\n }\n if (matcher.expanded !== undefined && matcher.expanded !== computeAriaExpanded(node)) {\n return false;\n }\n if (matcher.selected !== undefined && matcher.selected !== computeAriaSelected(node)) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA;;AASO,SAASC,uBAAuBA,CAACC,IAAiB,EAAEC,OAAkC,EAAE;EAC7F,IAAIA,OAAO,CAACC,IAAI,KAAKC,SAAS,IAAIF,OAAO,CAACC,IAAI,KAAK,IAAAE,8BAAe,EAACJ,IAAI,CAAC,EAAE;IACxE,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACI,OAAO,KAAKF,SAAS,IAAIF,OAAO,CAACI,OAAO,KAAK,IAAAC,iCAAkB,EAACN,IAAI,CAAC,EAAE;IACjF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACM,QAAQ,KAAKJ,SAAS,IAAIF,OAAO,CAACM,QAAQ,KAAK,IAAAC,kCAAmB,EAACR,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACQ,QAAQ,KAAKN,SAAS,IAAIF,OAAO,CAACQ,QAAQ,KAAK,IAAAC,kCAAmB,EAACV,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACU,QAAQ,KAAKR,SAAS,IAAIF,OAAO,CAACU,QAAQ,KAAK,IAAAC,kCAAmB,EAACZ,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
1
+ import type { HostElement } from 'universal-test-renderer';
2
2
  import type { TextMatch } from '../../matches';
3
3
  export interface AccessibilityValueMatcher {
4
4
  min?: number;
@@ -6,4 +6,4 @@ export interface AccessibilityValueMatcher {
6
6
  now?: number;
7
7
  text?: TextMatch;
8
8
  }
9
- export declare function matchAccessibilityValue(node: ReactTestInstance, matcher: AccessibilityValueMatcher): boolean;
9
+ export declare function matchAccessibilityValue(node: HostElement, matcher: AccessibilityValueMatcher): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"match-accessibility-value.js","names":["_accessibility","require","_matchStringProp","matchAccessibilityValue","node","matcher","value","computeAriaValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/match-accessibility-value.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport type { TextMatch } from '../../matches';\nimport { computeAriaValue } from '../accessibility';\nimport { matchStringProp } from './match-string-prop';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: ReactTestInstance,\n matcher: AccessibilityValueMatcher,\n): boolean {\n const value = computeAriaValue(node);\n return (\n (matcher.min === undefined || matcher.min === value?.min) &&\n (matcher.max === undefined || matcher.max === value?.max) &&\n (matcher.now === undefined || matcher.now === value?.now) &&\n (matcher.text === undefined || matchStringProp(value?.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AASO,SAASE,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EACzB;EACT,MAAMC,KAAK,GAAG,IAAAC,+BAAgB,EAACH,IAAI,CAAC;EACpC,OACE,CAACC,OAAO,CAACG,GAAG,KAAKC,SAAS,IAAIJ,OAAO,CAACG,GAAG,KAAKF,KAAK,EAAEE,GAAG,MACvDH,OAAO,CAACK,GAAG,KAAKD,SAAS,IAAIJ,OAAO,CAACK,GAAG,KAAKJ,KAAK,EAAEI,GAAG,CAAC,KACxDL,OAAO,CAACM,GAAG,KAAKF,SAAS,IAAIJ,OAAO,CAACM,GAAG,KAAKL,KAAK,EAAEK,GAAG,CAAC,KACxDN,OAAO,CAACO,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACP,KAAK,EAAEM,IAAI,EAAEP,OAAO,CAACO,IAAI,CAAC,CAAC;AAE9E","ignoreList":[]}
1
+ {"version":3,"file":"match-accessibility-value.js","names":["_accessibility","require","_matchStringProp","matchAccessibilityValue","node","matcher","value","computeAriaValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/match-accessibility-value.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport type { TextMatch } from '../../matches';\nimport { computeAriaValue } from '../accessibility';\nimport { matchStringProp } from './match-string-prop';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: HostElement,\n matcher: AccessibilityValueMatcher,\n): boolean {\n const value = computeAriaValue(node);\n return (\n (matcher.min === undefined || matcher.min === value?.min) &&\n (matcher.max === undefined || matcher.max === value?.max) &&\n (matcher.now === undefined || matcher.now === value?.now) &&\n (matcher.text === undefined || matchStringProp(value?.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AASO,SAASE,uBAAuBA,CACrCC,IAAiB,EACjBC,OAAkC,EACzB;EACT,MAAMC,KAAK,GAAG,IAAAC,+BAAgB,EAACH,IAAI,CAAC;EACpC,OACE,CAACC,OAAO,CAACG,GAAG,KAAKC,SAAS,IAAIJ,OAAO,CAACG,GAAG,KAAKF,KAAK,EAAEE,GAAG,MACvDH,OAAO,CAACK,GAAG,KAAKD,SAAS,IAAIJ,OAAO,CAACK,GAAG,KAAKJ,KAAK,EAAEI,GAAG,CAAC,KACxDL,OAAO,CAACM,GAAG,KAAKF,SAAS,IAAIJ,OAAO,CAACM,GAAG,KAAKL,KAAK,EAAEK,GAAG,CAAC,KACxDN,OAAO,CAACO,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACP,KAAK,EAAEM,IAAI,EAAEP,OAAO,CAACO,IAAI,CAAC,CAAC;AAE9E","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
1
+ import type { HostElement } from 'universal-test-renderer';
2
2
  import type { TextMatch, TextMatchOptions } from '../../matches';
3
- export declare function matchAccessibilityLabel(element: ReactTestInstance, expectedLabel: TextMatch, options?: TextMatchOptions): boolean;
3
+ export declare function matchAccessibilityLabel(element: HostElement, expectedLabel: TextMatch, options?: TextMatchOptions): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","matchAccessibilityLabel","element","expectedLabel","options","matches","computeAriaLabel","normalizer","exact"],"sources":["../../../src/helpers/matchers/match-label-text.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport type { TextMatch, TextMatchOptions } from '../../matches';\nimport { matches } from '../../matches';\nimport { computeAriaLabel } from '../accessibility';\n\nexport function matchAccessibilityLabel(\n element: ReactTestInstance,\n expectedLabel: TextMatch,\n options?: TextMatchOptions,\n) {\n return matches(expectedLabel, computeAriaLabel(element), options?.normalizer, options?.exact);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEO,SAASE,uBAAuBA,CACrCC,OAA0B,EAC1BC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,OAAO,IAAAC,gBAAO,EAACF,aAAa,EAAE,IAAAG,+BAAgB,EAACJ,OAAO,CAAC,EAAEE,OAAO,EAAEG,UAAU,EAAEH,OAAO,EAAEI,KAAK,CAAC;AAC/F","ignoreList":[]}
1
+ {"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","matchAccessibilityLabel","element","expectedLabel","options","matches","computeAriaLabel","normalizer","exact"],"sources":["../../../src/helpers/matchers/match-label-text.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport type { TextMatch, TextMatchOptions } from '../../matches';\nimport { matches } from '../../matches';\nimport { computeAriaLabel } from '../accessibility';\n\nexport function matchAccessibilityLabel(\n element: HostElement,\n expectedLabel: TextMatch,\n options?: TextMatchOptions,\n) {\n return matches(expectedLabel, computeAriaLabel(element), options?.normalizer, options?.exact);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEO,SAASE,uBAAuBA,CACrCC,OAAoB,EACpBC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,OAAO,IAAAC,gBAAO,EAACF,aAAa,EAAE,IAAAG,+BAAgB,EAACJ,OAAO,CAAC,EAAEE,OAAO,EAAEG,UAAU,EAAEH,OAAO,EAAEI,KAAK,CAAC;AAC/F","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
1
+ import type { HostElement } from 'universal-test-renderer';
2
2
  import type { TextMatch, TextMatchOptions } from '../../matches';
3
3
  /**
4
4
  * Matches the given node's text content against string or regex matcher.
@@ -7,4 +7,4 @@ import type { TextMatch, TextMatchOptions } from '../../matches';
7
7
  * @param text - The string or regex to match.
8
8
  * @returns - Whether the node's text content matches the given string or regex.
9
9
  */
10
- export declare function matchTextContent(node: ReactTestInstance, text: TextMatch, options?: TextMatchOptions): boolean;
10
+ export declare function matchTextContent(node: HostElement, text: TextMatch, options?: TextMatchOptions): boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"match-text-content.js","names":["_matches","require","_textContent","matchTextContent","node","text","options","textContent","getTextContent","exact","normalizer","matches"],"sources":["../../../src/helpers/matchers/match-text-content.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport type { TextMatch, TextMatchOptions } from '../../matches';\nimport { matches } from '../../matches';\nimport { getTextContent } from '../text-content';\n\n/**\n * Matches the given node's text content against string or regex matcher.\n *\n * @param node - Node which text content will be matched\n * @param text - The string or regex to match.\n * @returns - Whether the node's text content matches the given string or regex.\n */\nexport function matchTextContent(\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {},\n) {\n const textContent = getTextContent(node);\n const { exact, normalizer } = options;\n return matches(text, textContent, normalizer, exact);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,MAAMC,WAAW,GAAG,IAAAC,2BAAc,EAACJ,IAAI,CAAC;EACxC,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGJ,OAAO;EACrC,OAAO,IAAAK,gBAAO,EAACN,IAAI,EAAEE,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACtD","ignoreList":[]}
1
+ {"version":3,"file":"match-text-content.js","names":["_matches","require","_textContent","matchTextContent","node","text","options","textContent","getTextContent","exact","normalizer","matches"],"sources":["../../../src/helpers/matchers/match-text-content.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport type { TextMatch, TextMatchOptions } from '../../matches';\nimport { matches } from '../../matches';\nimport { getTextContent } from '../text-content';\n\n/**\n * Matches the given node's text content against string or regex matcher.\n *\n * @param node - Node which text content will be matched\n * @param text - The string or regex to match.\n * @returns - Whether the node's text content matches the given string or regex.\n */\nexport function matchTextContent(\n node: HostElement,\n text: TextMatch,\n options: TextMatchOptions = {},\n) {\n const textContent = getTextContent(node);\n const { exact, normalizer } = options;\n return matches(text, textContent, normalizer, exact);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BC,IAAiB,EACjBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,MAAMC,WAAW,GAAG,IAAAC,2BAAc,EAACJ,IAAI,CAAC;EACxC,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGJ,OAAO;EACrC,OAAO,IAAAK,gBAAO,EAACN,IAAI,EAAEE,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACtD","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
1
+ import type { HostElement } from 'universal-test-renderer';
2
2
  /**
3
3
  * pointerEvents controls whether the View can be the target of touch events.
4
4
  * 'auto': The View and its children can be the target of touch events.
@@ -6,4 +6,4 @@ import type { ReactTestInstance } from 'react-test-renderer';
6
6
  * 'box-none': The View is never the target of touch events but its subviews can be
7
7
  * 'box-only': The view can be the target of touch events but its subviews cannot be
8
8
  * see the official react native doc https://reactnative.dev/docs/view#pointerevents */
9
- export declare const isPointerEventEnabled: (element: ReactTestInstance, isParent?: boolean) => boolean;
9
+ export declare const isPointerEventEnabled: (element: HostElement, isParent?: boolean) => boolean;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.isPointerEventEnabled = void 0;
7
- var _componentTree = require("./component-tree");
8
7
  /**
9
8
  * pointerEvents controls whether the View can be the target of touch events.
10
9
  * 'auto': The View and its children can be the target of touch events.
@@ -17,7 +16,7 @@ const isPointerEventEnabled = (element, isParent) => {
17
16
  if (element?.props.pointerEvents === 'none' || parentCondition) {
18
17
  return false;
19
18
  }
20
- const hostParent = (0, _componentTree.getHostParent)(element);
19
+ const hostParent = element.parent;
21
20
  if (!hostParent) return true;
22
21
  return isPointerEventEnabled(hostParent, true);
23
22
  };
@@ -1 +1 @@
1
- {"version":3,"file":"pointer-events.js","names":["_componentTree","require","isPointerEventEnabled","element","isParent","parentCondition","props","pointerEvents","hostParent","getHostParent","exports"],"sources":["../../src/helpers/pointer-events.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport { getHostParent } from './component-tree';\n\n/**\n * pointerEvents controls whether the View can be the target of touch events.\n * 'auto': The View and its children can be the target of touch events.\n * 'none': The View is never the target of touch events.\n * 'box-none': The View is never the target of touch events but its subviews can be\n * 'box-only': The view can be the target of touch events but its subviews cannot be\n * see the official react native doc https://reactnative.dev/docs/view#pointerevents */\nexport const isPointerEventEnabled = (element: ReactTestInstance, isParent?: boolean): 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 const hostParent = getHostParent(element);\n if (!hostParent) return true;\n\n return isPointerEventEnabled(hostParent, true);\n};\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CAACC,OAA0B,EAAEC,QAAkB,KAAc;EAChG,MAAMC,eAAe,GAAGD,QAAQ,GAC5BD,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU,GAC3CJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU;EAE/C,IAAIJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,MAAM,IAAIF,eAAe,EAAE;IAC9D,OAAO,KAAK;EACd;EAEA,MAAMG,UAAU,GAAG,IAAAC,4BAAa,EAACN,OAAO,CAAC;EACzC,IAAI,CAACK,UAAU,EAAE,OAAO,IAAI;EAE5B,OAAON,qBAAqB,CAACM,UAAU,EAAE,IAAI,CAAC;AAChD,CAAC;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA","ignoreList":[]}
1
+ {"version":3,"file":"pointer-events.js","names":["isPointerEventEnabled","element","isParent","parentCondition","props","pointerEvents","hostParent","parent","exports"],"sources":["../../src/helpers/pointer-events.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\n/**\n * pointerEvents controls whether the View can be the target of touch events.\n * 'auto': The View and its children can be the target of touch events.\n * 'none': The View is never the target of touch events.\n * 'box-none': The View is never the target of touch events but its subviews can be\n * 'box-only': The view can be the target of touch events but its subviews cannot be\n * see the official react native doc https://reactnative.dev/docs/view#pointerevents */\nexport const isPointerEventEnabled = (element: HostElement, isParent?: boolean): 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 const hostParent = element.parent;\n if (!hostParent) return true;\n\n return isPointerEventEnabled(hostParent, true);\n};\n"],"mappings":";;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,qBAAqB,GAAGA,CAACC,OAAoB,EAAEC,QAAkB,KAAc;EAC1F,MAAMC,eAAe,GAAGD,QAAQ,GAC5BD,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU,GAC3CJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,UAAU;EAE/C,IAAIJ,OAAO,EAAEG,KAAK,CAACC,aAAa,KAAK,MAAM,IAAIF,eAAe,EAAE;IAC9D,OAAO,KAAK;EACd;EAEA,MAAMG,UAAU,GAAGL,OAAO,CAACM,MAAM;EACjC,IAAI,CAACD,UAAU,EAAE,OAAO,IAAI;EAE5B,OAAON,qBAAqB,CAACM,UAAU,EAAE,IAAI,CAAC;AAChD,CAAC;AAACE,OAAA,CAAAR,qBAAA,GAAAA,qBAAA","ignoreList":[]}
@@ -1,2 +1,2 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- export declare function getTextContent(element: ReactTestInstance | string | null): string;
1
+ import type { HostElement } from 'universal-test-renderer';
2
+ export declare function getTextContent(element: HostElement | string | null): string;
@@ -1 +1 @@
1
- {"version":3,"file":"text-content.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/text-content.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nexport function getTextContent(element: ReactTestInstance | string | null): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAcA,CAACC,OAA0C,EAAU;EACjF,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"text-content.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/text-content.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nexport function getTextContent(element: HostElement | string | null): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAcA,CAACC,OAAoC,EAAU;EAC3E,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import type { ReactTestInstance } from 'react-test-renderer';
2
- export declare function isEditableTextInput(element: ReactTestInstance): boolean;
3
- export declare function getTextInputValue(element: ReactTestInstance): any;
1
+ import type { HostElement } from 'universal-test-renderer';
2
+ export declare function isEditableTextInput(element: HostElement): boolean;
3
+ export declare function getTextInputValue(element: HostElement): any;
@@ -1 +1 @@
1
- {"version":3,"file":"text-input.js","names":["_nativeState","require","_hostComponentNames","isEditableTextInput","element","isHostTextInput","props","editable","getTextInputValue","Error","type","value","nativeState","valueForElement","get","defaultValue"],"sources":["../../src/helpers/text-input.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nimport { nativeState } from '../native-state';\nimport { isHostTextInput } from './host-component-names';\n\nexport function isEditableTextInput(element: ReactTestInstance) {\n return isHostTextInput(element) && element.props.editable !== false;\n}\n\nexport function getTextInputValue(element: ReactTestInstance) {\n if (!isHostTextInput(element)) {\n throw new Error(`Element is not a \"TextInput\", but it has type \"${element.type}\".`);\n }\n\n return (\n element.props.value ??\n nativeState.valueForElement.get(element) ??\n element.props.defaultValue ??\n ''\n );\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEO,SAASE,mBAAmBA,CAACC,OAA0B,EAAE;EAC9D,OAAO,IAAAC,mCAAe,EAACD,OAAO,CAAC,IAAIA,OAAO,CAACE,KAAK,CAACC,QAAQ,KAAK,KAAK;AACrE;AAEO,SAASC,iBAAiBA,CAACJ,OAA0B,EAAE;EAC5D,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIK,KAAK,CAAC,kDAAkDL,OAAO,CAACM,IAAI,IAAI,CAAC;EACrF;EAEA,OACEN,OAAO,CAACE,KAAK,CAACK,KAAK,IACnBC,wBAAW,CAACC,eAAe,CAACC,GAAG,CAACV,OAAO,CAAC,IACxCA,OAAO,CAACE,KAAK,CAACS,YAAY,IAC1B,EAAE;AAEN","ignoreList":[]}
1
+ {"version":3,"file":"text-input.js","names":["_nativeState","require","_hostComponentNames","isEditableTextInput","element","isHostTextInput","props","editable","getTextInputValue","Error","type","value","nativeState","valueForElement","get","defaultValue"],"sources":["../../src/helpers/text-input.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { nativeState } from '../native-state';\nimport { isHostTextInput } from './host-component-names';\n\nexport function isEditableTextInput(element: HostElement) {\n return isHostTextInput(element) && element.props.editable !== false;\n}\n\nexport function getTextInputValue(element: HostElement) {\n if (!isHostTextInput(element)) {\n throw new Error(`Element is not a \"TextInput\", but it has type \"${element.type}\".`);\n }\n\n return (\n element.props.value ??\n nativeState.valueForElement.get(element) ??\n element.props.defaultValue ??\n ''\n );\n}\n"],"mappings":";;;;;;;AAEA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEO,SAASE,mBAAmBA,CAACC,OAAoB,EAAE;EACxD,OAAO,IAAAC,mCAAe,EAACD,OAAO,CAAC,IAAIA,OAAO,CAACE,KAAK,CAACC,QAAQ,KAAK,KAAK;AACrE;AAEO,SAASC,iBAAiBA,CAACJ,OAAoB,EAAE;EACtD,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIK,KAAK,CAAC,kDAAkDL,OAAO,CAACM,IAAI,IAAI,CAAC;EACrF;EAEA,OACEN,OAAO,CAACE,KAAK,CAACK,KAAK,IACnBC,wBAAW,CAACC,eAAe,CAACC,GAAG,CAACV,OAAO,CAAC,IACxCA,OAAO,CAACE,KAAK,CAACS,YAAY,IAC1B,EAAE;AAEN","ignoreList":[]}
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
3
+ * See: https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/src/pure.js#L37
3
4
  *
4
5
  * @param callback Async callback to run
5
6
  * @returns Result of the callback
@@ -10,6 +10,7 @@ var _flushMicroTasks = require("../flush-micro-tasks");
10
10
 
11
11
  /**
12
12
  * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
13
+ * See: https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/src/pure.js#L37
13
14
  *
14
15
  * @param callback Async callback to run
15
16
  * @returns Result of the callback
@@ -1 +1 @@
1
- {"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasks();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,SAASA,CAASC,QAA+B,EAAmB;EACxF,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;EACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;EAE7B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAAC,CAAC;IAC/B;IACA,MAAM,IAAAK,gCAAe,EAAC,CAAC;IACvB,OAAOD,MAAM;EACf,CAAC,SAAS;IACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;EAChD;AACF","ignoreList":[]}
1
+ {"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n * See: https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/src/pure.js#L37\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasks();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,SAASA,CAASC,QAA+B,EAAmB;EACxF,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;EACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;EAE7B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAAC,CAAC;IAC/B;IACA,MAAM,IAAAK,gCAAe,EAAC,CAAC;IACvB,OAAOD,MAAM;EACf,CAAC,SAAS;IACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;EAChD;AACF","ignoreList":[]}
package/build/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import './helpers/ensure-peer-deps';
2
1
  import './matchers/extend-expect';
2
+ export { HostElement } from 'universal-test-renderer';
3
3
  export * from './pure';
@@ -310,7 +310,6 @@ declare module '@testing-library/react-native' {
310
310
  declare interface RenderOptions {
311
311
  wrapper?: React.ComponentType<any>;
312
312
  createNodeMock?: (element: React.Element<any>) => any;
313
- unstable_validateStringsRenderedWithinText?: boolean;
314
313
  unstable_isConcurrent?: boolean;
315
314
  unstable_strictMode?: boolean;
316
315
  unstable_concurrentUpdatesByDefault?: boolean;