@testing-library/react-native 12.2.2 → 12.3.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 (164) hide show
  1. package/build/act.js +1 -2
  2. package/build/act.js.map +1 -1
  3. package/build/config.d.ts +2 -0
  4. package/build/config.js.map +1 -1
  5. package/build/fireEvent.js +3 -3
  6. package/build/fireEvent.js.map +1 -1
  7. package/build/helpers/accessiblity.d.ts +11 -0
  8. package/build/helpers/accessiblity.js +108 -8
  9. package/build/helpers/accessiblity.js.map +1 -1
  10. package/build/helpers/component-tree.d.ts +7 -0
  11. package/build/helpers/component-tree.js +18 -0
  12. package/build/helpers/component-tree.js.map +1 -1
  13. package/build/helpers/format-default.d.ts +1 -2
  14. package/build/helpers/format-default.js +22 -13
  15. package/build/helpers/format-default.js.map +1 -1
  16. package/build/helpers/format.js +4 -8
  17. package/build/helpers/format.js.map +1 -1
  18. package/build/helpers/host-component-names.d.ts +10 -0
  19. package/build/helpers/host-component-names.js +27 -3
  20. package/build/helpers/host-component-names.js.map +1 -1
  21. package/build/helpers/matchers/accessibilityState.js +3 -3
  22. package/build/helpers/matchers/accessibilityState.js.map +1 -1
  23. package/build/helpers/matchers/accessibilityValue.js +3 -2
  24. package/build/helpers/matchers/accessibilityValue.js.map +1 -1
  25. package/build/helpers/matchers/matchLabelText.d.ts +1 -1
  26. package/build/helpers/matchers/matchLabelText.js +5 -8
  27. package/build/helpers/matchers/matchLabelText.js.map +1 -1
  28. package/build/helpers/matchers/matchTextContent.js +2 -2
  29. package/build/helpers/matchers/matchTextContent.js.map +1 -1
  30. package/build/helpers/object.d.ts +1 -0
  31. package/build/helpers/object.js +16 -0
  32. package/build/helpers/object.js.map +1 -0
  33. package/build/helpers/{getTextContent.js → text-content.js} +1 -1
  34. package/build/helpers/text-content.js.map +1 -0
  35. package/build/helpers/text-input.d.ts +3 -0
  36. package/build/helpers/text-input.js +21 -0
  37. package/build/helpers/text-input.js.map +1 -0
  38. package/build/helpers/wrap-async.d.ts +7 -0
  39. package/build/helpers/wrap-async.js +45 -0
  40. package/build/helpers/wrap-async.js.map +1 -0
  41. package/build/matchers/extend-expect.d.js +2 -0
  42. package/build/matchers/extend-expect.d.js.map +1 -0
  43. package/build/matchers/extend-expect.d.ts +2 -0
  44. package/build/matchers/extend-expect.js +38 -0
  45. package/build/matchers/extend-expect.js.map +1 -0
  46. package/build/matchers/index.d.ts +15 -0
  47. package/build/matchers/index.js +117 -0
  48. package/build/matchers/index.js.map +1 -0
  49. package/build/matchers/to-be-busy.d.ts +6 -0
  50. package/build/matchers/to-be-busy.js +20 -0
  51. package/build/matchers/to-be-busy.js.map +1 -0
  52. package/build/matchers/to-be-checked.d.ts +6 -0
  53. package/build/matchers/to-be-checked.js +31 -0
  54. package/build/matchers/to-be-checked.js.map +1 -0
  55. package/build/matchers/to-be-collapsed.d.ts +6 -0
  56. package/build/matchers/to-be-collapsed.js +20 -0
  57. package/build/matchers/to-be-collapsed.js.map +1 -0
  58. package/build/matchers/to-be-disabled.d.ts +10 -0
  59. package/build/matchers/to-be-disabled.js +52 -0
  60. package/build/matchers/to-be-disabled.js.map +1 -0
  61. package/build/matchers/to-be-empty-element.d.ts +6 -0
  62. package/build/matchers/to-be-empty-element.js +20 -0
  63. package/build/matchers/to-be-empty-element.js.map +1 -0
  64. package/build/matchers/to-be-expanded.d.ts +6 -0
  65. package/build/matchers/to-be-expanded.js +20 -0
  66. package/build/matchers/to-be-expanded.js.map +1 -0
  67. package/build/matchers/to-be-on-the-screen.d.ts +6 -0
  68. package/build/matchers/to-be-on-the-screen.js +29 -0
  69. package/build/matchers/to-be-on-the-screen.js.map +1 -0
  70. package/build/matchers/to-be-partially-checked.d.ts +6 -0
  71. package/build/matchers/to-be-partially-checked.js +28 -0
  72. package/build/matchers/to-be-partially-checked.js.map +1 -0
  73. package/build/matchers/to-be-selected.d.ts +6 -0
  74. package/build/matchers/to-be-selected.js +20 -0
  75. package/build/matchers/to-be-selected.js.map +1 -0
  76. package/build/matchers/to-be-visible.d.ts +6 -0
  77. package/build/matchers/to-be-visible.js +56 -0
  78. package/build/matchers/to-be-visible.js.map +1 -0
  79. package/build/matchers/to-contain-element.d.ts +6 -0
  80. package/build/matchers/to-contain-element.js +26 -0
  81. package/build/matchers/to-contain-element.js.map +1 -0
  82. package/build/matchers/to-have-display-value.d.ts +7 -0
  83. package/build/matchers/to-have-display-value.js +26 -0
  84. package/build/matchers/to-have-display-value.js.map +1 -0
  85. package/build/matchers/to-have-prop.d.ts +6 -0
  86. package/build/matchers/to-have-prop.js +35 -0
  87. package/build/matchers/to-have-prop.js.map +1 -0
  88. package/build/matchers/to-have-style.d.ts +8 -0
  89. package/build/matchers/to-have-style.js +52 -0
  90. package/build/matchers/to-have-style.js.map +1 -0
  91. package/build/matchers/to-have-text-content.d.ts +7 -0
  92. package/build/matchers/to-have-text-content.js +21 -0
  93. package/build/matchers/to-have-text-content.js.map +1 -0
  94. package/build/matchers/utils.d.ts +18 -0
  95. package/build/matchers/utils.js +90 -0
  96. package/build/matchers/utils.js.map +1 -0
  97. package/build/matches.d.ts +1 -1
  98. package/build/matches.js.map +1 -1
  99. package/build/queries/displayValue.js +4 -3
  100. package/build/queries/displayValue.js.map +1 -1
  101. package/build/queries/labelText.js +2 -2
  102. package/build/queries/labelText.js.map +1 -1
  103. package/build/queries/role.js +1 -1
  104. package/build/queries/role.js.map +1 -1
  105. package/build/react-versions.js +2 -2
  106. package/build/react-versions.js.map +1 -1
  107. package/build/render.d.ts +12 -48
  108. package/build/render.js +5 -4
  109. package/build/render.js.map +1 -1
  110. package/build/screen.js +1 -2
  111. package/build/screen.js.map +1 -1
  112. package/build/shallow.js +2 -2
  113. package/build/shallow.js.map +1 -1
  114. package/build/test-utils/events.d.ts +1 -2
  115. package/build/test-utils/events.js.map +1 -1
  116. package/build/user-event/clear.js +2 -1
  117. package/build/user-event/clear.js.map +1 -1
  118. package/build/user-event/event-builder/common.js +1 -2
  119. package/build/user-event/event-builder/common.js.map +1 -1
  120. package/build/user-event/event-builder/index.d.ts +30 -0
  121. package/build/user-event/event-builder/index.js +3 -2
  122. package/build/user-event/event-builder/index.js.map +1 -1
  123. package/build/user-event/event-builder/scroll-view.d.ts +42 -0
  124. package/build/user-event/event-builder/scroll-view.js +52 -0
  125. package/build/user-event/event-builder/scroll-view.js.map +1 -0
  126. package/build/user-event/event-builder/text-input.js +1 -2
  127. package/build/user-event/event-builder/text-input.js.map +1 -1
  128. package/build/user-event/index.d.ts +2 -0
  129. package/build/user-event/index.js +3 -3
  130. package/build/user-event/index.js.map +1 -1
  131. package/build/user-event/press/constants.js +2 -4
  132. package/build/user-event/press/constants.js.map +1 -1
  133. package/build/user-event/press/press.js +11 -14
  134. package/build/user-event/press/press.js.map +1 -1
  135. package/build/user-event/scroll/index.d.ts +1 -0
  136. package/build/user-event/scroll/index.js +19 -0
  137. package/build/user-event/scroll/index.js.map +1 -0
  138. package/build/user-event/scroll/scrollTo.d.ts +16 -0
  139. package/build/user-event/scroll/scrollTo.js +82 -0
  140. package/build/user-event/scroll/scrollTo.js.map +1 -0
  141. package/build/user-event/scroll/state.d.ts +4 -0
  142. package/build/user-event/scroll/state.js +18 -0
  143. package/build/user-event/scroll/state.js.map +1 -0
  144. package/build/user-event/scroll/utils.d.ts +20 -0
  145. package/build/user-event/scroll/utils.js +68 -0
  146. package/build/user-event/scroll/utils.js.map +1 -0
  147. package/build/user-event/setup/setup.d.ts +8 -0
  148. package/build/user-event/setup/setup.js +34 -6
  149. package/build/user-event/setup/setup.js.map +1 -1
  150. package/build/user-event/type/type.js +2 -1
  151. package/build/user-event/type/type.js.map +1 -1
  152. package/build/user-event/utils/index.d.ts +0 -1
  153. package/build/user-event/utils/index.js +0 -11
  154. package/build/user-event/utils/index.js.map +1 -1
  155. package/build/waitFor.js +2 -26
  156. package/build/waitFor.js.map +1 -1
  157. package/build/within.js +1 -2
  158. package/build/within.js.map +1 -1
  159. package/package.json +23 -37
  160. package/build/helpers/getTextContent.js.map +0 -1
  161. package/build/user-event/utils/host-components.d.ts +0 -2
  162. package/build/user-event/utils/host-components.js +0 -11
  163. package/build/user-event/utils/host-components.js.map +0 -1
  164. /package/build/helpers/{getTextContent.d.ts → text-content.d.ts} +0 -0
