@testing-library/react-native 14.0.0-beta.0 → 14.0.0-beta.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 (191) hide show
  1. package/README.md +22 -33
  2. package/build/event-builder/base.js.map +1 -0
  3. package/build/event-builder/common.d.ts +152 -0
  4. package/build/event-builder/common.js +80 -0
  5. package/build/event-builder/common.js.map +1 -0
  6. package/build/event-builder/index.d.ts +3 -0
  7. package/build/event-builder/index.js +39 -0
  8. package/build/event-builder/index.js.map +1 -0
  9. package/build/event-builder/scroll.d.ts +56 -0
  10. package/build/event-builder/scroll.js +51 -0
  11. package/build/event-builder/scroll.js.map +1 -0
  12. package/build/event-builder/text.d.ts +162 -0
  13. package/build/event-builder/text.js +113 -0
  14. package/build/event-builder/text.js.map +1 -0
  15. package/build/fire-event.d.ts +6 -5
  16. package/build/fire-event.js +47 -23
  17. package/build/fire-event.js.map +1 -1
  18. package/build/helpers/accessibility.d.ts +18 -15
  19. package/build/helpers/accessibility.js +64 -47
  20. package/build/helpers/accessibility.js.map +1 -1
  21. package/build/helpers/component-tree.d.ts +9 -9
  22. package/build/helpers/component-tree.js +17 -17
  23. package/build/helpers/component-tree.js.map +1 -1
  24. package/build/helpers/find-all.d.ts +2 -2
  25. package/build/helpers/find-all.js +1 -1
  26. package/build/helpers/find-all.js.map +1 -1
  27. package/build/helpers/format-element.d.ts +5 -5
  28. package/build/helpers/format-element.js +9 -9
  29. package/build/helpers/format-element.js.map +1 -1
  30. package/build/helpers/host-component-names.d.ts +13 -13
  31. package/build/helpers/host-component-names.js +18 -18
  32. package/build/helpers/host-component-names.js.map +1 -1
  33. package/build/helpers/matchers/match-accessibility-state.d.ts +2 -2
  34. package/build/helpers/matchers/match-accessibility-state.js +6 -6
  35. package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
  36. package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
  37. package/build/helpers/matchers/match-accessibility-value.js +2 -2
  38. package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
  39. package/build/helpers/matchers/match-label-text.d.ts +2 -2
  40. package/build/helpers/matchers/match-label-text.js +2 -2
  41. package/build/helpers/matchers/match-label-text.js.map +1 -1
  42. package/build/helpers/matchers/match-text-content.d.ts +5 -5
  43. package/build/helpers/matchers/match-text-content.js +5 -5
  44. package/build/helpers/matchers/match-text-content.js.map +1 -1
  45. package/build/helpers/pointer-events.d.ts +2 -2
  46. package/build/helpers/pointer-events.js +4 -4
  47. package/build/helpers/pointer-events.js.map +1 -1
  48. package/build/helpers/text-content.d.ts +2 -2
  49. package/build/helpers/text-content.js +5 -5
  50. package/build/helpers/text-content.js.map +1 -1
  51. package/build/helpers/text-input.d.ts +3 -3
  52. package/build/helpers/text-input.js +6 -6
  53. package/build/helpers/text-input.js.map +1 -1
  54. package/build/matchers/to-be-busy.d.ts +2 -2
  55. package/build/matchers/to-be-busy.js +5 -5
  56. package/build/matchers/to-be-busy.js.map +1 -1
  57. package/build/matchers/to-be-checked.d.ts +2 -2
  58. package/build/matchers/to-be-checked.js +9 -9
  59. package/build/matchers/to-be-checked.js.map +1 -1
  60. package/build/matchers/to-be-disabled.d.ts +3 -3
  61. package/build/matchers/to-be-disabled.js +10 -10
  62. package/build/matchers/to-be-disabled.js.map +1 -1
  63. package/build/matchers/to-be-empty-element.d.ts +2 -2
  64. package/build/matchers/to-be-empty-element.js +4 -4
  65. package/build/matchers/to-be-empty-element.js.map +1 -1
  66. package/build/matchers/to-be-expanded.d.ts +3 -3
  67. package/build/matchers/to-be-expanded.js +10 -10
  68. package/build/matchers/to-be-expanded.js.map +1 -1
  69. package/build/matchers/to-be-on-the-screen.d.ts +2 -2
  70. package/build/matchers/to-be-on-the-screen.js +7 -7
  71. package/build/matchers/to-be-on-the-screen.js.map +1 -1
  72. package/build/matchers/to-be-partially-checked.d.ts +2 -2
  73. package/build/matchers/to-be-partially-checked.js +8 -8
  74. package/build/matchers/to-be-partially-checked.js.map +1 -1
  75. package/build/matchers/to-be-selected.d.ts +2 -2
  76. package/build/matchers/to-be-selected.js +4 -4
  77. package/build/matchers/to-be-selected.js.map +1 -1
  78. package/build/matchers/to-be-visible.d.ts +2 -2
  79. package/build/matchers/to-be-visible.js +12 -12
  80. package/build/matchers/to-be-visible.js.map +1 -1
  81. package/build/matchers/to-contain-element.d.ts +2 -2
  82. package/build/matchers/to-contain-element.js +6 -6
  83. package/build/matchers/to-contain-element.js.map +1 -1
  84. package/build/matchers/to-have-accessibility-value.d.ts +2 -2
  85. package/build/matchers/to-have-accessibility-value.js +6 -6
  86. package/build/matchers/to-have-accessibility-value.js.map +1 -1
  87. package/build/matchers/to-have-accessible-name.d.ts +2 -2
  88. package/build/matchers/to-have-accessible-name.js +5 -10
  89. package/build/matchers/to-have-accessible-name.js.map +1 -1
  90. package/build/matchers/to-have-display-value.d.ts +2 -2
  91. package/build/matchers/to-have-display-value.js +6 -6
  92. package/build/matchers/to-have-display-value.js.map +1 -1
  93. package/build/matchers/to-have-prop.d.ts +2 -2
  94. package/build/matchers/to-have-prop.js +6 -6
  95. package/build/matchers/to-have-prop.js.map +1 -1
  96. package/build/matchers/to-have-style.d.ts +2 -2
  97. package/build/matchers/to-have-style.js +5 -5
  98. package/build/matchers/to-have-style.js.map +1 -1
  99. package/build/matchers/to-have-text-content.d.ts +2 -2
  100. package/build/matchers/to-have-text-content.js +4 -4
  101. package/build/matchers/to-have-text-content.js.map +1 -1
  102. package/build/matchers/types.d.ts +20 -20
  103. package/build/matchers/types.js.map +1 -1
  104. package/build/matchers/utils.d.ts +4 -4
  105. package/build/matchers/utils.js +6 -6
  106. package/build/matchers/utils.js.map +1 -1
  107. package/build/native-state.d.ts +3 -3
  108. package/build/native-state.js +2 -2
  109. package/build/native-state.js.map +1 -1
  110. package/build/queries/display-value.d.ts +2 -2
  111. package/build/queries/display-value.js +12 -12
  112. package/build/queries/display-value.js.map +1 -1
  113. package/build/queries/hint-text.d.ts +2 -2
  114. package/build/queries/hint-text.js +11 -11
  115. package/build/queries/hint-text.js.map +1 -1
  116. package/build/queries/label-text.d.ts +2 -2
  117. package/build/queries/label-text.js +9 -9
  118. package/build/queries/label-text.js.map +1 -1
  119. package/build/queries/make-queries.d.ts +8 -8
  120. package/build/queries/make-queries.js +11 -11
  121. package/build/queries/make-queries.js.map +1 -1
  122. package/build/queries/placeholder-text.d.ts +2 -2
  123. package/build/queries/placeholder-text.js +11 -11
  124. package/build/queries/placeholder-text.js.map +1 -1
  125. package/build/queries/role.d.ts +2 -2
  126. package/build/queries/role.js +17 -27
  127. package/build/queries/role.js.map +1 -1
  128. package/build/queries/test-id.d.ts +2 -2
  129. package/build/queries/test-id.js +11 -11
  130. package/build/queries/test-id.js.map +1 -1
  131. package/build/queries/text.d.ts +2 -2
  132. package/build/queries/text.js +9 -9
  133. package/build/queries/text.js.map +1 -1
  134. package/build/render.d.ts +3 -4
  135. package/build/render.js +17 -3
  136. package/build/render.js.map +1 -1
  137. package/build/screen.js.map +1 -1
  138. package/build/test-utils/react-version-gates.d.ts +1 -0
  139. package/build/test-utils/react-version-gates.js +28 -0
  140. package/build/test-utils/react-version-gates.js.map +1 -0
  141. package/build/types.d.ts +7 -0
  142. package/build/types.js.map +1 -1
  143. package/build/user-event/clear.d.ts +2 -2
  144. package/build/user-event/clear.js +13 -13
  145. package/build/user-event/clear.js.map +1 -1
  146. package/build/user-event/index.d.ts +7 -7
  147. package/build/user-event/index.js +6 -6
  148. package/build/user-event/index.js.map +1 -1
  149. package/build/user-event/paste.d.ts +2 -2
  150. package/build/user-event/paste.js +18 -18
  151. package/build/user-event/paste.js.map +1 -1
  152. package/build/user-event/press/press.d.ts +3 -3
  153. package/build/user-event/press/press.js +35 -35
  154. package/build/user-event/press/press.js.map +1 -1
  155. package/build/user-event/scroll/scroll-to.d.ts +2 -2
  156. package/build/user-event/scroll/scroll-to.js +20 -20
  157. package/build/user-event/scroll/scroll-to.js.map +1 -1
  158. package/build/user-event/setup/setup.d.ts +11 -11
  159. package/build/user-event/setup/setup.js.map +1 -1
  160. package/build/user-event/type/type.d.ts +3 -3
  161. package/build/user-event/type/type.js +27 -28
  162. package/build/user-event/type/type.js.map +1 -1
  163. package/build/user-event/utils/dispatch-event.d.ts +3 -3
  164. package/build/user-event/utils/dispatch-event.js +4 -4
  165. package/build/user-event/utils/dispatch-event.js.map +1 -1
  166. package/build/user-event/utils/index.d.ts +0 -1
  167. package/build/user-event/utils/index.js +0 -11
  168. package/build/user-event/utils/index.js.map +1 -1
  169. package/build/within.d.ts +3 -3
  170. package/build/within.js +10 -10
  171. package/build/within.js.map +1 -1
  172. package/package.json +38 -27
  173. package/build/tsconfig.release.tsbuildinfo +0 -1
  174. package/build/user-event/event-builder/base.js.map +0 -1
  175. package/build/user-event/event-builder/common.d.ts +0 -155
  176. package/build/user-event/event-builder/common.js +0 -77
  177. package/build/user-event/event-builder/common.js.map +0 -1
  178. package/build/user-event/event-builder/index.d.ts +0 -318
  179. package/build/user-event/event-builder/index.js +0 -15
  180. package/build/user-event/event-builder/index.js.map +0 -1
  181. package/build/user-event/event-builder/scroll-view.d.ts +0 -58
  182. package/build/user-event/event-builder/scroll-view.js +0 -53
  183. package/build/user-event/event-builder/scroll-view.js.map +0 -1
  184. package/build/user-event/event-builder/text-input.d.ts +0 -165
  185. package/build/user-event/event-builder/text-input.js +0 -105
  186. package/build/user-event/event-builder/text-input.js.map +0 -1
  187. package/build/user-event/utils/text-range.d.ts +0 -4
  188. package/build/user-event/utils/text-range.js +0 -6
  189. package/build/user-event/utils/text-range.js.map +0 -1
  190. /package/build/{user-event/event-builder → event-builder}/base.d.ts +0 -0
  191. /package/build/{user-event/event-builder → event-builder}/base.js +0 -0
