@testing-library/react-native 14.0.0-beta.0 → 14.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +37 -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
@@ -1 +1 @@
1
- {"version":3,"file":"to-have-display-value.js","names":["_jestMatcherUtils","require","_errors","_hostComponentNames","_textInput","_matches","_utils","toHaveDisplayValue","element","expectedValue","options","checkHostElement","isHostTextInput","ErrorWithStack","type","receivedValue","getTextInputValue","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-display-value.ts"],"sourcesContent":["import { matcherHint } from 'jest-matcher-utils';\nimport type { HostElement } from 'test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { getTextInputValue } from '../helpers/text-input';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveDisplayValue(\n this: jest.MatcherContext,\n element: HostElement,\n expectedValue: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(element, toHaveDisplayValue, this);\n\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `toHaveDisplayValue() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n toHaveDisplayValue,\n );\n }\n\n const receivedValue = getTextInputValue(element);\n\n return {\n pass: matches(expectedValue, receivedValue, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveDisplayValue`, 'element', ''),\n `Expected element ${this.isNot ? 'not to' : 'to'} have display value`,\n expectedValue,\n 'Received',\n receivedValue,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,kBAAkBA,CAEhCC,OAAoB,EACpBC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,kBAAkB,EAAE,IAAI,CAAC;EAEnD,IAAI,CAAC,IAAAK,mCAAe,EAACJ,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIK,sBAAc,CACtB,4FAA4FL,OAAO,CAACM,IAAI,IAAI,EAC5GP,kBACF,CAAC;EACH;EAEA,MAAMQ,aAAa,GAAG,IAAAC,4BAAiB,EAACR,OAAO,CAAC;EAEhD,OAAO;IACLS,IAAI,EAAE,IAAAC,gBAAO,EAACT,aAAa,EAAEM,aAAa,EAAEL,OAAO,EAAES,UAAU,EAAET,OAAO,EAAEU,KAAK,CAAC;IAChFC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,qBAAqB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC5E,oBAAoB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAI,qBAAqB,EACrEf,aAAa,EACb,UAAU,EACVM,aACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"to-have-display-value.js","names":["_jestMatcherUtils","require","_errors","_hostComponentNames","_textInput","_matches","_utils","toHaveDisplayValue","instance","expectedValue","options","checkHostElement","isHostTextInput","ErrorWithStack","type","receivedValue","getTextInputValue","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-display-value.ts"],"sourcesContent":["import { matcherHint } from 'jest-matcher-utils';\nimport type { TestInstance } from 'test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { getTextInputValue } from '../helpers/text-input';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveDisplayValue(\n this: jest.MatcherContext,\n instance: TestInstance,\n expectedValue: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(instance, toHaveDisplayValue, this);\n\n if (!isHostTextInput(instance)) {\n throw new ErrorWithStack(\n `toHaveDisplayValue() works only with host \"TextInput\" instances. Passed instance has type \"${instance.type}\".`,\n toHaveDisplayValue,\n );\n }\n\n const receivedValue = getTextInputValue(instance);\n\n return {\n pass: matches(expectedValue, receivedValue, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveDisplayValue`, 'instance', ''),\n `Expected instance ${this.isNot ? 'not to' : 'to'} have display value`,\n expectedValue,\n 'Received',\n receivedValue,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAEA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,kBAAkBA,CAEhCC,QAAsB,EACtBC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,QAAQ,EAAED,kBAAkB,EAAE,IAAI,CAAC;EAEpD,IAAI,CAAC,IAAAK,mCAAe,EAACJ,QAAQ,CAAC,EAAE;IAC9B,MAAM,IAAIK,sBAAc,CACtB,8FAA8FL,QAAQ,CAACM,IAAI,IAAI,EAC/GP,kBACF,CAAC;EACH;EAEA,MAAMQ,aAAa,GAAG,IAAAC,4BAAiB,EAACR,QAAQ,CAAC;EAEjD,OAAO;IACLS,IAAI,EAAE,IAAAC,gBAAO,EAACT,aAAa,EAAEM,aAAa,EAAEL,OAAO,EAAES,UAAU,EAAET,OAAO,EAAEU,KAAK,CAAC;IAChFC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,qBAAqB,EAAE,UAAU,EAAE,EAAE,CAAC,EAC7E,qBAAqB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAI,qBAAqB,EACtEf,aAAa,EACb,UAAU,EACVM,aACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,5 +1,5 @@
1
- import type { HostElement } from 'test-renderer';
2
- export declare function toHaveProp(this: jest.MatcherContext, element: HostElement, name: string, expectedValue: unknown): {
1
+ import type { TestInstance } from 'test-renderer';
2
+ export declare function toHaveProp(this: jest.MatcherContext, instance: TestInstance, name: string, expectedValue: unknown): {
3
3
  pass: boolean;
4
4
  message: () => string;
5
5
  };
@@ -6,20 +6,20 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.toHaveProp = toHaveProp;
7
7
  var _jestMatcherUtils = require("jest-matcher-utils");
8
8
  var _utils = require("./utils");
9
- function toHaveProp(element, name, expectedValue) {
10
- (0, _utils.checkHostElement)(element, toHaveProp, this);
9
+ function toHaveProp(instance, name, expectedValue) {
10
+ (0, _utils.checkHostElement)(instance, toHaveProp, this);
11
11
  const isExpectedValueDefined = expectedValue !== undefined;
12
- const hasProp = name in element.props;
13
- const receivedValue = element.props[name];
12
+ const hasProp = name in instance.props;
13
+ const receivedValue = instance.props[name];
14
14
  const pass = isExpectedValueDefined ? hasProp && this.equals(expectedValue, receivedValue) : hasProp;
15
15
  return {
16
16
  pass,
17
17
  message: () => {
18
18
  const to = this.isNot ? 'not to' : 'to';
19
- const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveProp`, 'element', (0, _jestMatcherUtils.printExpected)(name), {
19
+ const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveProp`, 'instance', (0, _jestMatcherUtils.printExpected)(name), {
20
20
  secondArgument: isExpectedValueDefined ? (0, _jestMatcherUtils.printExpected)(expectedValue) : undefined
21
21
  });
22
- return (0, _utils.formatMessage)(matcher, `Expected element ${to} have prop`, formatProp(name, expectedValue), 'Received', hasProp ? formatProp(name, receivedValue) : undefined);
22
+ return (0, _utils.formatMessage)(matcher, `Expected instance ${to} have prop`, formatProp(name, expectedValue), 'Received', hasProp ? formatProp(name, receivedValue) : undefined);
23
23
  }
24
24
  };
25
25
  }
@@ -1 +1 @@
1
- {"version":3,"file":"to-have-prop.js","names":["_jestMatcherUtils","require","_utils","toHaveProp","element","name","expectedValue","checkHostElement","isExpectedValueDefined","undefined","hasProp","props","receivedValue","pass","equals","message","to","isNot","matcher","matcherHint","printExpected","secondArgument","formatMessage","formatProp","value","stringify"],"sources":["../../src/matchers/to-have-prop.ts"],"sourcesContent":["import { matcherHint, printExpected, stringify } from 'jest-matcher-utils';\nimport type { HostElement } from 'test-renderer';\n\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveProp(\n this: jest.MatcherContext,\n element: HostElement,\n name: string,\n expectedValue: unknown,\n) {\n checkHostElement(element, toHaveProp, this);\n\n const isExpectedValueDefined = expectedValue !== undefined;\n const hasProp = name in element.props;\n const receivedValue = element.props[name];\n\n const pass = isExpectedValueDefined\n ? hasProp && this.equals(expectedValue, receivedValue)\n : hasProp;\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveProp`,\n 'element',\n printExpected(name),\n {\n secondArgument: isExpectedValueDefined ? printExpected(expectedValue) : undefined,\n },\n );\n return formatMessage(\n matcher,\n `Expected element ${to} have prop`,\n formatProp(name, expectedValue),\n 'Received',\n hasProp ? formatProp(name, receivedValue) : undefined,\n );\n },\n };\n}\n\nfunction formatProp(name: string, value: unknown) {\n if (value === undefined) {\n return name;\n }\n\n if (typeof value === 'string') {\n return `${name}=\"${value}\"`;\n }\n\n return `${name}={${stringify(value)}}`;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,UAAUA,CAExBC,OAAoB,EACpBC,IAAY,EACZC,aAAsB,EACtB;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,UAAU,EAAE,IAAI,CAAC;EAE3C,MAAMK,sBAAsB,GAAGF,aAAa,KAAKG,SAAS;EAC1D,MAAMC,OAAO,GAAGL,IAAI,IAAID,OAAO,CAACO,KAAK;EACrC,MAAMC,aAAa,GAAGR,OAAO,CAACO,KAAK,CAACN,IAAI,CAAC;EAEzC,MAAMQ,IAAI,GAAGL,sBAAsB,GAC/BE,OAAO,IAAI,IAAI,CAACI,MAAM,CAACR,aAAa,EAAEM,aAAa,CAAC,GACpDF,OAAO;EAEX,OAAO;IACLG,IAAI;IACJE,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACzB,GAAG,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAE,aAAa,EACxC,SAAS,EACT,IAAAG,+BAAa,EAACf,IAAI,CAAC,EACnB;QACEgB,cAAc,EAAEb,sBAAsB,GAAG,IAAAY,+BAAa,EAACd,aAAa,CAAC,GAAGG;MAC1E,CACF,CAAC;MACD,OAAO,IAAAa,oBAAa,EAClBJ,OAAO,EACP,oBAAoBF,EAAE,YAAY,EAClCO,UAAU,CAAClB,IAAI,EAAEC,aAAa,CAAC,EAC/B,UAAU,EACVI,OAAO,GAAGa,UAAU,CAAClB,IAAI,EAAEO,aAAa,CAAC,GAAGH,SAC9C,CAAC;IACH;EACF,CAAC;AACH;AAEA,SAASc,UAAUA,CAAClB,IAAY,EAAEmB,KAAc,EAAE;EAChD,IAAIA,KAAK,KAAKf,SAAS,EAAE;IACvB,OAAOJ,IAAI;EACb;EAEA,IAAI,OAAOmB,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,GAAGnB,IAAI,KAAKmB,KAAK,GAAG;EAC7B;EAEA,OAAO,GAAGnB,IAAI,KAAK,IAAAoB,2BAAS,EAACD,KAAK,CAAC,GAAG;AACxC","ignoreList":[]}
1
+ {"version":3,"file":"to-have-prop.js","names":["_jestMatcherUtils","require","_utils","toHaveProp","instance","name","expectedValue","checkHostElement","isExpectedValueDefined","undefined","hasProp","props","receivedValue","pass","equals","message","to","isNot","matcher","matcherHint","printExpected","secondArgument","formatMessage","formatProp","value","stringify"],"sources":["../../src/matchers/to-have-prop.ts"],"sourcesContent":["import { matcherHint, printExpected, stringify } from 'jest-matcher-utils';\nimport type { TestInstance } from 'test-renderer';\n\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveProp(\n this: jest.MatcherContext,\n instance: TestInstance,\n name: string,\n expectedValue: unknown,\n) {\n checkHostElement(instance, toHaveProp, this);\n\n const isExpectedValueDefined = expectedValue !== undefined;\n const hasProp = name in instance.props;\n const receivedValue = instance.props[name];\n\n const pass = isExpectedValueDefined\n ? hasProp && this.equals(expectedValue, receivedValue)\n : hasProp;\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveProp`,\n 'instance',\n printExpected(name),\n {\n secondArgument: isExpectedValueDefined ? printExpected(expectedValue) : undefined,\n },\n );\n return formatMessage(\n matcher,\n `Expected instance ${to} have prop`,\n formatProp(name, expectedValue),\n 'Received',\n hasProp ? formatProp(name, receivedValue) : undefined,\n );\n },\n };\n}\n\nfunction formatProp(name: string, value: unknown) {\n if (value === undefined) {\n return name;\n }\n\n if (typeof value === 'string') {\n return `${name}=\"${value}\"`;\n }\n\n return `${name}={${stringify(value)}}`;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,UAAUA,CAExBC,QAAsB,EACtBC,IAAY,EACZC,aAAsB,EACtB;EACA,IAAAC,uBAAgB,EAACH,QAAQ,EAAED,UAAU,EAAE,IAAI,CAAC;EAE5C,MAAMK,sBAAsB,GAAGF,aAAa,KAAKG,SAAS;EAC1D,MAAMC,OAAO,GAAGL,IAAI,IAAID,QAAQ,CAACO,KAAK;EACtC,MAAMC,aAAa,GAAGR,QAAQ,CAACO,KAAK,CAACN,IAAI,CAAC;EAE1C,MAAMQ,IAAI,GAAGL,sBAAsB,GAC/BE,OAAO,IAAI,IAAI,CAACI,MAAM,CAACR,aAAa,EAAEM,aAAa,CAAC,GACpDF,OAAO;EAEX,OAAO;IACLG,IAAI;IACJE,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACzB,GAAG,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAE,aAAa,EACxC,UAAU,EACV,IAAAG,+BAAa,EAACf,IAAI,CAAC,EACnB;QACEgB,cAAc,EAAEb,sBAAsB,GAAG,IAAAY,+BAAa,EAACd,aAAa,CAAC,GAAGG;MAC1E,CACF,CAAC;MACD,OAAO,IAAAa,oBAAa,EAClBJ,OAAO,EACP,qBAAqBF,EAAE,YAAY,EACnCO,UAAU,CAAClB,IAAI,EAAEC,aAAa,CAAC,EAC/B,UAAU,EACVI,OAAO,GAAGa,UAAU,CAAClB,IAAI,EAAEO,aAAa,CAAC,GAAGH,SAC9C,CAAC;IACH;EACF,CAAC;AACH;AAEA,SAASc,UAAUA,CAAClB,IAAY,EAAEmB,KAAc,EAAE;EAChD,IAAIA,KAAK,KAAKf,SAAS,EAAE;IACvB,OAAOJ,IAAI;EACb;EAEA,IAAI,OAAOmB,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAO,GAAGnB,IAAI,KAAKmB,KAAK,GAAG;EAC7B;EAEA,OAAO,GAAGnB,IAAI,KAAK,IAAAoB,2BAAS,EAACD,KAAK,CAAC,GAAG;AACxC","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
2
- import type { HostElement } from 'test-renderer';
2
+ import type { TestInstance } from 'test-renderer';
3
3
  export type Style = ViewStyle | TextStyle | ImageStyle;
4
- export declare function toHaveStyle(this: jest.MatcherContext, element: HostElement, style: StyleProp<Style>): {
4
+ export declare function toHaveStyle(this: jest.MatcherContext, instance: TestInstance, style: StyleProp<Style>): {
5
5
  pass: boolean;
6
6
  message: () => string;
7
7
  };
@@ -7,18 +7,18 @@ exports.toHaveStyle = toHaveStyle;
7
7
  var _reactNative = require("react-native");
8
8
  var _jestMatcherUtils = require("jest-matcher-utils");
9
9
  var _utils = require("./utils");
10
- function toHaveStyle(element, style) {
11
- (0, _utils.checkHostElement)(element, toHaveStyle, this);
10
+ function toHaveStyle(instance, style) {
11
+ (0, _utils.checkHostElement)(instance, toHaveStyle, this);
12
12
  const expected = _reactNative.StyleSheet.flatten(style) ?? {};
13
- const received = _reactNative.StyleSheet.flatten(element.props.style) ?? {};
13
+ const received = _reactNative.StyleSheet.flatten(instance.props.style) ?? {};
14
14
  const pass = Object.keys(expected).every(key => this.equals(expected[key], received[key]));
15
15
  return {
16
16
  pass,
17
17
  message: () => {
18
18
  const to = this.isNot ? 'not to' : 'to';
19
- const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveStyle`, 'element', '');
19
+ const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveStyle`, 'instance', '');
20
20
  if (pass) {
21
- return (0, _utils.formatMessage)(matcher, `Expected element ${to} have style`, formatStyles(expected), 'Received', formatStyles(pickReceivedStyles(expected, received)));
21
+ return (0, _utils.formatMessage)(matcher, `Expected instance ${to} have style`, formatStyles(expected), 'Received', formatStyles(pickReceivedStyles(expected, received)));
22
22
  } else {
23
23
  return [matcher, '', expectedDiff(expected, received)].join('\n');
24
24
  }
@@ -1 +1 @@
1
- {"version":3,"file":"to-have-style.js","names":["_reactNative","require","_jestMatcherUtils","_utils","toHaveStyle","element","style","checkHostElement","expected","StyleSheet","flatten","received","props","pass","Object","keys","every","key","equals","message","to","isNot","matcher","matcherHint","formatMessage","formatStyles","pickReceivedStyles","expectedDiff","join","receivedNarrow","diff","result","forEach","undefined","sort","map","prop","JSON","stringify"],"sources":["../../src/matchers/to-have-style.ts"],"sourcesContent":["import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\nimport { diff, matcherHint } from 'jest-matcher-utils';\nimport type { HostElement } from 'test-renderer';\n\nimport { checkHostElement, formatMessage } from './utils';\n\nexport type Style = ViewStyle | TextStyle | ImageStyle;\n\ntype StyleLike = Record<string, unknown>;\n\nexport function toHaveStyle(\n this: jest.MatcherContext,\n element: HostElement,\n style: StyleProp<Style>,\n) {\n checkHostElement(element, toHaveStyle, this);\n\n const expected = (StyleSheet.flatten(style) as StyleLike) ?? {};\n const received = (StyleSheet.flatten(element.props.style) as StyleLike) ?? {};\n\n const pass = Object.keys(expected).every((key) => this.equals(expected[key], received[key]));\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toHaveStyle`, 'element', '');\n\n if (pass) {\n return formatMessage(\n matcher,\n `Expected element ${to} have style`,\n formatStyles(expected),\n 'Received',\n formatStyles(pickReceivedStyles(expected, received)),\n );\n } else {\n return [matcher, '', expectedDiff(expected, received)].join('\\n');\n }\n },\n };\n}\n\n/**\n * Generate diff between `expected` and `received` styles.\n */\nfunction expectedDiff(expected: StyleLike, received: StyleLike) {\n const receivedNarrow = pickReceivedStyles(expected, received);\n return diff(formatStyles(expected), formatStyles(receivedNarrow));\n}\n\n/**\n * Pick from `received` style only the keys present in `expected` style.\n */\nfunction pickReceivedStyles(expected: StyleLike, received: StyleLike) {\n const result: StyleLike = {};\n Object.keys(received).forEach((key) => {\n if (expected[key] !== undefined) {\n result[key] = received[key];\n }\n });\n\n return result;\n}\n\nfunction formatStyles(style: StyleLike) {\n return Object.keys(style)\n .sort()\n .map((prop) => `${prop}: ${JSON.stringify(style[prop], null, 2)};`)\n .join('\\n');\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAMO,SAASG,WAAWA,CAEzBC,OAAoB,EACpBC,KAAuB,EACvB;EACA,IAAAC,uBAAgB,EAACF,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAE5C,MAAMI,QAAQ,GAAIC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC,IAAkB,CAAC,CAAC;EAC/D,MAAMK,QAAQ,GAAIF,uBAAU,CAACC,OAAO,CAACL,OAAO,CAACO,KAAK,CAACN,KAAK,CAAC,IAAkB,CAAC,CAAC;EAE7E,MAAMO,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACP,QAAQ,CAAC,CAACQ,KAAK,CAAEC,GAAG,IAAK,IAAI,CAACC,MAAM,CAACV,QAAQ,CAACS,GAAG,CAAC,EAAEN,QAAQ,CAACM,GAAG,CAAC,CAAC,CAAC;EAE5F,OAAO;IACLJ,IAAI;IACJM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC;MAErF,IAAIR,IAAI,EAAE;QACR,OAAO,IAAAW,oBAAa,EAClBF,OAAO,EACP,oBAAoBF,EAAE,aAAa,EACnCK,YAAY,CAACjB,QAAQ,CAAC,EACtB,UAAU,EACViB,YAAY,CAACC,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC,CACrD,CAAC;MACH,CAAC,MAAM;QACL,OAAO,CAACW,OAAO,EAAE,EAAE,EAAEK,YAAY,CAACnB,QAAQ,EAAEG,QAAQ,CAAC,CAAC,CAACiB,IAAI,CAAC,IAAI,CAAC;MACnE;IACF;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASD,YAAYA,CAACnB,QAAmB,EAAEG,QAAmB,EAAE;EAC9D,MAAMkB,cAAc,GAAGH,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC;EAC7D,OAAO,IAAAmB,sBAAI,EAACL,YAAY,CAACjB,QAAQ,CAAC,EAAEiB,YAAY,CAACI,cAAc,CAAC,CAAC;AACnE;;AAEA;AACA;AACA;AACA,SAASH,kBAAkBA,CAAClB,QAAmB,EAAEG,QAAmB,EAAE;EACpE,MAAMoB,MAAiB,GAAG,CAAC,CAAC;EAC5BjB,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAACqB,OAAO,CAAEf,GAAG,IAAK;IACrC,IAAIT,QAAQ,CAACS,GAAG,CAAC,KAAKgB,SAAS,EAAE;MAC/BF,MAAM,CAACd,GAAG,CAAC,GAAGN,QAAQ,CAACM,GAAG,CAAC;IAC7B;EACF,CAAC,CAAC;EAEF,OAAOc,MAAM;AACf;AAEA,SAASN,YAAYA,CAACnB,KAAgB,EAAE;EACtC,OAAOQ,MAAM,CAACC,IAAI,CAACT,KAAK,CAAC,CACtB4B,IAAI,CAAC,CAAC,CACNC,GAAG,CAAEC,IAAI,IAAK,GAAGA,IAAI,KAAKC,IAAI,CAACC,SAAS,CAAChC,KAAK,CAAC8B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAClER,IAAI,CAAC,IAAI,CAAC;AACf","ignoreList":[]}
1
+ {"version":3,"file":"to-have-style.js","names":["_reactNative","require","_jestMatcherUtils","_utils","toHaveStyle","instance","style","checkHostElement","expected","StyleSheet","flatten","received","props","pass","Object","keys","every","key","equals","message","to","isNot","matcher","matcherHint","formatMessage","formatStyles","pickReceivedStyles","expectedDiff","join","receivedNarrow","diff","result","forEach","undefined","sort","map","prop","JSON","stringify"],"sources":["../../src/matchers/to-have-style.ts"],"sourcesContent":["import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\nimport { diff, matcherHint } from 'jest-matcher-utils';\nimport type { TestInstance } from 'test-renderer';\n\nimport { checkHostElement, formatMessage } from './utils';\n\nexport type Style = ViewStyle | TextStyle | ImageStyle;\n\ntype StyleLike = Record<string, unknown>;\n\nexport function toHaveStyle(\n this: jest.MatcherContext,\n instance: TestInstance,\n style: StyleProp<Style>,\n) {\n checkHostElement(instance, toHaveStyle, this);\n\n const expected = (StyleSheet.flatten(style) as StyleLike) ?? {};\n const received = (StyleSheet.flatten(instance.props.style) as StyleLike) ?? {};\n\n const pass = Object.keys(expected).every((key) => this.equals(expected[key], received[key]));\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toHaveStyle`, 'instance', '');\n\n if (pass) {\n return formatMessage(\n matcher,\n `Expected instance ${to} have style`,\n formatStyles(expected),\n 'Received',\n formatStyles(pickReceivedStyles(expected, received)),\n );\n } else {\n return [matcher, '', expectedDiff(expected, received)].join('\\n');\n }\n },\n };\n}\n\n/**\n * Generate diff between `expected` and `received` styles.\n */\nfunction expectedDiff(expected: StyleLike, received: StyleLike) {\n const receivedNarrow = pickReceivedStyles(expected, received);\n return diff(formatStyles(expected), formatStyles(receivedNarrow));\n}\n\n/**\n * Pick from `received` style only the keys present in `expected` style.\n */\nfunction pickReceivedStyles(expected: StyleLike, received: StyleLike) {\n const result: StyleLike = {};\n Object.keys(received).forEach((key) => {\n if (expected[key] !== undefined) {\n result[key] = received[key];\n }\n });\n\n return result;\n}\n\nfunction formatStyles(style: StyleLike) {\n return Object.keys(style)\n .sort()\n .map((prop) => `${prop}: ${JSON.stringify(style[prop], null, 2)};`)\n .join('\\n');\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AAGA,IAAAE,MAAA,GAAAF,OAAA;AAMO,SAASG,WAAWA,CAEzBC,QAAsB,EACtBC,KAAuB,EACvB;EACA,IAAAC,uBAAgB,EAACF,QAAQ,EAAED,WAAW,EAAE,IAAI,CAAC;EAE7C,MAAMI,QAAQ,GAAIC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC,IAAkB,CAAC,CAAC;EAC/D,MAAMK,QAAQ,GAAIF,uBAAU,CAACC,OAAO,CAACL,QAAQ,CAACO,KAAK,CAACN,KAAK,CAAC,IAAkB,CAAC,CAAC;EAE9E,MAAMO,IAAI,GAAGC,MAAM,CAACC,IAAI,CAACP,QAAQ,CAAC,CAACQ,KAAK,CAAEC,GAAG,IAAK,IAAI,CAACC,MAAM,CAACV,QAAQ,CAACS,GAAG,CAAC,EAAEN,QAAQ,CAACM,GAAG,CAAC,CAAC,CAAC;EAE5F,OAAO;IACLJ,IAAI;IACJM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,CAAC;MAEtF,IAAIR,IAAI,EAAE;QACR,OAAO,IAAAW,oBAAa,EAClBF,OAAO,EACP,qBAAqBF,EAAE,aAAa,EACpCK,YAAY,CAACjB,QAAQ,CAAC,EACtB,UAAU,EACViB,YAAY,CAACC,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC,CACrD,CAAC;MACH,CAAC,MAAM;QACL,OAAO,CAACW,OAAO,EAAE,EAAE,EAAEK,YAAY,CAACnB,QAAQ,EAAEG,QAAQ,CAAC,CAAC,CAACiB,IAAI,CAAC,IAAI,CAAC;MACnE;IACF;EACF,CAAC;AACH;;AAEA;AACA;AACA;AACA,SAASD,YAAYA,CAACnB,QAAmB,EAAEG,QAAmB,EAAE;EAC9D,MAAMkB,cAAc,GAAGH,kBAAkB,CAAClB,QAAQ,EAAEG,QAAQ,CAAC;EAC7D,OAAO,IAAAmB,sBAAI,EAACL,YAAY,CAACjB,QAAQ,CAAC,EAAEiB,YAAY,CAACI,cAAc,CAAC,CAAC;AACnE;;AAEA;AACA;AACA;AACA,SAASH,kBAAkBA,CAAClB,QAAmB,EAAEG,QAAmB,EAAE;EACpE,MAAMoB,MAAiB,GAAG,CAAC,CAAC;EAC5BjB,MAAM,CAACC,IAAI,CAACJ,QAAQ,CAAC,CAACqB,OAAO,CAAEf,GAAG,IAAK;IACrC,IAAIT,QAAQ,CAACS,GAAG,CAAC,KAAKgB,SAAS,EAAE;MAC/BF,MAAM,CAACd,GAAG,CAAC,GAAGN,QAAQ,CAACM,GAAG,CAAC;IAC7B;EACF,CAAC,CAAC;EAEF,OAAOc,MAAM;AACf;AAEA,SAASN,YAAYA,CAACnB,KAAgB,EAAE;EACtC,OAAOQ,MAAM,CAACC,IAAI,CAACT,KAAK,CAAC,CACtB4B,IAAI,CAAC,CAAC,CACNC,GAAG,CAAEC,IAAI,IAAK,GAAGA,IAAI,KAAKC,IAAI,CAACC,SAAS,CAAChC,KAAK,CAAC8B,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAClER,IAAI,CAAC,IAAI,CAAC;AACf","ignoreList":[]}
@@ -1,6 +1,6 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  import type { TextMatch, TextMatchOptions } from '../matches';
3
- export declare function toHaveTextContent(this: jest.MatcherContext, element: HostElement, expectedText: TextMatch, options?: TextMatchOptions): {
3
+ export declare function toHaveTextContent(this: jest.MatcherContext, instance: TestInstance, expectedText: TextMatch, options?: TextMatchOptions): {
4
4
  pass: boolean;
5
5
  message: () => string;
6
6
  };
@@ -8,13 +8,13 @@ var _jestMatcherUtils = require("jest-matcher-utils");
8
8
  var _textContent = require("../helpers/text-content");
9
9
  var _matches = require("../matches");
10
10
  var _utils = require("./utils");
11
- function toHaveTextContent(element, expectedText, options) {
12
- (0, _utils.checkHostElement)(element, toHaveTextContent, this);
13
- const text = (0, _textContent.getTextContent)(element);
11
+ function toHaveTextContent(instance, expectedText, options) {
12
+ (0, _utils.checkHostElement)(instance, toHaveTextContent, this);
13
+ const text = (0, _textContent.getTextContent)(instance);
14
14
  return {
15
15
  pass: (0, _matches.matches)(expectedText, text, options?.normalizer, options?.exact),
16
16
  message: () => {
17
- return [(0, _utils.formatMessage)((0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'element', ''), `Expected element ${this.isNot ? 'not to' : 'to'} have text content`, expectedText, 'Received', text)].join('\n');
17
+ return [(0, _utils.formatMessage)((0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'instance', ''), `Expected instance ${this.isNot ? 'not to' : 'to'} have text content`, expectedText, 'Received', text)].join('\n');
18
18
  }
19
19
  };
20
20
  }
@@ -1 +1 @@
1
- {"version":3,"file":"to-have-text-content.js","names":["_jestMatcherUtils","require","_textContent","_matches","_utils","toHaveTextContent","element","expectedText","options","checkHostElement","text","getTextContent","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-text-content.ts"],"sourcesContent":["import { matcherHint } from 'jest-matcher-utils';\nimport type { HostElement } from 'test-renderer';\n\nimport { getTextContent } from '../helpers/text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveTextContent(\n this: jest.MatcherContext,\n element: HostElement,\n expectedText: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(element, toHaveTextContent, this);\n\n const text = getTextContent(element);\n\n return {\n pass: matches(expectedText, text, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'element', ''),\n `Expected element ${this.isNot ? 'not to' : 'to'} have text content`,\n expectedText,\n 'Received',\n text,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,iBAAiBA,CAE/BC,OAAoB,EACpBC,YAAuB,EACvBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,iBAAiB,EAAE,IAAI,CAAC;EAElD,MAAMK,IAAI,GAAG,IAAAC,2BAAc,EAACL,OAAO,CAAC;EAEpC,OAAO;IACLM,IAAI,EAAE,IAAAC,gBAAO,EAACN,YAAY,EAAEG,IAAI,EAAEF,OAAO,EAAEM,UAAU,EAAEN,OAAO,EAAEO,KAAK,CAAC;IACtEC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,oBAAoB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC3E,oBAAoB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAI,oBAAoB,EACpEZ,YAAY,EACZ,UAAU,EACVG,IACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"to-have-text-content.js","names":["_jestMatcherUtils","require","_textContent","_matches","_utils","toHaveTextContent","instance","expectedText","options","checkHostElement","text","getTextContent","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-text-content.ts"],"sourcesContent":["import { matcherHint } from 'jest-matcher-utils';\nimport type { TestInstance } from 'test-renderer';\n\nimport { getTextContent } from '../helpers/text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveTextContent(\n this: jest.MatcherContext,\n instance: TestInstance,\n expectedText: TextMatch,\n options?: TextMatchOptions,\n) {\n checkHostElement(instance, toHaveTextContent, this);\n\n const text = getTextContent(instance);\n\n return {\n pass: matches(expectedText, text, options?.normalizer, options?.exact),\n message: () => {\n return [\n formatMessage(\n matcherHint(`${this.isNot ? '.not' : ''}.toHaveTextContent`, 'instance', ''),\n `Expected instance ${this.isNot ? 'not to' : 'to'} have text content`,\n expectedText,\n 'Received',\n text,\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAGA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,iBAAiBA,CAE/BC,QAAsB,EACtBC,YAAuB,EACvBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,QAAQ,EAAED,iBAAiB,EAAE,IAAI,CAAC;EAEnD,MAAMK,IAAI,GAAG,IAAAC,2BAAc,EAACL,QAAQ,CAAC;EAErC,OAAO;IACLM,IAAI,EAAE,IAAAC,gBAAO,EAACN,YAAY,EAAEG,IAAI,EAAEF,OAAO,EAAEM,UAAU,EAAEN,OAAO,EAAEO,KAAK,CAAC;IACtEC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,oBAAoB,EAAE,UAAU,EAAE,EAAE,CAAC,EAC5E,qBAAqB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAI,oBAAoB,EACrEZ,YAAY,EACZ,UAAU,EACVG,IACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
@@ -1,5 +1,5 @@
1
1
  import type { StyleProp } from 'react-native';
2
- import type { HostElement } from 'test-renderer';
2
+ import type { TestInstance } from 'test-renderer';
3
3
  import type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';
4
4
  import type { TextMatch, TextMatchOptions } from '../matches';
5
5
  import type { Style } from './to-have-style';
@@ -8,7 +8,7 @@ export interface JestNativeMatchers<R> {
8
8
  * Assert whether a host element is present in the element tree (screen) or not.
9
9
  *
10
10
  * @see
11
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)
11
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeonthescreen)
12
12
  *
13
13
  * @example
14
14
  * <Text>Hello</Text>
@@ -21,7 +21,7 @@ export interface JestNativeMatchers<R> {
21
21
  * Assert whether a host element is checked based on accessibility props.
22
22
  *
23
23
  * @see
24
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
24
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked)
25
25
  *
26
26
  * @see {@link toBePartiallyChecked} for a related matcher.
27
27
  *
@@ -35,7 +35,7 @@ export interface JestNativeMatchers<R> {
35
35
  * Assert whether a host element is collapsed based on accessibility props.
36
36
  *
37
37
  * @see
38
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
38
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded)
39
39
  *
40
40
  * @see {@link toBeExpanded} for an inverse matcher.
41
41
  *
@@ -51,7 +51,7 @@ export interface JestNativeMatchers<R> {
51
51
  * This matcher will check ancestor elements for their disabled state as well.
52
52
  *
53
53
  * @see
54
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
54
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled)
55
55
  *
56
56
  * @see {@link toBeEnabled} for an inverse matcher.
57
57
  *
@@ -68,7 +68,7 @@ export interface JestNativeMatchers<R> {
68
68
  * This matcher will check ancestor elements for their disabled state as well.
69
69
  *
70
70
  * @see
71
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)
71
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobebusy)
72
72
  *
73
73
  * @example
74
74
  * <View testID="loader" aria-busy />
@@ -80,7 +80,7 @@ export interface JestNativeMatchers<R> {
80
80
  * Assert whether a host element has no host children or text content.
81
81
  *
82
82
  * @see
83
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)
83
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeemptyelement)
84
84
  *
85
85
  * @example
86
86
  * <View testID="not-empty">
@@ -97,7 +97,7 @@ export interface JestNativeMatchers<R> {
97
97
  * This matcher will check ancestor elements for their disabled state as well.
98
98
  *
99
99
  * @see
100
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)
100
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled)
101
101
  *
102
102
  * @see {@link toBeDisabled} for inverse matcher.
103
103
  *
@@ -111,7 +111,7 @@ export interface JestNativeMatchers<R> {
111
111
  * Assert whether a host element is expanded based on accessibility props.
112
112
  *
113
113
  * @see
114
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)
114
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded)
115
115
  *
116
116
  * @see {@link toBeCollapsed} for inverse matcher.
117
117
  *
@@ -125,7 +125,7 @@ export interface JestNativeMatchers<R> {
125
125
  * Assert whether a host element is partially checked based on accessibility props.
126
126
  *
127
127
  * @see
128
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)
128
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked)
129
129
  *
130
130
  * @see {@link toBeChecked} for related matcher.
131
131
  *
@@ -139,7 +139,7 @@ export interface JestNativeMatchers<R> {
139
139
  * Assert whether a host element is selected based on accessibility props.
140
140
  *
141
141
  * @see
142
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)
142
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeselected)
143
143
  *
144
144
  * @example
145
145
  * <View testID="view" aria-selected />
@@ -153,7 +153,7 @@ export interface JestNativeMatchers<R> {
153
153
  * This matcher will check ancestor elements for their visibility as well.
154
154
  *
155
155
  * @see
156
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)
156
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobevisible)
157
157
  *
158
158
  * @example
159
159
  * <View testID="visible" />
@@ -167,7 +167,7 @@ export interface JestNativeMatchers<R> {
167
167
  * Assert whether a host element contains another host element.
168
168
  *
169
169
  * @see
170
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)
170
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tocontainelement)
171
171
  *
172
172
  * @example
173
173
  * <View testID="outer">
@@ -176,12 +176,12 @@ export interface JestNativeMatchers<R> {
176
176
  *
177
177
  * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));
178
178
  */
179
- toContainElement(element: HostElement | null): R;
179
+ toContainElement(instance: TestInstance | null): R;
180
180
  /**
181
181
  * Assert whether a host element has a given accessbility value.
182
182
  *
183
183
  * @see
184
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)
184
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessibilityvalue)
185
185
  *
186
186
  *
187
187
  * @example
@@ -194,7 +194,7 @@ export interface JestNativeMatchers<R> {
194
194
  * Assert whether a host element has a given accessibile name based on the accessibility label or text content.
195
195
  *
196
196
  * @see
197
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)
197
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessiblename)
198
198
  *
199
199
  * @example
200
200
  * <View testID="view" aria-label="Hello" />
@@ -206,7 +206,7 @@ export interface JestNativeMatchers<R> {
206
206
  * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.
207
207
  *
208
208
  * @see
209
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)
209
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavedisplayvalue)
210
210
  *
211
211
  * @example
212
212
  * <TextInput testID="input" value="Hello" />
@@ -218,7 +218,7 @@ export interface JestNativeMatchers<R> {
218
218
  * Assert whether a host element has a given prop.
219
219
  *
220
220
  * @see
221
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)
221
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveprop)
222
222
  *
223
223
  * @example
224
224
  * <Text testID="text" numberOfLines={1]} />
@@ -231,7 +231,7 @@ export interface JestNativeMatchers<R> {
231
231
  * Assert whether a host element has a given style.
232
232
  *
233
233
  * @see
234
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)
234
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavestyle)
235
235
  *
236
236
  * @example
237
237
  * <View testID="view" style={{ width: '100%' }} />
@@ -244,7 +244,7 @@ export interface JestNativeMatchers<R> {
244
244
  * Assert whether a host element has a given text content.
245
245
  *
246
246
  * @see
247
- * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)
247
+ * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavetextcontent)
248
248
  *
249
249
  * @example
250
250
  * <View testID="view">
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { HostElement } from 'test-renderer';\n\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether a host element is present in the element tree (screen) or not.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeonthescreen)\n *\n * @example\n * <Text>Hello</Text>\n *\n * expect(getByText('Hello')).toBeOnTheScreen()\n * expect(queryByText('Other')).not.toBeOnTheScreen()\n */\n toBeOnTheScreen(): R;\n\n /**\n * Assert whether a host element is checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBePartiallyChecked} for a related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBeChecked()\n */\n toBeChecked(): R;\n\n /**\n * Assert whether a host element is collapsed based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeExpanded} for an inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded={false} />\n *\n * expect(getByTestId('details').toBeCollapsed()\n */\n toBeCollapsed(): R;\n\n /**\n * Assert whether a host element is disabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeEnabled} for an inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled />\n *\n * expect(getByRole('button').toBeDisabled()\n *\n */\n toBeDisabled(): R;\n\n /**\n * Assert whether a host element is busy based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobebusy)\n *\n * @example\n * <View testID=\"loader\" aria-busy />\n *\n * expect(getByTestId('loader')).toBeBusy()\n */\n toBeBusy(): R;\n\n /**\n * Assert whether a host element has no host children or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeemptyelement)\n *\n * @example\n * <View testID=\"not-empty\">\n * <View testID=\"empty\" />\n * </View>\n *\n * expect(getByTestId('empty')).toBeEmptyElement()\n * expect(getByTestId('not-mepty')).not.toBeEmptyElement()\n */\n toBeEmptyElement(): R;\n\n /**\n * Assert whether a host element is enabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeenabled)\n *\n * @see {@link toBeDisabled} for inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled={false} />\n *\n * expect(getByRole('button').toBeEnabled()\n */\n toBeEnabled(): R;\n\n /**\n * Assert whether a host element is expanded based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeCollapsed} for inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded />\n *\n * expect(getByTestId('details').toBeExpanded()\n */\n toBeExpanded(): R;\n\n /**\n * Assert whether a host element is partially checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobechecked)\n *\n * @see {@link toBeChecked} for related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked=\"mixed\" aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBePartiallyChecked()\n */\n toBePartiallyChecked(): R;\n\n /**\n * Assert whether a host element is selected based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobeselected)\n *\n * @example\n * <View testID=\"view\" aria-selected />\n *\n * expect(getByTestId('view')).toBeSelected()\n */\n toBeSelected(): R;\n\n /**\n * Assert whether a host element is visible based on style and accessibility props.\n *\n * This matcher will check ancestor elements for their visibility as well.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tobevisible)\n *\n * @example\n * <View testID=\"visible\" />\n * <View testID=\"not-visible\" style={{ display: 'none' }} />\n *\n * expect(getByTestId('visible')).toBeVisible()\n * expect(getByTestId('not-visible')).not.toBeVisible()\n */\n toBeVisible(): R;\n\n /**\n * Assert whether a host element contains another host element.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tocontainelement)\n *\n * @example\n * <View testID=\"outer\">\n * <View testID=\"inner\" />\n * </View>\n *\n * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));\n */\n toContainElement(element: HostElement | null): R;\n\n /**\n * Assert whether a host element has a given accessbility value.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessibilityvalue)\n *\n *\n * @example\n * <View testID=\"view\" aria-valuetext=\"33%\" />\n *\n * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });\n */\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n\n /**\n * Assert whether a host element has a given accessibile name based on the accessibility label or text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveaccessiblename)\n *\n * @example\n * <View testID=\"view\" aria-label=\"Hello\" />\n *\n * expect(getByTestId('view')).toHaveAccessibleName('Hello');\n */\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavedisplayvalue)\n *\n * @example\n * <TextInput testID=\"input\" value=\"Hello\" />\n *\n * expect(getByTestId('input')).toHaveDisplayValue('Hello');\n */\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host element has a given prop.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohaveprop)\n *\n * @example\n * <Text testID=\"text\" numberOfLines={1]} />\n *\n * expect(getByTestId('text')).toHaveProp('numberOfLines');\n * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);\n */\n toHaveProp(name: string, expectedValue?: unknown): R;\n\n /**\n * Assert whether a host element has a given style.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavestyle)\n *\n * @example\n * <View testID=\"view\" style={{ width: '100%' }} />\n *\n * expect(getByTestId('view')).toHaveStyle({ width: '100%' });\n * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });\n */\n toHaveStyle(style: StyleProp<Style>): R;\n\n /**\n * Assert whether a host element has a given text content.\n *\n * @see\n * [Jest Matchers docs](https://callstack.github.io/react-native-testing-library/docs/jest-matchers#tohavetextcontent)\n *\n * @example\n * <View testID=\"view\">\n * <Text>Hello World</Text>\n * </View>\n *\n * expect(getByTestId('view')).toHaveTextContent('Hello World');\n * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});\n * expect(getByTestId('view')).toHaveTextContent(/hello/i);\n * expect(getByTestId('view')).not.toHaveTextContent('Hello');\n */\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-expect-error: Invalid module name in augmentation, module '@jest/expect' cannot be found\ndeclare module '@jest/expect' {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface Matchers<R extends void | Promise<void>> extends JestNativeMatchers<R> {}\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/matchers/types.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { TestInstance } from 'test-renderer';\n\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n /**\n * Assert whether a host element is present in the element tree (screen) or not.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeonthescreen)\n *\n * @example\n * <Text>Hello</Text>\n *\n * expect(getByText('Hello')).toBeOnTheScreen()\n * expect(queryByText('Other')).not.toBeOnTheScreen()\n */\n toBeOnTheScreen(): R;\n\n /**\n * Assert whether a host element is checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked)\n *\n * @see {@link toBePartiallyChecked} for a related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBeChecked()\n */\n toBeChecked(): R;\n\n /**\n * Assert whether a host element is collapsed based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeExpanded} for an inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded={false} />\n *\n * expect(getByTestId('details').toBeCollapsed()\n */\n toBeCollapsed(): R;\n\n /**\n * Assert whether a host element is disabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled)\n *\n * @see {@link toBeEnabled} for an inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled />\n *\n * expect(getByRole('button').toBeDisabled()\n *\n */\n toBeDisabled(): R;\n\n /**\n * Assert whether a host element is busy based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobebusy)\n *\n * @example\n * <View testID=\"loader\" aria-busy />\n *\n * expect(getByTestId('loader')).toBeBusy()\n */\n toBeBusy(): R;\n\n /**\n * Assert whether a host element has no host children or text content.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeemptyelement)\n *\n * @example\n * <View testID=\"not-empty\">\n * <View testID=\"empty\" />\n * </View>\n *\n * expect(getByTestId('empty')).toBeEmptyElement()\n * expect(getByTestId('not-mepty')).not.toBeEmptyElement()\n */\n toBeEmptyElement(): R;\n\n /**\n * Assert whether a host element is enabled based on accessibility props.\n *\n * This matcher will check ancestor elements for their disabled state as well.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeenabled)\n *\n * @see {@link toBeDisabled} for inverse matcher.\n *\n * @example\n * <View role=\"button\" aria-disabled={false} />\n *\n * expect(getByRole('button').toBeEnabled()\n */\n toBeEnabled(): R;\n\n /**\n * Assert whether a host element is expanded based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeexpanded)\n *\n * @see {@link toBeCollapsed} for inverse matcher.\n *\n * @example\n * <View testID=\"details\" aria-expanded />\n *\n * expect(getByTestId('details').toBeExpanded()\n */\n toBeExpanded(): R;\n\n /**\n * Assert whether a host element is partially checked based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobechecked)\n *\n * @see {@link toBeChecked} for related matcher.\n *\n * @example\n * <View accessible role=\"checkbox\" aria-checked=\"mixed\" aria-label=\"Enable\" />\n *\n * expect(getByRole('checkbox', { name: \"Enable\" })).toBePartiallyChecked()\n */\n toBePartiallyChecked(): R;\n\n /**\n * Assert whether a host element is selected based on accessibility props.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobeselected)\n *\n * @example\n * <View testID=\"view\" aria-selected />\n *\n * expect(getByTestId('view')).toBeSelected()\n */\n toBeSelected(): R;\n\n /**\n * Assert whether a host element is visible based on style and accessibility props.\n *\n * This matcher will check ancestor elements for their visibility as well.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tobevisible)\n *\n * @example\n * <View testID=\"visible\" />\n * <View testID=\"not-visible\" style={{ display: 'none' }} />\n *\n * expect(getByTestId('visible')).toBeVisible()\n * expect(getByTestId('not-visible')).not.toBeVisible()\n */\n toBeVisible(): R;\n\n /**\n * Assert whether a host element contains another host element.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tocontainelement)\n *\n * @example\n * <View testID=\"outer\">\n * <View testID=\"inner\" />\n * </View>\n *\n * expect(getByTestId('outer')).toContainElement(getByTestId('inner'));\n */\n toContainElement(instance: TestInstance | null): R;\n\n /**\n * Assert whether a host element has a given accessbility value.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessibilityvalue)\n *\n *\n * @example\n * <View testID=\"view\" aria-valuetext=\"33%\" />\n *\n * expect(getByTestId('view')).toHaveAccessibilityValue({ text: '33%' });\n */\n toHaveAccessibilityValue(expectedValue: AccessibilityValueMatcher): R;\n\n /**\n * Assert whether a host element has a given accessibile name based on the accessibility label or text content.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveaccessiblename)\n *\n * @example\n * <View testID=\"view\" aria-label=\"Hello\" />\n *\n * expect(getByTestId('view')).toHaveAccessibleName('Hello');\n */\n toHaveAccessibleName(expectedName?: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host `TextInput` element has a given display value based on `value` prop, unmanaged native state, and `defaultValue` prop.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavedisplayvalue)\n *\n * @example\n * <TextInput testID=\"input\" value=\"Hello\" />\n *\n * expect(getByTestId('input')).toHaveDisplayValue('Hello');\n */\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n\n /**\n * Assert whether a host element has a given prop.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohaveprop)\n *\n * @example\n * <Text testID=\"text\" numberOfLines={1]} />\n *\n * expect(getByTestId('text')).toHaveProp('numberOfLines');\n * expect(getByTestId('text')).toHaveProp('numberOfLines', 1);\n */\n toHaveProp(name: string, expectedValue?: unknown): R;\n\n /**\n * Assert whether a host element has a given style.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavestyle)\n *\n * @example\n * <View testID=\"view\" style={{ width: '100%' }} />\n *\n * expect(getByTestId('view')).toHaveStyle({ width: '100%' });\n * expect(getByTestId('view')).not.toHaveStyle({ width: '50%' });\n */\n toHaveStyle(style: StyleProp<Style>): R;\n\n /**\n * Assert whether a host element has a given text content.\n *\n * @see\n * [Jest Matchers docs](https://oss.callstack.com/react-native-testing-library/docs/api/jest-matchers#tohavetextcontent)\n *\n * @example\n * <View testID=\"view\">\n * <Text>Hello World</Text>\n * </View>\n *\n * expect(getByTestId('view')).toHaveTextContent('Hello World');\n * expect(getByTestId('view')).toHaveTextContent('Hello', { exact: false }});\n * expect(getByTestId('view')).toHaveTextContent(/hello/i);\n * expect(getByTestId('view')).not.toHaveTextContent('Hello');\n */\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type, @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\n// @ts-expect-error: Invalid module name in augmentation, module '@jest/expect' cannot be found\ndeclare module '@jest/expect' {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n interface Matchers<R extends void | Promise<void>> extends JestNativeMatchers<R> {}\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,10 +1,10 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  /**
3
- * Throws HostElementTypeError if passed element is not a host element.
3
+ * Throws HostElementTypeError if passed instance is not a host instance.
4
4
  *
5
- * @param element HostElement to check.
5
+ * @param instance TestInstance to check.
6
6
  * @param matcherFn Matcher function calling the check used for formatting error.
7
7
  * @param context Jest matcher context used for formatting error.
8
8
  */
9
- export declare function checkHostElement(element: HostElement | null | undefined, matcherFn: jest.CustomMatcher, context: jest.MatcherContext): asserts element is HostElement;
9
+ export declare function checkHostElement(instance: TestInstance | null | undefined, matcherFn: jest.CustomMatcher, context: jest.MatcherContext): asserts instance is TestInstance;
10
10
  export declare function formatMessage(matcher: string, expectedLabel: string, expectedValue: string | RegExp | null | undefined, receivedLabel: string, receivedValue: string | null | undefined): string;
@@ -24,20 +24,20 @@ class HostElementTypeError extends Error {
24
24
  } catch {
25
25
  // Deliberately empty.
26
26
  }
27
- this.message = [(0, _jestMatcherUtils.matcherHint)(`${context.isNot ? '.not' : ''}.${matcherFn.name}`, 'received', ''), '', `${(0, _jestMatcherUtils.RECEIVED_COLOR)('received')} value must be a host element.`, withType].join('\n');
27
+ this.message = [(0, _jestMatcherUtils.matcherHint)(`${context.isNot ? '.not' : ''}.${matcherFn.name}`, 'received', ''), '', `${(0, _jestMatcherUtils.RECEIVED_COLOR)('received')} value must be a host instance.`, withType].join('\n');
28
28
  }
29
29
  }
30
30
 
31
31
  /**
32
- * Throws HostElementTypeError if passed element is not a host element.
32
+ * Throws HostElementTypeError if passed instance is not a host instance.
33
33
  *
34
- * @param element HostElement to check.
34
+ * @param instance TestInstance to check.
35
35
  * @param matcherFn Matcher function calling the check used for formatting error.
36
36
  * @param context Jest matcher context used for formatting error.
37
37
  */
38
- function checkHostElement(element, matcherFn, context) {
39
- if (!(0, _componentTree.isHostElement)(element)) {
40
- throw new HostElementTypeError(element, matcherFn, context);
38
+ function checkHostElement(instance, matcherFn, context) {
39
+ if (!(0, _componentTree.isTestInstance)(instance)) {
40
+ throw new HostElementTypeError(instance, matcherFn, context);
41
41
  }
42
42
  }
43
43
  function formatMessage(matcher, expectedLabel, expectedValue, receivedLabel, receivedValue) {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","names":["_jestMatcherUtils","require","_redent","_interopRequireDefault","_componentTree","e","__esModule","default","HostElementTypeError","Error","constructor","received","matcherFn","context","captureStackTrace","withType","printWithType","printReceived","message","matcherHint","isNot","name","RECEIVED_COLOR","join","checkHostElement","element","isHostElement","formatMessage","matcher","expectedLabel","expectedValue","receivedLabel","receivedValue","EXPECTED_COLOR","redent","formatValue","value","stringify"],"sources":["../../src/matchers/utils.ts"],"sourcesContent":["import {\n EXPECTED_COLOR,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n stringify,\n} from 'jest-matcher-utils';\nimport redent from 'redent';\nimport type { HostElement } from 'test-renderer';\n\nimport { isHostElement } from '../helpers/component-tree';\n\nclass HostElementTypeError extends Error {\n constructor(received: unknown, matcherFn: jest.CustomMatcher, context: jest.MatcherContext) {\n super();\n\n /* istanbul ignore next */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, matcherFn);\n }\n\n let withType = '';\n try {\n withType = printWithType('Received', received, printReceived);\n /* istanbul ignore next */\n } catch {\n // Deliberately empty.\n }\n\n this.message = [\n matcherHint(`${context.isNot ? '.not' : ''}.${matcherFn.name}`, 'received', ''),\n '',\n `${RECEIVED_COLOR('received')} value must be a host element.`,\n withType,\n ].join('\\n');\n }\n}\n\n/**\n * Throws HostElementTypeError if passed element is not a host element.\n *\n * @param element HostElement to check.\n * @param matcherFn Matcher function calling the check used for formatting error.\n * @param context Jest matcher context used for formatting error.\n */\nexport function checkHostElement(\n element: HostElement | null | undefined,\n matcherFn: jest.CustomMatcher,\n context: jest.MatcherContext,\n): asserts element is HostElement {\n if (!isHostElement(element)) {\n throw new HostElementTypeError(element, matcherFn, context);\n }\n}\n\nexport function formatMessage(\n matcher: string,\n expectedLabel: string,\n expectedValue: string | RegExp | null | undefined,\n receivedLabel: string,\n receivedValue: string | null | undefined,\n) {\n return [\n `${matcher}\\n`,\n `${expectedLabel}:\\n${EXPECTED_COLOR(redent(formatValue(expectedValue), 2))}`,\n `${receivedLabel}:\\n${RECEIVED_COLOR(redent(formatValue(receivedValue), 2))}`,\n ].join('\\n');\n}\n\nfunction formatValue(value: unknown) {\n return typeof value === 'string' ? value : stringify(value);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AAA0D,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1D,MAAMG,oBAAoB,SAASC,KAAK,CAAC;EACvCC,WAAWA,CAACC,QAAiB,EAAEC,SAA6B,EAAEC,OAA4B,EAAE;IAC1F,KAAK,CAAC,CAAC;;IAEP;IACA,IAAIJ,KAAK,CAACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEF,SAAS,CAAC;IAC1C;IAEA,IAAIG,QAAQ,GAAG,EAAE;IACjB,IAAI;MACFA,QAAQ,GAAG,IAAAC,+BAAa,EAAC,UAAU,EAAEL,QAAQ,EAAEM,+BAAa,CAAC;MAC7D;IACF,CAAC,CAAC,MAAM;MACN;IAAA;IAGF,IAAI,CAACC,OAAO,GAAG,CACb,IAAAC,6BAAW,EAAC,GAAGN,OAAO,CAACO,KAAK,GAAG,MAAM,GAAG,EAAE,IAAIR,SAAS,CAACS,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,EAC/E,EAAE,EACF,GAAG,IAAAC,gCAAc,EAAC,UAAU,CAAC,gCAAgC,EAC7DP,QAAQ,CACT,CAACQ,IAAI,CAAC,IAAI,CAAC;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAC9BC,OAAuC,EACvCb,SAA6B,EAC7BC,OAA4B,EACI;EAChC,IAAI,CAAC,IAAAa,4BAAa,EAACD,OAAO,CAAC,EAAE;IAC3B,MAAM,IAAIjB,oBAAoB,CAACiB,OAAO,EAAEb,SAAS,EAAEC,OAAO,CAAC;EAC7D;AACF;AAEO,SAASc,aAAaA,CAC3BC,OAAe,EACfC,aAAqB,EACrBC,aAAiD,EACjDC,aAAqB,EACrBC,aAAwC,EACxC;EACA,OAAO,CACL,GAAGJ,OAAO,IAAI,EACd,GAAGC,aAAa,MAAM,IAAAI,gCAAc,EAAC,IAAAC,eAAM,EAACC,WAAW,CAACL,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAC7E,GAAGC,aAAa,MAAM,IAAAT,gCAAc,EAAC,IAAAY,eAAM,EAACC,WAAW,CAACH,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC9E,CAACT,IAAI,CAAC,IAAI,CAAC;AACd;AAEA,SAASY,WAAWA,CAACC,KAAc,EAAE;EACnC,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,IAAAC,2BAAS,EAACD,KAAK,CAAC;AAC7D","ignoreList":[]}
1
+ {"version":3,"file":"utils.js","names":["_jestMatcherUtils","require","_redent","_interopRequireDefault","_componentTree","e","__esModule","default","HostElementTypeError","Error","constructor","received","matcherFn","context","captureStackTrace","withType","printWithType","printReceived","message","matcherHint","isNot","name","RECEIVED_COLOR","join","checkHostElement","instance","isTestInstance","formatMessage","matcher","expectedLabel","expectedValue","receivedLabel","receivedValue","EXPECTED_COLOR","redent","formatValue","value","stringify"],"sources":["../../src/matchers/utils.ts"],"sourcesContent":["import {\n EXPECTED_COLOR,\n matcherHint,\n printReceived,\n printWithType,\n RECEIVED_COLOR,\n stringify,\n} from 'jest-matcher-utils';\nimport redent from 'redent';\nimport type { TestInstance } from 'test-renderer';\n\nimport { isTestInstance } from '../helpers/component-tree';\n\nclass HostElementTypeError extends Error {\n constructor(received: unknown, matcherFn: jest.CustomMatcher, context: jest.MatcherContext) {\n super();\n\n /* istanbul ignore next */\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, matcherFn);\n }\n\n let withType = '';\n try {\n withType = printWithType('Received', received, printReceived);\n /* istanbul ignore next */\n } catch {\n // Deliberately empty.\n }\n\n this.message = [\n matcherHint(`${context.isNot ? '.not' : ''}.${matcherFn.name}`, 'received', ''),\n '',\n `${RECEIVED_COLOR('received')} value must be a host instance.`,\n withType,\n ].join('\\n');\n }\n}\n\n/**\n * Throws HostElementTypeError if passed instance is not a host instance.\n *\n * @param instance TestInstance to check.\n * @param matcherFn Matcher function calling the check used for formatting error.\n * @param context Jest matcher context used for formatting error.\n */\nexport function checkHostElement(\n instance: TestInstance | null | undefined,\n matcherFn: jest.CustomMatcher,\n context: jest.MatcherContext,\n): asserts instance is TestInstance {\n if (!isTestInstance(instance)) {\n throw new HostElementTypeError(instance, matcherFn, context);\n }\n}\n\nexport function formatMessage(\n matcher: string,\n expectedLabel: string,\n expectedValue: string | RegExp | null | undefined,\n receivedLabel: string,\n receivedValue: string | null | undefined,\n) {\n return [\n `${matcher}\\n`,\n `${expectedLabel}:\\n${EXPECTED_COLOR(redent(formatValue(expectedValue), 2))}`,\n `${receivedLabel}:\\n${RECEIVED_COLOR(redent(formatValue(receivedValue), 2))}`,\n ].join('\\n');\n}\n\nfunction formatValue(value: unknown) {\n return typeof value === 'string' ? value : stringify(value);\n}\n"],"mappings":";;;;;;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAQA,IAAAC,OAAA,GAAAC,sBAAA,CAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AAA2D,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE3D,MAAMG,oBAAoB,SAASC,KAAK,CAAC;EACvCC,WAAWA,CAACC,QAAiB,EAAEC,SAA6B,EAAEC,OAA4B,EAAE;IAC1F,KAAK,CAAC,CAAC;;IAEP;IACA,IAAIJ,KAAK,CAACK,iBAAiB,EAAE;MAC3BL,KAAK,CAACK,iBAAiB,CAAC,IAAI,EAAEF,SAAS,CAAC;IAC1C;IAEA,IAAIG,QAAQ,GAAG,EAAE;IACjB,IAAI;MACFA,QAAQ,GAAG,IAAAC,+BAAa,EAAC,UAAU,EAAEL,QAAQ,EAAEM,+BAAa,CAAC;MAC7D;IACF,CAAC,CAAC,MAAM;MACN;IAAA;IAGF,IAAI,CAACC,OAAO,GAAG,CACb,IAAAC,6BAAW,EAAC,GAAGN,OAAO,CAACO,KAAK,GAAG,MAAM,GAAG,EAAE,IAAIR,SAAS,CAACS,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,CAAC,EAC/E,EAAE,EACF,GAAG,IAAAC,gCAAc,EAAC,UAAU,CAAC,iCAAiC,EAC9DP,QAAQ,CACT,CAACQ,IAAI,CAAC,IAAI,CAAC;EACd;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAC9BC,QAAyC,EACzCb,SAA6B,EAC7BC,OAA4B,EACM;EAClC,IAAI,CAAC,IAAAa,6BAAc,EAACD,QAAQ,CAAC,EAAE;IAC7B,MAAM,IAAIjB,oBAAoB,CAACiB,QAAQ,EAAEb,SAAS,EAAEC,OAAO,CAAC;EAC9D;AACF;AAEO,SAASc,aAAaA,CAC3BC,OAAe,EACfC,aAAqB,EACrBC,aAAiD,EACjDC,aAAqB,EACrBC,aAAwC,EACxC;EACA,OAAO,CACL,GAAGJ,OAAO,IAAI,EACd,GAAGC,aAAa,MAAM,IAAAI,gCAAc,EAAC,IAAAC,eAAM,EAACC,WAAW,CAACL,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAC7E,GAAGC,aAAa,MAAM,IAAAT,gCAAc,EAAC,IAAAY,eAAM,EAACC,WAAW,CAACH,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAC9E,CAACT,IAAI,CAAC,IAAI,CAAC;AACd;AAEA,SAASY,WAAWA,CAACC,KAAc,EAAE;EACnC,OAAO,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,GAAG,IAAAC,2BAAS,EAACD,KAAK,CAAC;AAC7D","ignoreList":[]}
@@ -1,4 +1,4 @@
1
- import type { HostElement } from 'test-renderer';
1
+ import type { TestInstance } from 'test-renderer';
2
2
  import type { Point } from './types';
3
3
  /**
4
4
  * Simulated native state for unmanaged controls.
@@ -6,7 +6,7 @@ import type { Point } from './types';
6
6
  * Values from `value` props (managed controls) should take precedence over these values.
7
7
  */
8
8
  export type NativeState = {
9
- valueForElement: WeakMap<HostElement, string>;
10
- contentOffsetForElement: WeakMap<HostElement, Point>;
9
+ valueForInstance: WeakMap<TestInstance, string>;
10
+ contentOffsetForInstance: WeakMap<TestInstance, Point>;
11
11
  };
12
12
  export declare const nativeState: NativeState;
@@ -11,7 +11,7 @@ exports.nativeState = void 0;
11
11
  */
12
12
 
13
13
  const nativeState = exports.nativeState = {
14
- valueForElement: new WeakMap(),
15
- contentOffsetForElement: new WeakMap()
14
+ valueForInstance: new WeakMap(),
15
+ contentOffsetForInstance: new WeakMap()
16
16
  };
17
17
  //# sourceMappingURL=native-state.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"native-state.js","names":["nativeState","exports","valueForElement","WeakMap","contentOffsetForElement"],"sources":["../src/native-state.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport type { Point } from './types';\n\n/**\n * Simulated native state for unmanaged controls.\n *\n * Values from `value` props (managed controls) should take precedence over these values.\n */\nexport type NativeState = {\n valueForElement: WeakMap<HostElement, string>;\n contentOffsetForElement: WeakMap<HostElement, Point>;\n};\n\nexport const nativeState: NativeState = {\n valueForElement: new WeakMap(),\n contentOffsetForElement: new WeakMap(),\n};\n"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACA;;AAMO,MAAMA,WAAwB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACtCE,eAAe,EAAE,IAAIC,OAAO,CAAC,CAAC;EAC9BC,uBAAuB,EAAE,IAAID,OAAO,CAAC;AACvC,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"native-state.js","names":["nativeState","exports","valueForInstance","WeakMap","contentOffsetForInstance"],"sources":["../src/native-state.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport type { Point } from './types';\n\n/**\n * Simulated native state for unmanaged controls.\n *\n * Values from `value` props (managed controls) should take precedence over these values.\n */\nexport type NativeState = {\n valueForInstance: WeakMap<TestInstance, string>;\n contentOffsetForInstance: WeakMap<TestInstance, Point>;\n};\n\nexport const nativeState: NativeState = {\n valueForInstance: new WeakMap(),\n contentOffsetForInstance: new WeakMap(),\n};\n"],"mappings":";;;;;;AAIA;AACA;AACA;AACA;AACA;;AAMO,MAAMA,WAAwB,GAAAC,OAAA,CAAAD,WAAA,GAAG;EACtCE,gBAAgB,EAAE,IAAIC,OAAO,CAAC,CAAC;EAC/BC,wBAAwB,EAAE,IAAID,OAAO,CAAC;AACxC,CAAC","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 ByDisplayValueQueries = {
11
11
  findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;
12
12
  findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;
13
13
  };
14
- export declare const bindByDisplayValueQueries: (element: HostElement) => ByDisplayValueQueries;
14
+ export declare const bindByDisplayValueQueries: (instance: TestInstance) => ByDisplayValueQueries;
15
15
  export {};
@@ -9,16 +9,16 @@ var _hostComponentNames = require("../helpers/host-component-names");
9
9
  var _textInput = require("../helpers/text-input");
10
10
  var _matches = require("../matches");
11
11
  var _makeQueries = require("./make-queries");
12
- const matchDisplayValue = (node, expectedValue, options = {}) => {
12
+ const matchDisplayValue = (instance, expectedValue, options = {}) => {
13
13
  const {
14
14
  exact,
15
15
  normalizer
16
16
  } = options;
17
- const nodeValue = (0, _textInput.getTextInputValue)(node);
18
- return (0, _matches.matches)(expectedValue, nodeValue, normalizer, exact);
17
+ const instanceValue = (0, _textInput.getTextInputValue)(instance);
18
+ return (0, _matches.matches)(expectedValue, instanceValue, normalizer, exact);
19
19
  };
20
- const queryAllByDisplayValue = element => function queryAllByDisplayValueFn(displayValue, queryOptions) {
21
- return (0, _findAll.findAll)(element, node => (0, _hostComponentNames.isHostTextInput)(node) && matchDisplayValue(node, displayValue, queryOptions), queryOptions);
20
+ const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
21
+ return (0, _findAll.findAll)(instance, item => (0, _hostComponentNames.isHostTextInput)(item) && matchDisplayValue(item, displayValue, queryOptions), queryOptions);
22
22
  };
23
23
  const getMultipleError = displayValue => `Found multiple elements with display value: ${String(displayValue)} `;
24
24
  const getMissingError = displayValue => `Unable to find an element with displayValue: ${String(displayValue)}`;
@@ -30,13 +30,13 @@ const {
30
30
  findBy,
31
31
  findAllBy
32
32
  } = (0, _makeQueries.makeQueries)(queryAllByDisplayValue, getMissingError, getMultipleError);
33
- const bindByDisplayValueQueries = element => ({
34
- getByDisplayValue: getBy(element),
35
- getAllByDisplayValue: getAllBy(element),
36
- queryByDisplayValue: queryBy(element),
37
- queryAllByDisplayValue: queryAllBy(element),
38
- findByDisplayValue: findBy(element),
39
- findAllByDisplayValue: findAllBy(element)
33
+ const bindByDisplayValueQueries = instance => ({
34
+ getByDisplayValue: getBy(instance),
35
+ getAllByDisplayValue: getAllBy(instance),
36
+ queryByDisplayValue: queryBy(instance),
37
+ queryAllByDisplayValue: queryAllBy(instance),
38
+ findByDisplayValue: findBy(instance),
39
+ findAllByDisplayValue: findAllBy(instance)
40
40
  });
41
41
  exports.bindByDisplayValueQueries = bindByDisplayValueQueries;
42
42
  //# sourceMappingURL=display-value.js.map