@@ -5,14 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.configureHostComponentNamesIfNeeded = configureHostComponentNamesIfNeeded;
7
7
  exports.getHostComponentNames = getHostComponentNames;
8
+ exports.isHostModal = isHostModal;
9
+ exports.isHostScrollView = isHostScrollView;
8
10
  exports.isHostText = isHostText;
9
11
  exports.isHostTextInput = isHostTextInput;
10
12
  var React = _interopRequireWildcard(require("react"));
11
13
  var _reactNative = require("react-native");
12
14
  var _config = require("../config");
13
15
  var _renderAct = require("../render-act");
14
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
16
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
17
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
16
18
  const userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
17
19
  Please check if you are using compatible versions of React Native and React Native Testing Library.`;
18
20
  function getHostComponentNames() {
@@ -43,11 +45,17 @@ function detectHostComponentNames() {
43
45
  testID: "textInput"
44
46
  }), /*#__PURE__*/React.createElement(_reactNative.Switch, {
45
47
  testID: "switch"
48
+ }), /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
49
+ testID: "scrollView"
50
+ }), /*#__PURE__*/React.createElement(_reactNative.Modal, {
51
+ testID: "modal"
46
52
  })));
47
53
  return {
48
54
  text: getByTestId(renderer.root, 'text').type,
49
55
  textInput: getByTestId(renderer.root, 'textInput').type,
50
- switch: getByTestId(renderer.root, 'switch').type
56
+ switch: getByTestId(renderer.root, 'switch').type,
57
+ scrollView: getByTestId(renderer.root, 'scrollView').type,
58
+ modal: getByTestId(renderer.root, 'modal').type
51
59
  };
52
60
  } catch (error) {
53
61
  const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
@@ -77,4 +85,20 @@ function isHostText(element) {
77
85
  function isHostTextInput(element) {
78
86
  return element?.type === getHostComponentNames().textInput;
79
87
  }
88
+
89
+ /**
90
+ * Checks if the given element is a host ScrollView.
91
+ * @param element The element to check.
92
+ */
93
+ function isHostScrollView(element) {
94
+ return element?.type === getHostComponentNames().scrollView;
95
+ }
96
+
97
+ /**
98
+ * Checks if the given element is a host Modal.
99
+ * @param element The element to check.
100
+ */
101
+ function isHostModal(element) {
102
+ return element?.type === getHostComponentNames().modal;
103
+ }
80
104
  //# sourceMappingURL=host-component-names.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Switch","text","getByTestId","root","type","textInput","switch","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Switch testID=\"switch\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text.\n * @param element The element to check.\n */\nexport function isHostText(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput.\n * @param element The element to check.\n */\nexport function isHostTextInput(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAA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,CAAE,0CAAyCZ,MAAO,EAAC,CAAC;EACrE;EAEA,OAAOc,KAAK,CAAC,CAAC,CAAC;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CACxBC,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEd,IAAI,KAAKlB,qBAAqB,CAAC,CAAC,CAACe,IAAI;AACvD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,eAAeA,CAC7BD,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEd,IAAI,KAAKlB,qBAAqB,CAAC,CAAC,CAACmB,SAAS;AAC5D"}
1
+ {"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","prototype","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Modal, ScrollView, Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Switch testID=\"switch\" />\n <ScrollView testID=\"scrollView\" />\n <Modal testID=\"modal\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n scrollView: getByTestId(renderer.root, 'scrollView').type as string,\n modal: getByTestId(renderer.root, 'modal').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text.\n * @param element The element to check.\n */\nexport function isHostText(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput.\n * @param element The element to check.\n */\nexport function isHostTextInput(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host ScrollView.\n * @param element The element to check.\n */\nexport function isHostScrollView(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal.\n * @param element The element to check.\n */\nexport function isHostModal(\n element?: ReactTestIn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ACiB,IAAI;AACvD;;AAEA;AACA;AACA;AACA;AACO,SAASoB,eAAeA,CAC7BD,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEhB,IAAI,KAAKpB,qBAAqB,CAAC,CAAC,CAACqB,SAAS;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAASiB,gBAAgBA,CAC9BF,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEhB,IAAI,KAAKpB,qBAAqB,CAAC,CAAC,CAACuB,UAAU;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASgB,WAAWA,CACzBH,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEhB,IAAI,KAAKpB,qBAAqB,CAAC,CAAC,CAACwB,KAAK;AACxD"}
@@ -23,10 +23,10 @@ const defaultState = {
23
23
  expanded: undefined
24
24
  };
25
25
  function matchAccessibilityState(node, matcher) {
26
- const state = node.props.accessibilityState;
27
- return _accessiblity.accessibilityStateKeys.every(key => matchState(state, matcher, key));
26
+ const state = (0, _accessiblity.getAccessibilityState)(node);
27
+ return _accessiblity.accessibilityStateKeys.every(key => matchState(matcher, state, key));
28
28
  }
29
- function matchState(state, matcher, key) {
29
+ function matchState(matcher, state, key) {
30
30
  return matcher[key] === undefined || matcher[key] === (state?.[key] ?? defaultState[key]);
31
31
  }
32
32
  //# sourceMappingURL=accessibilityState.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibilityState.js","names":["_accessiblity","require","defaultState","disabled","selected","checked","undefined","busy","expanded","matchAccessibilityState","node","matcher","state","props","accessibilityState","accessibilityStateKeys","every","key","matchState"],"sources":["../../../src/helpers/matchers/accessibilityState.ts"],"sourcesContent":["import { AccessibilityState } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { accessibilityStateKeys } from '../accessiblity';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\n/**\n * Default accessibility state values based on experiments using accessibility\n * inspector/screen reader on iOS and Android.\n *\n * @see https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State\n */\nconst defaultState: AccessibilityState = {\n disabled: false,\n selected: false,\n checked: undefined,\n busy: false,\n expanded: undefined,\n};\n\nexport function matchAccessibilityState(\n node: ReactTestInstance,\n matcher: AccessibilityStateMatcher\n) {\n const state = node.props.accessibilityState;\n return accessibilityStateKeys.every((key) => matchState(state, matcher, key));\n}\n\nfunction matchState(\n state: AccessibilityState,\n matcher: AccessibilityStateMatcher,\n key: keyof AccessibilityState\n) {\n return (\n matcher[key] === undefined ||\n matcher[key] === (state?.[key] ?? defaultState[key])\n );\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAgC,GAAG;EACvCC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,KAAK;EACXC,QAAQ,EAAEF;AACZ,CAAC;AAEM,SAASG,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EAClC;EACA,MAAMC,KAAK,GAAGF,IAAI,CAACG,KAAK,CAACC,kBAAkB;EAC3C,OAAOC,oCAAsB,CAACC,KAAK,CAAEC,GAAG,IAAKC,UAAU,CAACN,KAAK,EAAED,OAAO,EAAEM,GAAG,CAAC,CAAC;AAC/E;AAEA,SAASC,UAAUA,CACjBN,KAAyB,EACzBD,OAAkC,EAClCM,GAA6B,EAC7B;EACA,OACEN,OAAO,CAACM,GAAG,CAAC,KAAKX,SAAS,IAC1BK,OAAO,CAACM,GAAG,CAAC,MAAML,KAAK,GAAGK,GAAG,CAAC,IAAIf,YAAY,CAACe,GAAG,CAAC,CAAC;AAExD"}
1
+ {"version":3,"file":"accessibilityState.js","names":["_accessiblity","require","defaultState","disabled","selected","checked","undefined","busy","expanded","matchAccessibilityState","node","matcher","state","getAccessibilityState","accessibilityStateKeys","every","key","matchState"],"sources":["../../../src/helpers/matchers/accessibilityState.ts"],"sourcesContent":["import { AccessibilityState } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { accessibilityStateKeys, getAccessibilityState } from '../accessiblity';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\n/**\n * Default accessibility state values based on experiments using accessibility\n * inspector/screen reader on iOS and Android.\n *\n * @see https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State\n */\nconst defaultState: AccessibilityState = {\n disabled: false,\n selected: false,\n checked: undefined,\n busy: false,\n expanded: undefined,\n};\n\nexport function matchAccessibilityState(\n node: ReactTestInstance,\n matcher: AccessibilityStateMatcher\n) {\n const state = getAccessibilityState(node);\n return accessibilityStateKeys.every((key) => matchState(matcher, state, key));\n}\n\nfunction matchState(\n matcher: AccessibilityStateMatcher,\n state: AccessibilityState | undefined,\n key: keyof AccessibilityState\n) {\n return (\n matcher[key] === undefined ||\n matcher[key] === (state?.[key] ?? defaultState[key])\n );\n}\n"],"mappings":";;;;;;AAEA,IAAAA,aAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AASA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,YAAgC,GAAG;EACvCC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,OAAO,EAAEC,SAAS;EAClBC,IAAI,EAAE,KAAK;EACXC,QAAQ,EAAEF;AACZ,CAAC;AAEM,SAASG,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EAClC;EACA,MAAMC,KAAK,GAAG,IAAAC,mCAAqB,EAACH,IAAI,CAAC;EACzC,OAAOI,oCAAsB,CAACC,KAAK,CAAEC,GAAG,IAAKC,UAAU,CAACN,OAAO,EAAEC,KAAK,EAAEI,GAAG,CAAC,CAAC;AAC/E;AAEA,SAASC,UAAUA,CACjBN,OAAkC,EAClCC,KAAqC,EACrCI,GAA6B,EAC7B;EACA,OACEL,OAAO,CAACK,GAAG,CAAC,KAAKV,SAAS,IAC1BK,OAAO,CAACK,GAAG,CAAC,MAAMJ,KAAK,GAAGI,GAAG,CAAC,IAAId,YAAY,CAACc,GAAG,CAAC,CAAC;AAExD"}
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.matchAccessibilityValue = matchAccessibilityValue;
7
+ var _accessiblity = require("../accessiblity");
7
8
  var _matchStringProp = require("./matchStringProp");
8
9
  function matchAccessibilityValue(node, matcher) {
9
- const value = node.props.accessibilityValue ?? {};
10
- return (matcher.min === undefined || matcher.min === value.min) && (matcher.max === undefined || matcher.max === value.max) && (matcher.now === undefined || matcher.now === value.now) && (matcher.text === undefined || (0, _matchStringProp.matchStringProp)(value.text, matcher.text));
10
+ const value = (0, _accessiblity.getAccessibilityValue)(node);
11
+ return (matcher.min === undefined || matcher.min === value?.min) && (matcher.max === undefined || matcher.max === value?.max) && (matcher.now === undefined || matcher.now === value?.now) && (matcher.text === undefined || (0, _matchStringProp.matchStringProp)(value?.text, matcher.text));
11
12
  }
12
13
  //# sourceMappingURL=accessibilityValue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibilityValue.js","names":["_matchStringProp","require","matchAccessibilityValue","node","matcher","value","props","accessibilityValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/accessibilityValue.ts"],"sourcesContent":["import { AccessibilityValue } from 'react-native';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { TextMatch } from '../../matches';\nimport { matchStringProp } from './matchStringProp';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: ReactTestInstance,\n matcher: AccessibilityValueMatcher\n): boolean {\n const value: AccessibilityValue = node.props.accessibilityValue ?? {};\n return (\n (matcher.min === undefined || matcher.min === value.min) &&\n (matcher.max === undefined || matcher.max === value.max) &&\n (matcher.now === undefined || matcher.now === value.now) &&\n (matcher.text === undefined || matchStringProp(value.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AAGA,IAAAA,gBAAA,GAAAC,OAAA;AASO,SAASC,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EACzB;EACT,MAAMC,KAAyB,GAAGF,IAAI,CAACG,KAAK,CAACC,kBAAkB,IAAI,CAAC,CAAC;EACrE,OACE,CAACH,OAAO,CAACI,GAAG,KAAKC,SAAS,IAAIL,OAAO,CAACI,GAAG,KAAKH,KAAK,CAACG,GAAG,MACtDJ,OAAO,CAACM,GAAG,KAAKD,SAAS,IAAIL,OAAO,CAACM,GAAG,KAAKL,KAAK,CAACK,GAAG,CAAC,KACvDN,OAAO,CAACO,GAAG,KAAKF,SAAS,IAAIL,OAAO,CAACO,GAAG,KAAKN,KAAK,CAACM,GAAG,CAAC,KACvDP,OAAO,CAACQ,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACR,KAAK,CAACO,IAAI,EAAER,OAAO,CAACQ,IAAI,CAAC,CAAC;AAE7E"}
1
+ {"version":3,"file":"accessibilityValue.js","names":["_accessiblity","require","_matchStringProp","matchAccessibilityValue","node","matcher","value","getAccessibilityValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/accessibilityValue.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getAccessibilityValue } from '../accessiblity';\nimport { TextMatch } from '../../matches';\nimport { matchStringProp } from './matchStringProp';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: ReactTestInstance,\n matcher: AccessibilityValueMatcher\n): boolean {\n const value = getAccessibilityValue(node);\n return (\n (matcher.min === undefined || matcher.min === value?.min) &&\n (matcher.max === undefined || matcher.max === value?.max) &&\n (matcher.now === undefined || matcher.now === value?.now) &&\n (matcher.text === undefined || matchStringProp(value?.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AASO,SAASE,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EACzB;EACT,MAAMC,KAAK,GAAG,IAAAC,mCAAqB,EAACH,IAAI,CAAC;EACzC,OACE,CAACC,OAAO,CAACG,GAAG,KAAKC,SAAS,IAAIJ,OAAO,CAACG,GAAG,KAAKF,KAAK,EAAEE,GAAG,MACvDH,OAAO,CAACK,GAAG,KAAKD,SAAS,IAAIJ,OAAO,CAACK,GAAG,KAAKJ,KAAK,EAAEI,GAAG,CAAC,KACxDL,OAAO,CAACM,GAAG,KAAKF,SAAS,IAAIJ,OAAO,CAACM,GAAG,KAAKL,KAAK,EAAEK,GAAG,CAAC,KACxDN,OAAO,CAACO,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACP,KAAK,EAAEM,IAAI,EAAEP,OAAO,CAACO,IAAI,CAAC,CAAC;AAE9E"}
@@ -1,3 +1,3 @@
1
1
  import { ReactTestInstance } from 'react-test-renderer';
2
2
  import { TextMatch, TextMatchOptions } from '../../matches';
3
- export declare function matchLabelText(root: ReactTestInstance, element: ReactTestInstance, text: TextMatch, options?: TextMatchOptions): boolean;
3
+ export declare function matchLabelText(root: ReactTestInstance, element: ReactTestInstance, expectedText: TextMatch, options?: TextMatchOptions): boolean;
@@ -5,17 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.matchLabelText = matchLabelText;
7
7
  var _matches = require("../../matches");
8
+ var _accessiblity = require("../accessiblity");
8
9
  var _findAll = require("../findAll");
9
10
  var _matchTextContent = require("./matchTextContent");
10
- function matchLabelText(root, element, text, options = {}) {
11
- return matchAccessibilityLabel(element, text, options) || matchAccessibilityLabelledBy(root, element.props.accessibilityLabelledBy, text, options);
11
+ function matchLabelText(root, element, expectedText, options = {}) {
12
+ return matchAccessibilityLabel(element, expectedText, options) || matchAccessibilityLabelledBy(root, (0, _accessiblity.getAccessibilityLabelledBy)(element), expectedText, options);
12
13
  }
13
- function matchAccessibilityLabel(element, text, options) {
14
- const {
15
- exact,
16
- normalizer
17
- } = options;
18
- return (0, _matches.matches)(text, element.props.accessibilityLabel, normalizer, exact);
14
+ function matchAccessibilityLabel(element, extpectedLabel, options) {
15
+ return (0, _matches.matches)(extpectedLabel, (0, _accessiblity.getAccessibilityLabel)(element), options.normalizer, options.exact);
19
16
  }
20
17
  function matchAccessibilityLabelledBy(root, nativeId, text, options) {
21
18
  if (!nativeId) {
@@ -1 +1 @@
1
- {"version":3,"file":"matchLabelText.js","names":["_matches","require","_findAll","_matchTextContent","matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, text, options) ||\n matchAccessibilityLabelledBy(\n root,\n element.props.accessibilityLabelledBy,\n text,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions\n) {\n const { exact, normalizer } = options;\n return matches(text, element.props.accessibilityLabel, normalizer, exact);\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,SAASG,cAAcA,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC,IAC/CE,4BAA4B,CAC1BL,IAAI,EACJC,OAAO,CAACK,KAAK,CAACC,uBAAuB,EACrCL,IAAI,EACJC,OACF,CAAC;AAEL;AAEA,SAASC,uBAAuBA,CAC9BH,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,EACzB;EACA,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGN,OAAO;EACrC,OAAO,IAAAO,gBAAO,EAACR,IAAI,EAAED,OAAO,CAACK,KAAK,CAACK,kBAAkB,EAAEF,UAAU,EAAED,KAAK,CAAC;AAC3E;AAEA,SAASH,4BAA4BA,CACnCL,IAAuB,EACvBY,QAA4B,EAC5BV,IAAe,EACfC,OAAyB,EACzB;EACA,IAAI,CAACS,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EAEA,OACE,IAAAC,gBAAO,EACLb,IAAI,EACHc,IAAI,IACHA,IAAI,CAACR,KAAK,CAACS,QAAQ,KAAKH,QAAQ,IAChC,IAAAI,kCAAgB,EAACF,IAAI,EAAEZ,IAAI,EAAEC,OAAO,CACxC,CAAC,CAACc,MAAM,GAAG,CAAC;AAEhB"}
1
+ {"version":3,"file":"matchLabelText.js","names":["_matches","require","_accessiblity","_findAll","_matchTextContent","matchLabelText","root","element","expectedText","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","getAccessibilityLabelledBy","extpectedLabel","matches","getAccessibilityLabel","normalizer","exact","nativeId","text","findAll","node","props","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport {\n getAccessibilityLabel,\n getAccessibilityLabelledBy,\n} from '../accessiblity';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n expectedText: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, expectedText, options) ||\n matchAccessibilityLabelledBy(\n root,\n getAccessibilityLabelledBy(element),\n expectedText,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n extpectedLabel: TextMatch,\n options: TextMatchOptions\n) {\n return matches(\n extpectedLabel,\n getAccessibilityLabel(element),\n options.normalizer,\n options.exact\n );\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAIA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEO,SAASI,cAAcA,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,YAAuB,EACvBC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,YAAY,EAAEC,OAAO,CAAC,IACvDE,4BAA4B,CAC1BL,IAAI,EACJ,IAAAM,wCAA0B,EAACL,OAAO,CAAC,EACnCC,YAAY,EACZC,OACF,CAAC;AAEL;AAEA,SAASC,uBAAuBA,CAC9BH,OAA0B,EAC1BM,cAAyB,EACzBJ,OAAyB,EACzB;EACA,OAAO,IAAAK,gBAAO,EACZD,cAAc,EACd,IAAAE,mCAAqB,EAACR,OAAO,CAAC,EAC9BE,OAAO,CAACO,UAAU,EAClBP,OAAO,CAACQ,KACV,CAAC;AACH;AAEA,SAASN,4BAA4BA,CACnCL,IAAuB,EACvBY,QAA4B,EAC5BC,IAAe,EACfV,OAAyB,EACzB;EACA,IAAI,CAACS,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EAEA,OACE,IAAAE,gBAAO,EACLd,IAAI,EACHe,IAAI,IACHA,IAAI,CAACC,KAAK,CAACC,QAAQ,KAAKL,QAAQ,IAChC,IAAAM,kCAAgB,EAACH,IAAI,EAAEF,IAAI,EAAEV,OAAO,CACxC,CAAC,CAACgB,MAAM,GAAG,CAAC;AAEhB"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.matchTextContent = matchTextContent;
7
7
  var _matches = require("../../matches");
8
- var _getTextContent = require("../getTextContent");
8
+ var _textContent = require("../text-content");
9
9
  /**
10
10
  * Matches the given node's text content against string or regex matcher.
11
11
  *
@@ -14,7 +14,7 @@ var _getTextContent = require("../getTextContent");
14
14
  * @returns - Whether the node's text content matches the given string or regex.
15
15
  */
16
16
  function matchTextContent(node, text, options = {}) {
17
- const textContent = (0, _getTextContent.getTextContent)(node);
17
+ const textContent = (0, _textContent.getTextContent)(node);
18
18
  const {
19
19
  exact,
20
20
  normalizer
@@ -1 +1 @@
1
- {"version":3,"file":"matchTextContent.js","names":["_matches","require","_getTextContent","matchTextContent","node","text","options","textContent","getTextContent","exact","normalizer","matches"],"sources":["../../../src/helpers/matchers/matchTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { getTextContent } from '../getTextContent';\n\n/**\n * Matches the given node's text content against string or regex matcher.\n *\n * @param node - Node which text content will be matched\n * @param text - The string or regex to match.\n * @returns - Whether the node's text content matches the given string or regex.\n */\nexport function matchTextContent(\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n const textContent = getTextContent(node);\n const { exact, normalizer } = options;\n return matches(text, textContent, normalizer, exact);\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,MAAMC,WAAW,GAAG,IAAAC,8BAAc,EAACJ,IAAI,CAAC;EACxC,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGJ,OAAO;EACrC,OAAO,IAAAK,gBAAO,EAACN,IAAI,EAAEE,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACtD"}
1
+ {"version":3,"file":"matchTextContent.js","names":["_matches","require","_textContent","matchTextContent","node","text","options","textContent","getTextContent","exact","normalizer","matches"],"sources":["../../../src/helpers/matchers/matchTextContent.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { getTextContent } from '../text-content';\n\n/**\n * Matches the given node's text content against string or regex matcher.\n *\n * @param node - Node which text content will be matched\n * @param text - The string or regex to match.\n * @returns - Whether the node's text content matches the given string or regex.\n */\nexport function matchTextContent(\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n const textContent = getTextContent(node);\n const { exact, normalizer } = options;\n return matches(text, textContent, normalizer, exact);\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC9BC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,MAAMC,WAAW,GAAG,IAAAC,2BAAc,EAACJ,IAAI,CAAC;EACxC,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGJ,OAAO;EACrC,OAAO,IAAAK,gBAAO,EAACN,IAAI,EAAEE,WAAW,EAAEG,UAAU,EAAED,KAAK,CAAC;AACtD"}
@@ -0,0 +1 @@
1
+ export declare function pick<T extends {}>(object: T, keys: (keyof T)[]): Partial<T>;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pick = pick;
7
+ function pick(object, keys) {
8
+ const result = {};
9
+ keys.forEach(key => {
10
+ if (object[key] !== undefined) {
11
+ result[key] = object[key];
12
+ }
13
+ });
14
+ return result;
15
+ }
16
+ //# sourceMappingURL=object.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object.js","names":["pick","object","keys","result","forEach","key","undefined"],"sources":["../../src/helpers/object.ts"],"sourcesContent":["export function pick<T extends {}>(object: T, keys: (keyof T)[]): Partial<T> {\n const result: Partial<T> = {};\n keys.forEach((key) => {\n if (object[key] !== undefined) {\n result[key] = object[key];\n }\n });\n\n return result;\n}\n"],"mappings":";;;;;;AAAO,SAASA,IAAIA,CAAeC,MAAS,EAAEC,IAAiB,EAAc;EAC3E,MAAMC,MAAkB,GAAG,CAAC,CAAC;EAC7BD,IAAI,CAACE,OAAO,CAAEC,GAAG,IAAK;IACpB,IAAIJ,MAAM,CAACI,GAAG,CAAC,KAAKC,SAAS,EAAE;MAC7BH,MAAM,CAACE,GAAG,CAAC,GAAGJ,MAAM,CAACI,GAAG,CAAC;IAC3B;EACF,CAAC,CAAC;EAEF,OAAOF,MAAM;AACf"}
@@ -17,4 +17,4 @@ function getTextContent(element) {
17
17
  });
18
18
  return result.join('');
19
19
  }
20
- //# sourceMappingURL=getTextContent.js.map
20
+ //# sourceMappingURL=text-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-content.js","names":["getTextContent","element","result","children","forEach","child","push","join"],"sources":["../../src/helpers/text-content.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\n\nexport function getTextContent(\n element: ReactTestInstance | string | null\n): string {\n if (!element) {\n return '';\n }\n\n if (typeof element === 'string') {\n return element;\n }\n\n const result: string[] = [];\n element.children?.forEach((child) => {\n result.push(getTextContent(child));\n });\n\n return result.join('');\n}\n"],"mappings":";;;;;;AAEO,SAASA,cAAcA,CAC5BC,OAA0C,EAClC;EACR,IAAI,CAACA,OAAO,EAAE;IACZ,OAAO,EAAE;EACX;EAEA,IAAI,OAAOA,OAAO,KAAK,QAAQ,EAAE;IAC/B,OAAOA,OAAO;EAChB;EAEA,MAAMC,MAAgB,GAAG,EAAE;EAC3BD,OAAO,CAACE,QAAQ,EAAEC,OAAO,CAAEC,KAAK,IAAK;IACnCH,MAAM,CAACI,IAAI,CAACN,cAAc,CAACK,KAAK,CAAC,CAAC;EACpC,CAAC,CAAC;EAEF,OAAOH,MAAM,CAACK,IAAI,CAAC,EAAE,CAAC;AACxB"}
@@ -0,0 +1,3 @@
1
+ import { ReactTestInstance } from 'react-test-renderer';
2
+ export declare function isTextInputEditable(element: ReactTestInstance): boolean;
3
+ export declare function getTextInputValue(element: ReactTestInstance): any;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTextInputValue = getTextInputValue;
7
+ exports.isTextInputEditable = isTextInputEditable;
8
+ var _hostComponentNames = require("./host-component-names");
9
+ function isTextInputEditable(element) {
10
+ if (!(0, _hostComponentNames.isHostTextInput)(element)) {
11
+ throw new Error(`Element is not a "TextInput", but it has type "${element.type}".`);
12
+ }
13
+ return element.props.editable !== false;
14
+ }
15
+ function getTextInputValue(element) {
16
+ if (!(0, _hostComponentNames.isHostTextInput)(element)) {
17
+ throw new Error(`Element is not a "TextInput", but it has type "${element.type}".`);
18
+ }
19
+ return element.props.value ?? element.props.defaultValue;
20
+ }
21
+ //# sourceMappingURL=text-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-input.js","names":["_hostComponentNames","require","isTextInputEditable","element","isHostTextInput","Error","type","props","editable","getTextInputValue","value","defaultValue"],"sources":["../../src/helpers/text-input.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from './host-component-names';\n\nexport function isTextInputEditable(element: ReactTestInstance) {\n if (!isHostTextInput(element)) {\n throw new Error(\n `Element is not a \"TextInput\", but it has type \"${element.type}\".`\n );\n }\n\n return element.props.editable !== false;\n}\n\nexport function getTextInputValue(element: ReactTestInstance) {\n if (!isHostTextInput(element)) {\n throw new Error(\n `Element is not a \"TextInput\", but it has type \"${element.type}\".`\n );\n }\n\n return element.props.value ?? element.props.defaultValue;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AAEO,SAASC,mBAAmBA,CAACC,OAA0B,EAAE;EAC9D,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACZ,kDAAiDF,OAAO,CAACG,IAAK,IACjE,CAAC;EACH;EAEA,OAAOH,OAAO,CAACI,KAAK,CAACC,QAAQ,KAAK,KAAK;AACzC;AAEO,SAASC,iBAAiBA,CAACN,OAA0B,EAAE;EAC5D,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,KAAK,CACZ,kDAAiDF,OAAO,CAACG,IAAK,IACjE,CAAC;EACH;EAEA,OAAOH,OAAO,CAACI,KAAK,CAACG,KAAK,IAAIP,OAAO,CAACI,KAAK,CAACI,YAAY;AAC1D"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
3
+ *
4
+ * @param callback Async callback to run
5
+ * @returns Result of the callback
6
+ */
7
+ export declare function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result>;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.wrapAsync = wrapAsync;
7
+ var _reactTestRenderer = require("react-test-renderer");
8
+ var _act = require("../act");
9
+ var _flushMicroTasks = require("../flush-micro-tasks");
10
+ var _reactVersions = require("../react-versions");
11
+ /* istanbul ignore file */
12
+
13
+ /**
14
+ * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
15
+ *
16
+ * @param callback Async callback to run
17
+ * @returns Result of the callback
18
+ */
19
+ async function wrapAsync(callback) {
20
+ if ((0, _reactVersions.checkReactVersionAtLeast)(18, 0)) {
21
+ const previousActEnvironment = (0, _act.getIsReactActEnvironment)();
22
+ (0, _act.setReactActEnvironment)(false);
23
+ try {
24
+ const result = await callback();
25
+ // Flush the microtask queue before restoring the `act` environment
26
+ await (0, _flushMicroTasks.flushMicroTasksLegacy)();
27
+ return result;
28
+ } finally {
29
+ (0, _act.setReactActEnvironment)(previousActEnvironment);
30
+ }
31
+ }
32
+ if (!(0, _reactVersions.checkReactVersionAtLeast)(16, 9)) {
33
+ return callback();
34
+ }
35
+
36
+ // Wrapping with act for react version 16.9 to 17.x
37
+ let result;
38
+ await (0, _reactTestRenderer.act)(async () => {
39
+ result = await callback();
40
+ });
41
+
42
+ // Either we have result or `callback` threw error
43
+ return result;
44
+ }
45
+ //# sourceMappingURL=wrap-async.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap-async.js","names":["_reactTestRenderer","require","_act","_flushMicroTasks","_reactVersions","wrapAsync","callback","checkReactVersionAtLeast","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasksLegacy","act"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { act } from 'react-test-renderer';\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasksLegacy } from '../flush-micro-tasks';\nimport { checkReactVersionAtLeast } from '../react-versions';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(\n callback: () => Promise<Result>\n): Promise<Result> {\n if (checkReactVersionAtLeast(18, 0)) {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasksLegacy();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n }\n\n if (!checkReactVersionAtLeast(16, 9)) {\n return callback();\n }\n\n // Wrapping with act for react version 16.9 to 17.x\n let result: Result;\n await act(async () => {\n result = await callback();\n });\n\n // Either we have result or `callback` threw error\n return result!;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AALA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeI,SAASA,CAC7BC,QAA+B,EACd;EACjB,IAAI,IAAAC,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACnC,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;IAE7B,IAAI;MACF,MAAMC,MAAM,GAAG,MAAML,QAAQ,CAAC,CAAC;MAC/B;MACA,MAAM,IAAAM,sCAAqB,EAAC,CAAC;MAC7B,OAAOD,MAAM;IACf,CAAC,SAAS;MACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;IAChD;EACF;EAEA,IAAI,CAAC,IAAAD,uCAAwB,EAAC,EAAE,EAAE,CAAC,CAAC,EAAE;IACpC,OAAOD,QAAQ,CAAC,CAAC;EACnB;;EAEA;EACA,IAAIK,MAAc;EAClB,MAAM,IAAAE,sBAAG,EAAC,YAAY;IACpBF,MAAM,GAAG,MAAML,QAAQ,CAAC,CAAC;EAC3B,CAAC,CAAC;;EAEF;EACA,OAAOK,MAAM;AACf"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=extend-expect.d.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend-expect.d.js","names":[],"sources":["../../src/matchers/extend-expect.d.ts"],"sourcesContent":["import type { StyleProp } from 'react-native';\nimport type { ReactTestInstance } from 'react-test-renderer';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type { Style } from './to-have-style';\n\nexport interface JestNativeMatchers<R> {\n toBeOnTheScreen(): R;\n toBeChecked(): R;\n toBeCollapsed(): R;\n toBeDisabled(): R;\n toBeBusy(): R;\n toBeEmptyElement(): R;\n toBeEnabled(): R;\n toBeExpanded(): R;\n toBePartiallyChecked(): R;\n toBeSelected(): R;\n toBeVisible(): R;\n toContainElement(element: ReactTestInstance | null): R;\n toHaveDisplayValue(expectedValue: TextMatch, options?: TextMatchOptions): R;\n toHaveProp(name: string, expectedValue?: unknown): R;\n toHaveStyle(style: StyleProp<Style>): R;\n toHaveTextContent(expectedText: TextMatch, options?: TextMatchOptions): R;\n}\n\n// Implicit Jest global `expect`.\ndeclare global {\n namespace jest {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n interface Matchers<R, T = {}> extends JestNativeMatchers<R> {}\n }\n}\n\n// Explicit `@jest/globals` `expect` matchers.\ndeclare module '@jest/expect' {\n interface Matchers<R extends void | Promise<void>>\n extends JestNativeMatchers<R> {}\n}\n"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ /// <reference path="../../src/matchers/extend-expect.d.ts" />
2
+ export {};
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _toBeOnTheScreen = require("./to-be-on-the-screen");
4
+ var _toBeChecked = require("./to-be-checked");
5
+ var _toBeCollapsed = require("./to-be-collapsed");
6
+ var _toBeDisabled = require("./to-be-disabled");
7
+ var _toBeBusy = require("./to-be-busy");
8
+ var _toBeEmptyElement = require("./to-be-empty-element");
9
+ var _toBeExpanded = require("./to-be-expanded");
10
+ var _toBePartiallyChecked = require("./to-be-partially-checked");
11
+ var _toBeSelected = require("./to-be-selected");
12
+ var _toBeVisible = require("./to-be-visible");
13
+ var _toContainElement = require("./to-contain-element");
14
+ var _toHaveDisplayValue = require("./to-have-display-value");
15
+ var _toHaveProp = require("./to-have-prop");
16
+ var _toHaveStyle = require("./to-have-style");
17
+ var _toHaveTextContent = require("./to-have-text-content");
18
+ /// <reference path="./extend-expect.d.ts" />
19
+
20
+ expect.extend({
21
+ toBeOnTheScreen: _toBeOnTheScreen.toBeOnTheScreen,
22
+ toBeChecked: _toBeChecked.toBeChecked,
23
+ toBeCollapsed: _toBeCollapsed.toBeCollapsed,
24
+ toBeDisabled: _toBeDisabled.toBeDisabled,
25
+ toBeBusy: _toBeBusy.toBeBusy,
26
+ toBeEmptyElement: _toBeEmptyElement.toBeEmptyElement,
27
+ toBeEnabled: _toBeDisabled.toBeEnabled,
28
+ toBeExpanded: _toBeExpanded.toBeExpanded,
29
+ toBePartiallyChecked: _toBePartiallyChecked.toBePartiallyChecked,
30
+ toBeSelected: _toBeSelected.toBeSelected,
31
+ toBeVisible: _toBeVisible.toBeVisible,
32
+ toContainElement: _toContainElement.toContainElement,
33
+ toHaveDisplayValue: _toHaveDisplayValue.toHaveDisplayValue,
34
+ toHaveProp: _toHaveProp.toHaveProp,
35
+ toHaveStyle: _toHaveStyle.toHaveStyle,
36
+ toHaveTextContent: _toHaveTextContent.toHaveTextContent
37
+ });
38
+ //# sourceMappingURL=extend-expect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extend-expect.js","names":["_toBeOnTheScreen","require","_toBeChecked","_toBeCollapsed","_toBeDisabled","_toBeBusy","_toBeEmptyElement","_toBeExpanded","_toBePartiallyChecked","_toBeSelected","_toBeVisible","_toContainElement","_toHaveDisplayValue","_toHaveProp","_toHaveStyle","_toHaveTextContent","expect","extend","toBeOnTheScreen","toBeChecked","toBeCollapsed","toBeDisabled","toBeBusy","toBeEmptyElement","toBeEnabled","toBeExpanded","toBePartiallyChecked","toBeSelected","toBeVisible","toContainElement","toHaveDisplayValue","toHaveProp","toHaveStyle","toHaveTextContent"],"sources":["../../src/matchers/extend-expect.ts"],"sourcesContent":["/// <reference path=\"./extend-expect.d.ts\" />\n\nimport { toBeOnTheScreen } from './to-be-on-the-screen';\nimport { toBeChecked } from './to-be-checked';\nimport { toBeCollapsed } from './to-be-collapsed';\nimport { toBeDisabled, toBeEnabled } from './to-be-disabled';\nimport { toBeBusy } from './to-be-busy';\nimport { toBeEmptyElement } from './to-be-empty-element';\nimport { toBeExpanded } from './to-be-expanded';\nimport { toBePartiallyChecked } from './to-be-partially-checked';\nimport { toBeSelected } from './to-be-selected';\nimport { toBeVisible } from './to-be-visible';\nimport { toContainElement } from './to-contain-element';\nimport { toHaveDisplayValue } from './to-have-display-value';\nimport { toHaveProp } from './to-have-prop';\nimport { toHaveStyle } from './to-have-style';\nimport { toHaveTextContent } from './to-have-text-content';\n\nexpect.extend({\n toBeOnTheScreen,\n toBeChecked,\n toBeCollapsed,\n toBeDisabled,\n toBeBusy,\n toBeEmptyElement,\n toBeEnabled,\n toBeExpanded,\n toBePartiallyChecked,\n toBeSelected,\n toBeVisible,\n toContainElement,\n toHaveDisplayValue,\n toHaveProp,\n toHaveStyle,\n toHaveTextContent,\n});\n"],"mappings":";;AAEA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AACA,IAAAK,iBAAA,GAAAL,OAAA;AACA,IAAAM,aAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,YAAA,GAAAb,OAAA;AACA,IAAAc,kBAAA,GAAAd,OAAA;AAhBA;;AAkBAe,MAAM,CAACC,MAAM,CAAC;EACZC,eAAe,EAAfA,gCAAe;EACfC,WAAW,EAAXA,wBAAW;EACXC,aAAa,EAAbA,4BAAa;EACbC,YAAY,EAAZA,0BAAY;EACZC,QAAQ,EAARA,kBAAQ;EACRC,gBAAgB,EAAhBA,kCAAgB;EAChBC,WAAW,EAAXA,yBAAW;EACXC,YAAY,EAAZA,0BAAY;EACZC,oBAAoB,EAApBA,0CAAoB;EACpBC,YAAY,EAAZA,0BAAY;EACZC,WAAW,EAAXA,wBAAW;EACXC,gBAAgB,EAAhBA,kCAAgB;EAChBC,kBAAkB,EAAlBA,sCAAkB;EAClBC,UAAU,EAAVA,sBAAU;EACVC,WAAW,EAAXA,wBAAW;EACXC,iBAAiB,EAAjBA;AACF,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ export { toBeBusy } from './to-be-busy';
2
+ export { toBeChecked } from './to-be-checked';
3
+ export { toBeCollapsed } from './to-be-collapsed';
4
+ export { toBeDisabled, toBeEnabled } from './to-be-disabled';
5
+ export { toBeEmptyElement } from './to-be-empty-element';
6
+ export { toBeExpanded } from './to-be-expanded';
7
+ export { toBeOnTheScreen } from './to-be-on-the-screen';
8
+ export { toBePartiallyChecked } from './to-be-partially-checked';
9
+ export { toBeSelected } from './to-be-selected';
10
+ export { toBeVisible } from './to-be-visible';
11
+ export { toContainElement } from './to-contain-element';
12
+ export { toHaveDisplayValue } from './to-have-display-value';
13
+ export { toHaveProp } from './to-have-prop';
14
+ export { toHaveStyle } from './to-have-style';
15
+ export { toHaveTextContent } from './to-have-text-content';
@@ -0,0 +1,117 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "toBeBusy", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _toBeBusy.toBeBusy;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "toBeChecked", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _toBeChecked.toBeChecked;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "toBeCollapsed", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _toBeCollapsed.toBeCollapsed;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "toBeDisabled", {
25
+ enumerable: true,
26
+ get: function () {
27
+ return _toBeDisabled.toBeDisabled;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "toBeEmptyElement", {
31
+ enumerable: true,
32
+ get: function () {
33
+ return _toBeEmptyElement.toBeEmptyElement;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "toBeEnabled", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _toBeDisabled.toBeEnabled;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "toBeExpanded", {
43
+ enumerable: true,
44
+ get: function () {
45
+ return _toBeExpanded.toBeExpanded;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "toBeOnTheScreen", {
49
+ enumerable: true,
50
+ get: function () {
51
+ return _toBeOnTheScreen.toBeOnTheScreen;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "toBePartiallyChecked", {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _toBePartiallyChecked.toBePartiallyChecked;
58
+ }
59
+ });
60
+ Object.defineProperty(exports, "toBeSelected", {
61
+ enumerable: true,
62
+ get: function () {
63
+ return _toBeSelected.toBeSelected;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "toBeVisible", {
67
+ enumerable: true,
68
+ get: function () {
69
+ return _toBeVisible.toBeVisible;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "toContainElement", {
73
+ enumerable: true,
74
+ get: function () {
75
+ return _toContainElement.toContainElement;
76
+ }
77
+ });
78
+ Object.defineProperty(exports, "toHaveDisplayValue", {
79
+ enumerable: true,
80
+ get: function () {
81
+ return _toHaveDisplayValue.toHaveDisplayValue;
82
+ }
83
+ });
84
+ Object.defineProperty(exports, "toHaveProp", {
85
+ enumerable: true,
86
+ get: function () {
87
+ return _toHaveProp.toHaveProp;
88
+ }
89
+ });
90
+ Object.defineProperty(exports, "toHaveStyle", {
91
+ enumerable: true,
92
+ get: function () {
93
+ return _toHaveStyle.toHaveStyle;
94
+ }
95
+ });
96
+ Object.defineProperty(exports, "toHaveTextContent", {
97
+ enumerable: true,
98
+ get: function () {
99
+ return _toHaveTextContent.toHaveTextContent;
100
+ }
101
+ });
102
+ var _toBeBusy = require("./to-be-busy");
103
+ var _toBeChecked = require("./to-be-checked");
104
+ var _toBeCollapsed = require("./to-be-collapsed");
105
+ var _toBeDisabled = require("./to-be-disabled");
106
+ var _toBeEmptyElement = require("./to-be-empty-element");
107
+ var _toBeExpanded = require("./to-be-expanded");
108
+ var _toBeOnTheScreen = require("./to-be-on-the-screen");
109
+ var _toBePartiallyChecked = require("./to-be-partially-checked");
110
+ var _toBeSelected = require("./to-be-selected");
111
+ var _toBeVisible = require("./to-be-visible");
112
+ var _toContainElement = require("./to-contain-element");
113
+ var _toHaveDisplayValue = require("./to-have-display-value");
114
+ var _toHaveProp = require("./to-have-prop");
115
+ var _toHaveStyle = require("./to-have-style");
116
+ var _toHaveTextContent = require("./to-have-text-content");
117
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["_toBeBusy","require","_toBeChecked","_toBeCollapsed","_toBeDisabled","_toBeEmptyElement","_toBeExpanded","_toBeOnTheScreen","_toBePartiallyChecked","_toBeSelected","_toBeVisible","_toContainElement","_toHaveDisplayValue","_toHaveProp","_toHaveStyle","_toHaveTextContent"],"sources":["../../src/matchers/index.tsx"],"sourcesContent":["export { toBeBusy } from './to-be-busy';\nexport { toBeChecked } from './to-be-checked';\nexport { toBeCollapsed } from './to-be-collapsed';\nexport { toBeDisabled, toBeEnabled } from './to-be-disabled';\nexport { toBeEmptyElement } from './to-be-empty-element';\nexport { toBeExpanded } from './to-be-expanded';\nexport { toBeOnTheScreen } from './to-be-on-the-screen';\nexport { toBePartiallyChecked } from './to-be-partially-checked';\nexport { toBeSelected } from './to-be-selected';\nexport { toBeVisible } from './to-be-visible';\nexport { toContainElement } from './to-contain-element';\nexport { toHaveDisplayValue } from './to-have-display-value';\nexport { toHaveProp } from './to-have-prop';\nexport { toHaveStyle } from './to-have-style';\nexport { toHaveTextContent } from './to-have-text-content';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,gBAAA,GAAAN,OAAA;AACA,IAAAO,qBAAA,GAAAP,OAAA;AACA,IAAAQ,aAAA,GAAAR,OAAA;AACA,IAAAS,YAAA,GAAAT,OAAA;AACA,IAAAU,iBAAA,GAAAV,OAAA;AACA,IAAAW,mBAAA,GAAAX,OAAA;AACA,IAAAY,WAAA,GAAAZ,OAAA;AACA,IAAAa,YAAA,GAAAb,OAAA;AACA,IAAAc,kBAAA,GAAAd,OAAA"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="jest" />
2
+ import { ReactTestInstance } from 'react-test-renderer';
3
+ export declare function toBeBusy(this: jest.MatcherContext, element: ReactTestInstance): {
4
+ pass: NonNullable<boolean | undefined>;
5
+ message: () => string;
6
+ };
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.toBeBusy = toBeBusy;
7
+ var _jestMatcherUtils = require("jest-matcher-utils");
8
+ var _accessiblity = require("../helpers/accessiblity");
9
+ var _utils = require("./utils");
10
+ function toBeBusy(element) {
11
+ (0, _utils.checkHostElement)(element, toBeBusy, this);
12
+ return {
13
+ pass: (0, _accessiblity.isElementBusy)(element),
14
+ message: () => {
15
+ const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeBusy`, 'element', '');
16
+ return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}busy:`, (0, _utils.formatElement)(element)].join('\n');
17
+ }
18
+ };
19
+ }
20
+ //# sourceMappingURL=to-be-busy.js.map