@@ -7,15 +7,15 @@ exports.bindByTestIdQueries = void 0;
7
7
  var _findAll = require("../helpers/find-all");
8
8
  var _matches = require("../matches");
9
9
  var _makeQueries = require("./make-queries");
10
- const matchTestId = (node, testId, options = {}) => {
10
+ const matchTestId = (instance, testId, options = {}) => {
11
11
  const {
12
12
  exact,
13
13
  normalizer
14
14
  } = options;
15
- return (0, _matches.matches)(testId, node.props.testID, normalizer, exact);
15
+ return (0, _matches.matches)(testId, instance.props.testID, normalizer, exact);
16
16
  };
17
- const queryAllByTestId = element => function queryAllByTestIdFn(testId, queryOptions) {
18
- return (0, _findAll.findAll)(element, node => matchTestId(node, testId, queryOptions), queryOptions);
17
+ const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
18
+ return (0, _findAll.findAll)(instance, item => matchTestId(item, testId, queryOptions), queryOptions);
19
19
  };
20
20
  const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
21
21
  const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
@@ -27,13 +27,13 @@ const {
27
27
  findBy,
28
28
  findAllBy
29
29
  } = (0, _makeQueries.makeQueries)(queryAllByTestId, getMissingError, getMultipleError);
30
- const bindByTestIdQueries = element => ({
31
- getByTestId: getBy(element),
32
- getAllByTestId: getAllBy(element),
33
- queryByTestId: queryBy(element),
34
- queryAllByTestId: queryAllBy(element),
35
- findByTestId: findBy(element),
36
- findAllByTestId: findAllBy(element)
30
+ const bindByTestIdQueries = instance => ({
31
+ getByTestId: getBy(instance),
32
+ getAllByTestId: getAllBy(instance),
33
+ queryByTestId: queryBy(instance),
34
+ queryAllByTestId: queryAllBy(instance),
35
+ findByTestId: findBy(instance),
36
+ findAllByTestId: findAllBy(instance)
37
37
  });
38
38
  exports.bindByTestIdQueries = bindByTestIdQueries;
39
39
  //# sourceMappingURL=test-id.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","element","queryAllByTestIdFn","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } 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 ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (node: HostElement, testId: TextMatch, options: TextMatchOptions = {}) => {\n const { exact, normalizer } = options;\n return matches(testId, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (element: HostElement): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(element, (node) => matchTestId(node, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (element: HostElement): ByTestIdQueries => ({\n getByTestId: getBy(element),\n getAllByTestId: getAllBy(element),\n queryByTestId: queryBy(element),\n queryAllByTestId: queryAllBy(element),\n findByTestId: findBy(element),\n findAllByTestId: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA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B,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
1
+ {"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","instance","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","queryAllByTestIdFn","queryOptions","findAll","item","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } 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 ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (instance: TestInstance, testId: TextMatch, options: TextMatchOptions = {}) => {\n const { exact, normalizer } = options;\n return matches(testId, instance.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (instance: TestInstance): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(instance, (item) => matchTestId(item, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (instance: TestInstance): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,WAAW,GAAGA,CAACC,QAAsB,EAAEC,MAAiB,EAAEC,OAAyB,GAAG,CAAC,CAAC,KAAK;EACjG,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,QAAQ,CAACM,KAAK,CAACC,MAAM,EAAEH,UAAU,EAAED,KAAK,CAAC;AAClE,CAAC;AAED,MAAMK,gBAAgB,GAAIR,QAAsB,IAC9C,SAASS,kBAAkBA,CAACR,MAAM,EAAES,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EAACX,QAAQ,EAAGY,IAAI,IAAKb,WAAW,CAACa,IAAI,EAAEX,MAAM,EAAES,YAAY,CAAC,EAAEA,YAAY,CAAC;AAC3F,CAAC;AAEH,MAAMG,gBAAgB,GAAIZ,MAAiB,IACzC,wCAAwCa,MAAM,CAACb,MAAM,CAAC,EAAE;AAC1D,MAAMc,eAAe,GAAId,MAAiB,IACxC,0CAA0Ca,MAAM,CAACb,MAAM,CAAC,EAAE;AAE5D,MAAM;EAAEe,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,gBAAgB,EAChBO,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,mBAAmB,GAAIvB,QAAsB,KAAuB;EAC/EwB,WAAW,EAAER,KAAK,CAAChB,QAAQ,CAAC;EAC5ByB,cAAc,EAAER,QAAQ,CAACjB,QAAQ,CAAC;EAClC0B,aAAa,EAAER,OAAO,CAAClB,QAAQ,CAAC;EAChCQ,gBAAgB,EAAEW,UAAU,CAACnB,QAAQ,CAAC;EACtC2B,YAAY,EAAEP,MAAM,CAACpB,QAAQ,CAAC;EAC9B4B,eAAe,EAAEP,SAAS,CAACrB,QAAQ;AACrC,CAAC,CAAC;AAAC6B,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
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';
@@ -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: (element: HostElement) => ByTextQueries;
14
+ export declare const bindByTextQueries: (instance: TestInstance) => 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 = element => function queryAllByTextFn(text, options = {}) {
12
- return (0, _findAll.findAll)(element, node => (0, _hostComponentNames.isHostText)(node) && (0, _matchTextContent.matchTextContent)(node, text, options), {
11
+ const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
12
+ return (0, _findAll.findAll)(instance, item => (0, _hostComponentNames.isHostText)(item) && (0, _matchTextContent.matchTextContent)(item, 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 = 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)
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)
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","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 '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,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,cAAc,GAAIC,OAAoB,IAC1C,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,OAAO,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC3F,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,OAAoB,KAAqB;EACzEoB,SAAS,EAAER,KAAK,CAACZ,OAAO,CAAC;EACzBqB,YAAY,EAAER,QAAQ,CAACb,OAAO,CAAC;EAC/BsB,WAAW,EAAER,OAAO,CAACd,OAAO,CAAC;EAC7BD,cAAc,EAAEgB,UAAU,CAACf,OAAO,CAAC;EACnCuB,UAAU,EAAEP,MAAM,CAAChB,OAAO,CAAC;EAC3BwB,aAAa,EAAEP,SAAS,CAACjB,OAAO;AAClC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
1
+ {"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","instance","queryAllByTextFn","text","options","findAll","item","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 { TestInstance } from '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 = (instance: TestInstance): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(instance, (item) => isHostText(item) && matchTextContent(item, 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: TestInstance): 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":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,cAAc,GAAIC,QAAsB,IAC5C,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,QAAsB,KAAqB;EAC3EoB,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":[]}
package/build/render.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { type HostElement, type JsonElement } from 'test-renderer';
2
+ import { type JsonElement, type TestInstance } from 'test-renderer';
3
3
  import type { DebugOptions } from './helpers/debug';
4
4
  export interface RenderOptions {
5
5
  /**
@@ -7,7 +7,6 @@ export interface RenderOptions {
7
7
  * reusable custom render functions for common data providers.
8
8
  */
9
9
  wrapper?: React.ComponentType<any>;
10
- createNodeMock?: (element: React.ReactElement) => object;
11
10
  }
12
11
  export type RenderResult = Awaited<ReturnType<typeof render>>;
13
12
  /**
@@ -19,8 +18,8 @@ export declare function render<T>(element: React.ReactElement<T>, options?: Rend
19
18
  unmount: () => Promise<void>;
20
19
  toJSON: () => JsonElement | null;
21
20
  debug: DebugFunction;
22
- container: HostElement;
23
- root: HostElement | null;
21
+ container: TestInstance;
22
+ root: TestInstance | null;
24
23
  getByRole: import("./queries/make-queries").GetByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
25
24
  getAllByRole: import("./queries/make-queries").GetAllByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
26
25
  queryByRole: import("./queries/make-queries").QueryByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
package/build/render.js CHANGED
@@ -22,14 +22,18 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
22
22
  async function render(element, options = {}) {
23
23
  const {
24
24
  wrapper: Wrapper,
25
- createNodeMock,
26
25
  ...rest
27
26
  } = options || {};
28
27
  (0, _validateOptions.validateOptions)('render', rest, render);
29
28
  const rendererOptions = {
30
29
  textComponentTypes: _hostComponentNames.HOST_TEXT_NAMES,
31
30
  publicTextComponentTypes: ['Text'],
32
- createNodeMock
31
+ transformHiddenInstanceProps: ({
32
+ props
33
+ }) => ({
34
+ ...props,
35
+ style: withHiddenStyle(props.style)
36
+ })
33
37
  };
34
38
  const wrap = element => Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element;
35
39
  const renderer = (0, _testRenderer.createRoot)(rendererOptions);
@@ -59,7 +63,7 @@ async function render(element, options = {}) {
59
63
  };
60
64
  (0, _cleanup.addToCleanupQueue)(unmount);
61
65
  const result = {
62
- ...(0, _within.getQueriesForElement)(renderer.container),
66
+ ...(0, _within.getQueriesForInstance)(renderer.container),
63
67
  rerender,
64
68
  unmount,
65
69
  toJSON,
@@ -95,4 +99,14 @@ function makeDebug(renderer) {
95
99
  }
96
100
  return debugImpl;
97
101
  }
102
+ function withHiddenStyle(style) {
103
+ if (style == null) {
104
+ return {
105
+ display: 'none'
106
+ };
107
+ }
108
+ return [style, {
109
+ display: 'none'
110
+ }];
111
+ }
98
112
  //# sourceMappingURL=render.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_validateOptions","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","createNodeMock","rest","validateOptions","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForElement","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n createRoot,\n type HostElement,\n type JsonElement,\n type Root,\n type RootOptions,\n} from '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 { HOST_TEXT_NAMES } from './helpers/host-component-names';\nimport { validateOptions } from './helpers/validate-options';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\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) => object;\n}\n\nexport type RenderResult = Awaited<ReturnType<typeof render>>;\n\n/**\n * Renders test component deeply using Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {\n const { wrapper: Wrapper, createNodeMock, ...rest } = options || {};\n validateOptions('render', rest, render);\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n createNodeMock,\n };\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = createRoot(rendererOptions);\n\n await act(() => {\n renderer.render(wrap(element));\n });\n\n const container = renderer.container;\n\n const rerender = async (component: React.ReactElement) => {\n await act(() => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = async () => {\n await act(() => {\n renderer.unmount();\n });\n };\n\n const toJSON = (): JsonElement | null => {\n const json = renderer.container.toJSON();\n if (json?.children.length === 0) {\n return null;\n }\n\n if (json?.children.length === 1 && typeof json.children[0] !== 'string') {\n return json.children[0];\n }\n\n return json;\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(renderer.container),\n rerender,\n unmount,\n 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 /* istanbul ignore next */\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;AACA,IAAAC,aAAA,GAAAD,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAgD,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAA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AC3CC,QAAQ;IACRE,OAAO;IACPC,MAAM;IACNO,KAAK,EAAEC,SAAS,CAACf,QAAQ,CAAC;IAC1B,IAAIG,SAASA,CAAA,EAAgB;MAC3B,OAAOH,QAAQ,CAACG,SAAS;IAC3B,CAAC;IACD,IAAIa,IAAIA,CAAA,EAAuB;MAC7B,MAAMC,UAAU,GAAGd,SAAS,CAACM,QAAQ,CAAC,CAAC,CAAC;MACxC,IAAI,OAAOQ,UAAU,KAAK,QAAQ,EAAE;QAClC;QACA,MAAM,IAAIC,KAAK,CACb,wHACF,CAAC;MACH;MAEA,OAAOD,UAAU;IACnB;EACF,CAAC;EAED,IAAAE,uBAAe,EAACP,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAIA,SAASG,SAASA,CAACf,QAAc,EAAiB;EAChD,SAASoB,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,MAAMoB,IAAI,GAAGR,QAAQ,CAACG,SAAS,CAACI,MAAM,CAAC,CAAC;IACxC,IAAIC,IAAI,EAAE;MACR,OAAO,IAAAM,YAAK,EAACN,IAAI,EAAEe,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_validateOptions","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","rest","validateOptions","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","transformHiddenInstanceProps","props","style","withHiddenStyle","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForInstance","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions","display"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { StyleProp } from 'react-native';\nimport {\n createRoot,\n type JsonElement,\n type Root,\n type RootOptions,\n type TestInstance,\n} from '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 { HOST_TEXT_NAMES } from './helpers/host-component-names';\nimport { validateOptions } from './helpers/validate-options';\nimport { setRenderResult } from './screen';\nimport { getQueriesForInstance } from './within';\n\nexport interface RenderOptions {\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 type RenderResult = Awaited<ReturnType<typeof render>>;\n\n/**\n * Renders test component deeply using Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {\n const { wrapper: Wrapper, ...rest } = options || {};\n validateOptions('render', rest, render);\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n transformHiddenInstanceProps: ({ props }) => ({\n ...props,\n style: withHiddenStyle(props.style as StyleProp<StyleLike>),\n }),\n };\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = createRoot(rendererOptions);\n\n await act(() => {\n renderer.render(wrap(element));\n });\n\n const container = renderer.container;\n\n const rerender = async (component: React.ReactElement) => {\n await act(() => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = async () => {\n await act(() => {\n renderer.unmount();\n });\n };\n\n const toJSON = (): JsonElement | null => {\n const json = renderer.container.toJSON();\n if (json?.children.length === 0) {\n return null;\n }\n\n if (json?.children.length === 1 && typeof json.children[0] !== 'string') {\n return json.children[0];\n }\n\n return json;\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForInstance(renderer.container),\n rerender,\n unmount,\n toJSON,\n debug: makeDebug(renderer),\n get container(): TestInstance {\n return renderer.container;\n },\n get root(): TestInstance | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n /* istanbul ignore next */\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\ntype StyleLike = Record<string, unknown>;\n\nfunction withHiddenStyle(style: StyleProp<StyleLike>): StyleProp<StyleLike> {\n if (style == null) {\n return { display: 'none' };\n }\n\n return [style, { display: 'none' }];\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAiD,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAW,CAAA,EAAAC,CAAA,SAAAA,CAAA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,QAAQ,CAACG,SAAS,CAAC;IAC5CC,QAAQ;IACRE,OAAO;IACPC,MAAM;IACNO,KAAK,EAAEC,SAAS,CAACf,QAAQ,CAAC;IAC1B,IAAIG,SAASA,CAAA,EAAiB;MAC5B,OAAOH,QAAQ,CAACG,SAAS;IAC3B,CAAC;IACD,IAAIa,IAAIA,CAAA,EAAwB;MAC9B,MAAMC,UAAU,GAAGd,SAAS,CAACM,QAAQ,CAAC,CAAC,CAAC;MACxC,IAAI,OAAOQ,UAAU,KAAK,QAAQ,EAAE;QAClC;QACA,MAAM,IAAIC,KAAK,CACb,wHACF,CAAC;MACH;MAEA,OAAOD,UAAU;IACnB;EACF,CAAC;EAED,IAAAE,uBAAe,EAACP,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAIA,SAASG,SAASA,CAACf,QAAc,EAAiB;EAChD,SAASoB,SAASA,CAACnC,OAAsB,EAAE;IACzC,MAAM;MAAEoC;IAAoB,CAAC,GAAG,IAAAC,iBAAS,EAAC,CAAC;IAC3C,MAAMC,YAAY,GAAG;MAAE,GAAGF,mBAAmB;MAAE,GAAGpC;IAAQ,CAAC;IAC3D,MAAMuB,IAAI,GAAGR,QAAQ,CAACG,SAAS,CAACI,MAAM,CAAC,CAAC;IACxC,IAAIC,IAAI,EAAE;MACR,OAAO,IAAAM,YAAK,EAACN,IAAI,EAAEe,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB;AAIA,SAASvB,eAAeA,CAACD,KAA2B,EAAwB;EAC1E,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,OAAO;MAAE4B,OAAO,EAAE;IAAO,CAAC;EAC5B;EAEA,OAAO,CAAC5B,KAAK,EAAE;IAAE4B,OAAO,EAAE;EAAO,CAAC,CAAC;AACrC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","defaultScreen","isDetached","container","root","debug","rerender","unmount","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport type { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` function has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\ninterface Screen extends RenderResult {\n isDetached?: boolean;\n}\n\nconst defaultScreen: Screen = {\n isDetached: true,\n get container(): HostElement {\n throw new Error(SCREEN_ERROR);\n },\n get root(): HostElement | null {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplemented,\n rerender: notImplemented,\n unmount: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: Screen = defaultScreen;\n\nexport function setRenderResult(renderResult: RenderResult) {\n screen = renderResult;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAIA,MAAMA,YAAY,GAAG,uCAAuC;AAE5D,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAMD,MAAMG,aAAqB,GAAG;EAC5BC,UAAU,EAAE,IAAI;EAChB,IAAIC,SAASA,CAAA,EAAgB;IAC3B,MAAM,IAAIH,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACD,IAAIM,IAAIA,CAAA,EAAuB;IAC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wB,EAAE7C,cAAc;EACxC8C,iBAAiB,EAAE9C,cAAc;EACjC+C,oBAAoB,EAAE/C,cAAc;EACpCgD,mBAAmB,EAAEhD,cAAc;EACnCiD,sBAAsB,EAAEjD,cAAc;EACtCkD,kBAAkB,EAAElD,cAAc;EAClCmD,qBAAqB,EAAEnD,cAAc;EACrCoD,WAAW,EAAEpD,cAAc;EAC3BqD,cAAc,EAAErD,cAAc;EAC9BsD,aAAa,EAAEtD,cAAc;EAC7BuD,gBAAgB,EAAEvD,cAAc;EAChCwD,YAAY,EAAExD,cAAc;EAC5ByD,eAAe,EAAEzD,cAAc;EAC/B0D,SAAS,EAAE1D,cAAc;EACzB2D,YAAY,EAAE3D,cAAc;EAC5B4D,WAAW,EAAE5D,cAAc;EAC3B6D,cAAc,EAAE7D,cAAc;EAC9B8D,UAAU,EAAE9D,cAAc;EAC1B+D,aAAa,EAAE/D;AACjB,CAAC;AAEM,IAAIgE,MAAc,GAAAC,OAAA,CAAAD,MAAA,GAAG9D,aAAa;AAElC,SAASgE,eAAeA,CAACC,YAA0B,EAAE;EAC1DF,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAGG,YAAY;AACvB;AAEO,SAASC,iBAAiBA,CAAA,EAAG;EAClCH,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG9D,aAAa;AACxB","ignoreList":[]}
1
+ {"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","defaultScreen","isDetached","container","root","debug","rerender","unmount","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport type { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` function has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\ninterface Screen extends RenderResult {\n isDetached?: boolean;\n}\n\nconst defaultScreen: Screen = {\n isDetached: true,\n get container(): TestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get root(): TestInstance | null {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplemented,\n rerender: notImplemented,\n unmount: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: Screen = defaultScreen;\n\nexport function setRenderResult(renderResult: RenderResult) {\n screen = renderResult;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAIA,MAAMA,YAAY,GAAG,uCAAuC;AAE5D,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAMD,MAAMG,aAAqB,GAAG;EAC5BC,UAAU,EAAE,IAAI;EAChB,IAAIC,SAASA,CAAA,EAAiB;IAC5B,MAAM,IAAIH,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACD,IAAIM,IAAIA,CAAA,EAAwB;IAC9B,MAAM,IAAIJ,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACDO,KAAK,EAAEN,cAAc;EACrBO,QAAQ,EAAEP,cAAc;EACxBQ,OAAO,EAAER,cAAc;EACvBS,MAAM,EAAET,cAAc;EACtBU,cAAc,EAAEV,cAAc;EAC9BW,iBAAiB,EAAEX,cAAc;EACjCY,gBAAgB,EAAEZ,cAAc;EAChCa,mBAAmB,EAAEb,cAAc;EACnCc,eAA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cAAc;EAC7BuD,gBAAgB,EAAEvD,cAAc;EAChCwD,YAAY,EAAExD,cAAc;EAC5ByD,eAAe,EAAEzD,cAAc;EAC/B0D,SAAS,EAAE1D,cAAc;EACzB2D,YAAY,EAAE3D,cAAc;EAC5B4D,WAAW,EAAE5D,cAAc;EAC3B6D,cAAc,EAAE7D,cAAc;EAC9B8D,UAAU,EAAE9D,cAAc;EAC1B+D,aAAa,EAAE/D;AACjB,CAAC;AAEM,IAAIgE,MAAc,GAAAC,OAAA,CAAAD,MAAA,GAAG9D,aAAa;AAElC,SAASgE,eAAeA,CAACC,YAA0B,EAAE;EAC1DF,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAGG,YAAY;AACvB;AAEO,SAASC,iBAAiBA,CAAA,EAAG;EAClCH,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG9D,aAAa;AACxB","ignoreList":[]}
@@ -0,0 +1 @@
1
+ export declare const testGateReact19_2: jest.It;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.testGateReact19_2 = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
10
+ const testRendererVersion = require('test-renderer/package.json').version;
11
+ function isVersionAtLeast(versionString, targetMajor, targetMinor, targetPatch) {
12
+ const match = /^(\d+)\.(\d+)\.(\d+)/.exec(versionString);
13
+ if (!match) {
14
+ return false;
15
+ }
16
+ const major = Number(match[1]);
17
+ const minor = Number(match[2]);
18
+ const patch = Number(match[3]);
19
+ if (major !== targetMajor) {
20
+ return major > targetMajor;
21
+ }
22
+ if (minor !== targetMinor) {
23
+ return minor > targetMinor;
24
+ }
25
+ return patch >= targetPatch;
26
+ }
27
+ const testGateReact19_2 = exports.testGateReact19_2 = isVersionAtLeast(_react.default.version, 19, 2, 0) && isVersionAtLeast(testRendererVersion, 1, 2, 0) ? test : test.skip;
28
+ //# sourceMappingURL=react-version-gates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-version-gates.js","names":["_react","_interopRequireDefault","require","e","__esModule","default","testRendererVersion","version","isVersionAtLeast","versionString","targetMajor","targetMinor","targetPatch","match","exec","major","Number","minor","patch","testGateReact19_2","exports","React","test","skip"],"sources":["../../src/test-utils/react-version-gates.ts"],"sourcesContent":["import React from 'react';\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst testRendererVersion = require('test-renderer/package.json').version;\n\nfunction isVersionAtLeast(\n versionString: string,\n targetMajor: number,\n targetMinor: number,\n targetPatch: number,\n): boolean {\n const match = /^(\\d+)\\.(\\d+)\\.(\\d+)/.exec(versionString);\n\n if (!match) {\n return false;\n }\n\n const major = Number(match[1]);\n const minor = Number(match[2]);\n const patch = Number(match[3]);\n\n if (major !== targetMajor) {\n return major > targetMajor;\n }\n\n if (minor !== targetMinor) {\n return minor > targetMinor;\n }\n\n return patch >= targetPatch;\n}\n\nexport const testGateReact19_2 =\n isVersionAtLeast(React.version, 19, 2, 0) && isVersionAtLeast(testRendererVersion, 1, 2, 0)\n ? test\n : test.skip;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAC1B;AACA,MAAMG,mBAAmB,GAAGJ,OAAO,CAAC,4BAA4B,CAAC,CAACK,OAAO;AAEzE,SAASC,gBAAgBA,CACvBC,aAAqB,EACrBC,WAAmB,EACnBC,WAAmB,EACnBC,WAAmB,EACV;EACT,MAAMC,KAAK,GAAG,sBAAsB,CAACC,IAAI,CAACL,aAAa,CAAC;EAExD,IAAI,CAACI,KAAK,EAAE;IACV,OAAO,KAAK;EACd;EAEA,MAAME,KAAK,GAAGC,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9B,MAAMI,KAAK,GAAGD,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9B,MAAMK,KAAK,GAAGF,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAE9B,IAAIE,KAAK,KAAKL,WAAW,EAAE;IACzB,OAAOK,KAAK,GAAGL,WAAW;EAC5B;EAEA,IAAIO,KAAK,KAAKN,WAAW,EAAE;IACzB,OAAOM,KAAK,GAAGN,WAAW;EAC5B;EAEA,OAAOO,KAAK,IAAIN,WAAW;AAC7B;AAEO,MAAMO,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAC5BX,gBAAgB,CAACa,cAAK,CAACd,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAIC,gBAAgB,CAACF,mBAAmB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACvFgB,IAAI,GACJA,IAAI,CAACC,IAAI","ignoreList":[]}
package/build/types.d.ts CHANGED
@@ -16,4 +16,11 @@ export interface Size {
16
16
  height: number;
17
17
  width: number;
18
18
  }
19
+ /**
20
+ * Range of text in a text input.
21
+ */
22
+ export interface TextRange {
23
+ start: number;
24
+ end: number;
25
+ }
19
26
  export type StringWithAutocomplete<T> = T | (string & {});
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** `RefObject` type from React 19. */\nexport type RefObject<T> = {\n current: T;\n};\n\n/**\n * Location of an element.\n */\nexport interface Point {\n y: number;\n x: number;\n}\n\n/**\n * Size of an element.\n */\nexport interface Size {\n height: number;\n width: number;\n}\n\n// TS autocomplete trick\n// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939\nexport type StringWithAutocomplete<T> = T | (string & {});\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** `RefObject` type from React 19. */\nexport type RefObject<T> = {\n current: T;\n};\n\n/**\n * Location of an element.\n */\nexport interface Point {\n y: number;\n x: number;\n}\n\n/**\n * Size of an element.\n */\nexport interface Size {\n height: number;\n width: number;\n}\n\n/**\n * Range of text in a text input.\n */\nexport interface TextRange {\n start: number;\n end: number;\n}\n\n// TS autocomplete trick\n// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939\nexport type StringWithAutocomplete<T> = T | (string & {});\n"],"mappings":"","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  import type { UserEventInstance } from './setup';
3
- export declare function clear(this: UserEventInstance, element: HostElement): Promise<void>;
3
+ export declare function clear(this: UserEventInstance, instance: TestInstance): Promise<void>;
@@ -4,43 +4,43 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.clear = clear;
7
+ var _eventBuilder = require("../event-builder");
7
8
  var _errors = require("../helpers/errors");
8
9
  var _hostComponentNames = require("../helpers/host-component-names");
9
10
  var _pointerEvents = require("../helpers/pointer-events");
10
11
  var _textInput = require("../helpers/text-input");
11
- var _eventBuilder = require("./event-builder");
12
12
  var _type = require("./type/type");
13
13
  var _utils = require("./utils");
14
- async function clear(element) {
15
- if (!(0, _hostComponentNames.isHostTextInput)(element)) {
16
- throw new _errors.ErrorWithStack(`clear() only supports host "TextInput" elements. Passed element has type: "${element.type}".`, clear);
14
+ async function clear(instance) {
15
+ if (!(0, _hostComponentNames.isHostTextInput)(instance)) {
16
+ throw new _errors.ErrorWithStack(`clear() only supports host "TextInput" instances. Passed instance has type: "${instance.type}".`, clear);
17
17
  }
18
- if (!(0, _textInput.isEditableTextInput)(element) || !(0, _pointerEvents.isPointerEventEnabled)(element)) {
18
+ if (!(0, _textInput.isEditableTextInput)(instance) || !(0, _pointerEvents.isPointerEventEnabled)(instance)) {
19
19
  return;
20
20
  }
21
21
 
22
- // 1. Enter element
23
- await (0, _utils.dispatchEvent)(element, 'focus', _eventBuilder.EventBuilder.Common.focus());
22
+ // 1. Enter instance
23
+ await (0, _utils.dispatchEvent)(instance, 'focus', (0, _eventBuilder.buildFocusEvent)());
24
24
 
25
25
  // 2. Select all
26
- const textToClear = (0, _textInput.getTextInputValue)(element);
26
+ const textToClear = (0, _textInput.getTextInputValue)(instance);
27
27
  const selectionRange = {
28
28
  start: 0,
29
29
  end: textToClear.length
30
30
  };
31
- await (0, _utils.dispatchEvent)(element, 'selectionChange', _eventBuilder.EventBuilder.TextInput.selectionChange(selectionRange));
31
+ await (0, _utils.dispatchEvent)(instance, 'selectionChange', (0, _eventBuilder.buildTextSelectionChangeEvent)(selectionRange));
32
32
 
33
33
  // 3. Press backspace with selected text
34
34
  const emptyText = '';
35
- await (0, _type.emitTypingEvents)(element, {
35
+ await (0, _type.emitTypingEvents)(instance, {
36
36
  config: this.config,
37
37
  key: 'Backspace',
38
38
  text: emptyText
39
39
  });
40
40
 
41
- // 4. Exit element
41
+ // 4. Exit instance
42
42
  await (0, _utils.wait)(this.config);
43
- await (0, _utils.dispatchEvent)(element, 'endEditing', _eventBuilder.EventBuilder.TextInput.endEditing(emptyText));
44
- await (0, _utils.dispatchEvent)(element, 'blur', _eventBuilder.EventBuilder.Common.blur());
43
+ await (0, _utils.dispatchEvent)(instance, 'endEditing', (0, _eventBuilder.buildEndEditingEvent)(emptyText));
44
+ await (0, _utils.dispatchEvent)(instance, 'blur', (0, _eventBuilder.buildBlurEvent)());
45
45
  }
46
46
  //# sourceMappingURL=clear.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"clear.js","names":["_errors","require","_hostComponentNames","_pointerEvents","_textInput","_eventBuilder","_type","_utils","clear","element","isHostTextInput","ErrorWithStack","type","isEditableTextInput","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","getTextInputValue","selectionRange","start","end","length","TextInput","selectionChange","emptyText","emitTypingEvents","config","key","text","wait","endEditing","blur"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { getTextInputValue, isEditableTextInput } from '../helpers/text-input';\nimport { EventBuilder } from './event-builder';\nimport type { UserEventInstance } from './setup';\nimport { emitTypingEvents } from './type/type';\nimport { dispatchEvent, wait } from './utils';\n\nexport async function clear(this: UserEventInstance, element: HostElement): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `clear() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n clear,\n );\n }\n\n if (!isEditableTextInput(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n await dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = getTextInputValue(element);\n const selectionRange = {\n start: 0,\n end: textToClear.length,\n };\n await dispatchEvent(\n element,\n 'selectionChange',\n EventBuilder.TextInput.selectionChange(selectionRange),\n );\n\n // 3. Press backspace with selected text\n const emptyText = '';\n await emitTypingEvents(element, {\n config: this.config,\n key: 'Backspace',\n text: emptyText,\n });\n\n // 4. Exit element\n await wait(this.config);\n await dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(emptyText));\n await dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAA0BC,OAAoB,EAAiB;EACxF,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,sBAAc,CACtB,8EAA8EF,OAAO,CAACG,IAAI,IAAI,EAC9FJ,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAK,8BAAmB,EAACJ,OAAO,CAAC,IAAI,CAAC,IAAAK,oCAAqB,EAACL,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,MAAM,IAAAM,oBAAa,EAACN,OAAO,EAAE,OAAO,EAAEO,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAElE;EACA,MAAMC,WAAW,GAAG,IAAAC,4BAAiB,EAACX,OAAO,CAAC;EAC9C,MAAMY,cAAc,GAAG;IACrBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAEJ,WAAW,CAACK;EACnB,CAAC;EACD,MAAM,IAAAT,oBAAa,EACjBN,OAAO,EACP,iBAAiB,EACjBO,0BAAY,CAACS,SAAS,CAACC,eAAe,CAACL,cAAc,CACvD,CAAC;;EAED;EACA,MAAMM,SAAS,GAAG,EAAE;EACpB,MAAM,IAAAC,sBAAgB,EAACnB,OAAO,EAAE;IAC9BoB,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,WAAW;IAChBC,IAAI,EAAEJ;EACR,CAAC,CAAC;;EAEF;EACA,MAAM,IAAAK,WAAI,EAAC,IAAI,CAACH,MAAM,CAAC;EACvB,MAAM,IAAAd,oBAAa,EAACN,OAAO,EAAE,YAAY,EAAEO,0BAAY,CAACS,SAAS,CAACQ,UAAU,CAACN,SAAS,CAAC,CAAC;EACxF,MAAM,IAAAZ,oBAAa,EAACN,OAAO,EAAE,MAAM,EAAEO,0BAAY,CAACC,MAAM,CAACiB,IAAI,CAAC,CAAC,CAAC;AAClE","ignoreList":[]}
1
+ {"version":3,"file":"clear.js","names":["_eventBuilder","require","_errors","_hostComponentNames","_pointerEvents","_textInput","_type","_utils","clear","instance","isHostTextInput","ErrorWithStack","type","isEditableTextInput","isPointerEventEnabled","dispatchEvent","buildFocusEvent","textToClear","getTextInputValue","selectionRange","start","end","length","buildTextSelectionChangeEvent","emptyText","emitTypingEvents","config","key","text","wait","buildEndEditingEvent","buildBlurEvent"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport {\n buildBlurEvent,\n buildEndEditingEvent,\n buildFocusEvent,\n buildTextSelectionChangeEvent,\n} from '../event-builder';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { getTextInputValue, isEditableTextInput } from '../helpers/text-input';\nimport type { UserEventInstance } from './setup';\nimport { emitTypingEvents } from './type/type';\nimport { dispatchEvent, wait } from './utils';\n\nexport async function clear(this: UserEventInstance, instance: TestInstance): Promise<void> {\n if (!isHostTextInput(instance)) {\n throw new ErrorWithStack(\n `clear() only supports host \"TextInput\" instances. Passed instance has type: \"${instance.type}\".`,\n clear,\n );\n }\n\n if (!isEditableTextInput(instance) || !isPointerEventEnabled(instance)) {\n return;\n }\n\n // 1. Enter instance\n await dispatchEvent(instance, 'focus', buildFocusEvent());\n\n // 2. Select all\n const textToClear = getTextInputValue(instance);\n const selectionRange = {\n start: 0,\n end: textToClear.length,\n };\n await dispatchEvent(instance, 'selectionChange', buildTextSelectionChangeEvent(selectionRange));\n\n // 3. Press backspace with selected text\n const emptyText = '';\n await emitTypingEvents(instance, {\n config: this.config,\n key: 'Backspace',\n text: emptyText,\n });\n\n // 4. Exit instance\n await wait(this.config);\n await dispatchEvent(instance, 'endEditing', buildEndEditingEvent(emptyText));\n await dispatchEvent(instance, 'blur', buildBlurEvent());\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAMA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAA0BC,QAAsB,EAAiB;EAC1F,IAAI,CAAC,IAAAC,mCAAe,EAACD,QAAQ,CAAC,EAAE;IAC9B,MAAM,IAAIE,sBAAc,CACtB,gFAAgFF,QAAQ,CAACG,IAAI,IAAI,EACjGJ,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAK,8BAAmB,EAACJ,QAAQ,CAAC,IAAI,CAAC,IAAAK,oCAAqB,EAACL,QAAQ,CAAC,EAAE;IACtE;EACF;;EAEA;EACA,MAAM,IAAAM,oBAAa,EAACN,QAAQ,EAAE,OAAO,EAAE,IAAAO,6BAAe,EAAC,CAAC,CAAC;;EAEzD;EACA,MAAMC,WAAW,GAAG,IAAAC,4BAAiB,EAACT,QAAQ,CAAC;EAC/C,MAAMU,cAAc,GAAG;IACrBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAEJ,WAAW,CAACK;EACnB,CAAC;EACD,MAAM,IAAAP,oBAAa,EAACN,QAAQ,EAAE,iBAAiB,EAAE,IAAAc,2CAA6B,EAACJ,cAAc,CAAC,CAAC;;EAE/F;EACA,MAAMK,SAAS,GAAG,EAAE;EACpB,MAAM,IAAAC,sBAAgB,EAAChB,QAAQ,EAAE;IAC/BiB,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,WAAW;IAChBC,IAAI,EAAEJ;EACR,CAAC,CAAC;;EAEF;EACA,MAAM,IAAAK,WAAI,EAAC,IAAI,CAACH,MAAM,CAAC;EACvB,MAAM,IAAAX,oBAAa,EAACN,QAAQ,EAAE,YAAY,EAAE,IAAAqB,kCAAoB,EAACN,SAAS,CAAC,CAAC;EAC5E,MAAM,IAAAT,oBAAa,EAACN,QAAQ,EAAE,MAAM,EAAE,IAAAsB,4BAAc,EAAC,CAAC,CAAC;AACzD","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  import type { PressOptions } from './press';
3
3
  import type { ScrollToOptions } from './scroll';
4
4
  import { setup } from './setup';
@@ -6,10 +6,10 @@ import type { TypeOptions } from './type';
6
6
  export { UserEventConfig } from './setup';
7
7
  export declare const userEvent: {
8
8
  setup: typeof setup;
9
- press: (element: HostElement) => Promise<void>;
10
- longPress: (element: HostElement, options?: PressOptions) => Promise<void>;
11
- type: (element: HostElement, text: string, options?: TypeOptions) => Promise<void>;
12
- clear: (element: HostElement) => Promise<void>;
13
- paste: (element: HostElement, text: string) => Promise<void>;
14
- scrollTo: (element: HostElement, options: ScrollToOptions) => Promise<void>;
9
+ press: (instance: TestInstance) => Promise<void>;
10
+ longPress: (instance: TestInstance, options?: PressOptions) => Promise<void>;
11
+ type: (instance: TestInstance, text: string, options?: TypeOptions) => Promise<void>;
12
+ clear: (instance: TestInstance) => Promise<void>;
13
+ paste: (instance: TestInstance, text: string) => Promise<void>;
14
+ scrollTo: (instance: TestInstance, options: ScrollToOptions) => Promise<void>;
15
15
  };
@@ -14,11 +14,11 @@ var _setup = require("./setup");
14
14
  const userEvent = exports.userEvent = {
15
15
  setup: _setup.setup,
16
16
  // Direct access for User Event v13 compatibility
17
- press: element => (0, _setup.setup)().press(element),
18
- longPress: (element, options) => (0, _setup.setup)().longPress(element, options),
19
- type: (element, text, options) => (0, _setup.setup)().type(element, text, options),
20
- clear: element => (0, _setup.setup)().clear(element),
21
- paste: (element, text) => (0, _setup.setup)().paste(element, text),
22
- scrollTo: (element, options) => (0, _setup.setup)().scrollTo(element, options)
17
+ press: instance => (0, _setup.setup)().press(instance),
18
+ longPress: (instance, options) => (0, _setup.setup)().longPress(instance, options),
19
+ type: (instance, text, options) => (0, _setup.setup)().type(instance, text, options),
20
+ clear: instance => (0, _setup.setup)().clear(instance),
21
+ paste: (instance, text) => (0, _setup.setup)().paste(instance, text),
22
+ scrollTo: (instance, options) => (0, _setup.setup)().scrollTo(instance, options)
23
23
  };
24
24
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["_setup","require","userEvent","exports","setup","press","element","longPress","options","type","text","clear","paste","scrollTo"],"sources":["../../src/user-event/index.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport type { PressOptions } from './press';\nimport type { ScrollToOptions } from './scroll';\nimport { setup } from './setup';\nimport type { TypeOptions } from './type';\n\nexport { UserEventConfig } from './setup';\n\nexport const userEvent = {\n setup,\n\n // Direct access for User Event v13 compatibility\n press: (element: HostElement) => setup().press(element),\n longPress: (element: HostElement, options?: PressOptions) => setup().longPress(element, options),\n type: (element: HostElement, text: string, options?: TypeOptions) =>\n setup().type(element, text, options),\n clear: (element: HostElement) => setup().clear(element),\n paste: (element: HostElement, text: string) => setup().paste(element, text),\n scrollTo: (element: HostElement, options: ScrollToOptions) => setup().scrollTo(element, options),\n};\n"],"mappings":";;;;;;;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAKO,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,KAAK,EAALA,YAAK;EAEL;EACAC,KAAK,EAAGC,OAAoB,IAAK,IAAAF,YAAK,EAAC,CAAC,CAACC,KAAK,CAACC,OAAO,CAAC;EACvDC,SAAS,EAAEA,CAACD,OAAoB,EAAEE,OAAsB,KAAK,IAAAJ,YAAK,EAAC,CAAC,CAACG,SAAS,CAACD,OAAO,EAAEE,OAAO,CAAC;EAChGC,IAAI,EAAEA,CAACH,OAAoB,EAAEI,IAAY,EAAEF,OAAqB,KAC9D,IAAAJ,YAAK,EAAC,CAAC,CAACK,IAAI,CAACH,OAAO,EAAEI,IAAI,EAAEF,OAAO,CAAC;EACtCG,KAAK,EAAGL,OAAoB,IAAK,IAAAF,YAAK,EAAC,CAAC,CAACO,KAAK,CAACL,OAAO,CAAC;EACvDM,KAAK,EAAEA,CAACN,OAAoB,EAAEI,IAAY,KAAK,IAAAN,YAAK,EAAC,CAAC,CAACQ,KAAK,CAACN,OAAO,EAAEI,IAAI,CAAC;EAC3EG,QAAQ,EAAEA,CAACP,OAAoB,EAAEE,OAAwB,KAAK,IAAAJ,YAAK,EAAC,CAAC,CAACS,QAAQ,CAACP,OAAO,EAAEE,OAAO;AACjG,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":["_setup","require","userEvent","exports","setup","press","instance","longPress","options","type","text","clear","paste","scrollTo"],"sources":["../../src/user-event/index.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport type { PressOptions } from './press';\nimport type { ScrollToOptions } from './scroll';\nimport { setup } from './setup';\nimport type { TypeOptions } from './type';\n\nexport { UserEventConfig } from './setup';\n\nexport const userEvent = {\n setup,\n\n // Direct access for User Event v13 compatibility\n press: (instance: TestInstance) => setup().press(instance),\n longPress: (instance: TestInstance, options?: PressOptions) =>\n setup().longPress(instance, options),\n type: (instance: TestInstance, text: string, options?: TypeOptions) =>\n setup().type(instance, text, options),\n clear: (instance: TestInstance) => setup().clear(instance),\n paste: (instance: TestInstance, text: string) => setup().paste(instance, text),\n scrollTo: (instance: TestInstance, options: ScrollToOptions) =>\n setup().scrollTo(instance, options),\n};\n"],"mappings":";;;;;;;;;;;;AAIA,IAAAA,MAAA,GAAAC,OAAA;AAKO,MAAMC,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACvBE,KAAK,EAALA,YAAK;EAEL;EACAC,KAAK,EAAGC,QAAsB,IAAK,IAAAF,YAAK,EAAC,CAAC,CAACC,KAAK,CAACC,QAAQ,CAAC;EAC1DC,SAAS,EAAEA,CAACD,QAAsB,EAAEE,OAAsB,KACxD,IAAAJ,YAAK,EAAC,CAAC,CAACG,SAAS,CAACD,QAAQ,EAAEE,OAAO,CAAC;EACtCC,IAAI,EAAEA,CAACH,QAAsB,EAAEI,IAAY,EAAEF,OAAqB,KAChE,IAAAJ,YAAK,EAAC,CAAC,CAACK,IAAI,CAACH,QAAQ,EAAEI,IAAI,EAAEF,OAAO,CAAC;EACvCG,KAAK,EAAGL,QAAsB,IAAK,IAAAF,YAAK,EAAC,CAAC,CAACO,KAAK,CAACL,QAAQ,CAAC;EAC1DM,KAAK,EAAEA,CAACN,QAAsB,EAAEI,IAAY,KAAK,IAAAN,YAAK,EAAC,CAAC,CAACQ,KAAK,CAACN,QAAQ,EAAEI,IAAI,CAAC;EAC9EG,QAAQ,EAAEA,CAACP,QAAsB,EAAEE,OAAwB,KACzD,IAAAJ,YAAK,EAAC,CAAC,CAACS,QAAQ,CAACP,QAAQ,EAAEE,OAAO;AACtC,CAAC","ignoreList":[]}
@@ -1,3 +1,3 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  import type { UserEventInstance } from './setup';
3
- export declare function paste(this: UserEventInstance, element: HostElement, text: string): Promise<void>;
3
+ export declare function paste(this: UserEventInstance, instance: TestInstance, text: string): Promise<void>;
@@ -4,53 +4,53 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.paste = paste;
7
+ var _eventBuilder = require("../event-builder");
7
8
  var _errors = require("../helpers/errors");
8
9
  var _hostComponentNames = require("../helpers/host-component-names");
9
10
  var _pointerEvents = require("../helpers/pointer-events");
10
11
  var _textInput = require("../helpers/text-input");
11
12
  var _nativeState = require("../native-state");
12
- var _eventBuilder = require("./event-builder");
13
13
  var _utils = require("./utils");
14
- async function paste(element, text) {
15
- if (!(0, _hostComponentNames.isHostTextInput)(element)) {
16
- throw new _errors.ErrorWithStack(`paste() only supports host "TextInput" elements. Passed element has type: "${element.type}".`, paste);
14
+ async function paste(instance, text) {
15
+ if (!(0, _hostComponentNames.isHostTextInput)(instance)) {
16
+ throw new _errors.ErrorWithStack(`paste() only supports host "TextInput" instances. Passed instance has type: "${instance.type}".`, paste);
17
17
  }
18
- if (!(0, _textInput.isEditableTextInput)(element) || !(0, _pointerEvents.isPointerEventEnabled)(element)) {
18
+ if (!(0, _textInput.isEditableTextInput)(instance) || !(0, _pointerEvents.isPointerEventEnabled)(instance)) {
19
19
  return;
20
20
  }
21
21
 
22
- // 1. Enter element
23
- await (0, _utils.dispatchEvent)(element, 'focus', _eventBuilder.EventBuilder.Common.focus());
22
+ // 1. Enter instance
23
+ await (0, _utils.dispatchEvent)(instance, 'focus', (0, _eventBuilder.buildFocusEvent)());
24
24
 
25
25
  // 2. Select all
26
- const textToClear = (0, _textInput.getTextInputValue)(element);
26
+ const textToClear = (0, _textInput.getTextInputValue)(instance);
27
27
  const rangeToClear = {
28
28
  start: 0,
29
29
  end: textToClear.length
30
30
  };
31
- await (0, _utils.dispatchEvent)(element, 'selectionChange', _eventBuilder.EventBuilder.TextInput.selectionChange(rangeToClear));
31
+ await (0, _utils.dispatchEvent)(instance, 'selectionChange', (0, _eventBuilder.buildTextSelectionChangeEvent)(rangeToClear));
32
32
 
33
33
  // 3. Paste the text
34
- _nativeState.nativeState.valueForElement.set(element, text);
35
- await (0, _utils.dispatchEvent)(element, 'change', _eventBuilder.EventBuilder.TextInput.change(text));
36
- await (0, _utils.dispatchEvent)(element, 'changeText', text);
34
+ _nativeState.nativeState.valueForInstance.set(instance, text);
35
+ await (0, _utils.dispatchEvent)(instance, 'change', (0, _eventBuilder.buildTextChangeEvent)(text));
36
+ await (0, _utils.dispatchEvent)(instance, 'changeText', text);
37
37
  const rangeAfter = {
38
38
  start: text.length,
39
39
  end: text.length
40
40
  };
41
- await (0, _utils.dispatchEvent)(element, 'selectionChange', _eventBuilder.EventBuilder.TextInput.selectionChange(rangeAfter));
41
+ await (0, _utils.dispatchEvent)(instance, 'selectionChange', (0, _eventBuilder.buildTextSelectionChangeEvent)(rangeAfter));
42
42
 
43
43
  // According to the docs only multiline TextInput emits contentSizeChange event
44
44
  // @see: https://reactnative.dev/docs/textinput#oncontentsizechange
45
- const isMultiline = element.props.multiline === true;
45
+ const isMultiline = instance.props.multiline === true;
46
46
  if (isMultiline) {
47
47
  const contentSize = (0, _utils.getTextContentSize)(text);
48
- await (0, _utils.dispatchEvent)(element, 'contentSizeChange', _eventBuilder.EventBuilder.TextInput.contentSizeChange(contentSize));
48
+ await (0, _utils.dispatchEvent)(instance, 'contentSizeChange', (0, _eventBuilder.buildContentSizeChangeEvent)(contentSize));
49
49
  }
50
50
 
51
- // 4. Exit element
51
+ // 4. Exit instance
52
52
  await (0, _utils.wait)(this.config);
53
- await (0, _utils.dispatchEvent)(element, 'endEditing', _eventBuilder.EventBuilder.TextInput.endEditing(text));
54
- await (0, _utils.dispatchEvent)(element, 'blur', _eventBuilder.EventBuilder.Common.blur());
53
+ await (0, _utils.dispatchEvent)(instance, 'endEditing', (0, _eventBuilder.buildEndEditingEvent)(text));
54
+ await (0, _utils.dispatchEvent)(instance, 'blur', (0, _eventBuilder.buildBlurEvent)());
55
55
  }
56
56
  //# sourceMappingURL=paste.js.map