@testing-library/react-native 12.7.0 → 12.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cleanup.d.ts +1 -2
- package/build/cleanup.js +1 -1
- package/build/cleanup.js.map +1 -1
- package/build/config.d.ts +3 -2
- package/build/config.js.map +1 -1
- package/build/fire-event.js +31 -0
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +23 -14
- package/build/helpers/accessibility.js +104 -78
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/format-default.js +1 -1
- package/build/helpers/format-default.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +14 -4
- package/build/helpers/host-component-names.js +25 -4
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-state.js +16 -18
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.js +1 -1
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-label-text.js +3 -3
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/text-input.js +2 -1
- package/build/helpers/text-input.js.map +1 -1
- package/build/matchers/extend-expect.js +1 -2
- package/build/matchers/extend-expect.js.map +1 -1
- package/build/matchers/index.d.ts +1 -2
- package/build/matchers/index.js +1 -2
- package/build/matchers/index.js.map +1 -1
- package/build/matchers/to-be-busy.d.ts +1 -2
- package/build/matchers/to-be-busy.js +1 -1
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.d.ts +0 -1
- package/build/matchers/to-be-checked.js +7 -6
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.d.ts +1 -2
- package/build/matchers/to-be-disabled.js +4 -15
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.d.ts +0 -1
- package/build/matchers/to-be-expanded.d.ts +5 -2
- package/build/matchers/to-be-expanded.js +12 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.d.ts +0 -1
- package/build/matchers/to-be-partially-checked.d.ts +0 -1
- package/build/matchers/to-be-partially-checked.js +2 -2
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.d.ts +1 -2
- package/build/matchers/to-be-selected.js +1 -1
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.d.ts +0 -1
- package/build/matchers/to-be-visible.js +2 -6
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.d.ts +0 -1
- package/build/matchers/to-have-accessibility-value.d.ts +0 -1
- package/build/matchers/to-have-accessibility-value.js +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.d.ts +0 -1
- package/build/matchers/to-have-accessible-name.js +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.d.ts +0 -1
- package/build/matchers/to-have-prop.d.ts +0 -1
- package/build/matchers/to-have-prop.js +1 -1
- package/build/matchers/to-have-prop.js.map +1 -1
- package/build/matchers/to-have-style.d.ts +0 -1
- package/build/matchers/to-have-text-content.d.ts +0 -1
- package/build/matchers/types.d.ts +1 -1
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.d.ts +0 -1
- package/build/matchers/utils.js +1 -1
- package/build/matchers/utils.js.map +1 -1
- package/build/native-state.d.ts +12 -0
- package/build/native-state.js +17 -0
- package/build/native-state.js.map +1 -0
- package/build/queries/hint-text.js +2 -2
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/role.js +4 -3
- package/build/queries/role.js.map +1 -1
- package/build/queries/unsafe-props.js +1 -1
- package/build/queries/unsafe-props.js.map +1 -1
- package/build/queries/unsafe-type.js +1 -1
- package/build/queries/unsafe-type.js.map +1 -1
- package/build/render-act.d.ts +0 -1
- package/build/render.d.ts +16 -16
- package/build/render.js.map +1 -1
- package/build/test-utils/events.d.ts +2 -1
- package/build/test-utils/events.js +6 -2
- package/build/test-utils/events.js.map +1 -1
- package/build/types.d.ts +14 -0
- package/build/types.js.map +1 -1
- package/build/user-event/clear.js +10 -6
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/index.d.ts +2 -27
- package/build/user-event/event-builder/scroll-view.d.ts +4 -16
- package/build/user-event/event-builder/scroll-view.js +0 -4
- package/build/user-event/event-builder/scroll-view.js.map +1 -1
- package/build/user-event/event-builder/text-input.d.ts +2 -32
- package/build/user-event/event-builder/text-input.js +0 -19
- package/build/user-event/event-builder/text-input.js.map +1 -1
- package/build/user-event/index.d.ts +1 -0
- package/build/user-event/index.js +1 -0
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/paste.d.ts +3 -0
- package/build/user-event/paste.js +56 -0
- package/build/user-event/paste.js.map +1 -0
- package/build/user-event/press/press.js +0 -1
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.d.ts +3 -8
- package/build/user-event/scroll/scroll-to.js +9 -6
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/scroll/utils.d.ts +2 -2
- package/build/user-event/scroll/utils.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +13 -1
- package/build/user-event/setup/setup.js +2 -0
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.d.ts +8 -1
- package/build/user-event/type/type.js +34 -15
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/content-size.d.ts +2 -5
- package/build/user-event/utils/content-size.js +0 -1
- package/build/user-event/utils/content-size.js.map +1 -1
- package/build/user-event/utils/index.d.ts +0 -1
- package/build/user-event/utils/index.js +0 -11
- package/build/user-event/utils/index.js.map +1 -1
- package/build/wait-for-element-to-be-removed.js +1 -1
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/within.d.ts +5 -6
- package/package.json +2 -3
- package/build/matchers/to-be-collapsed.d.ts +0 -6
- package/build/matchers/to-be-collapsed.js +0 -20
- package/build/matchers/to-be-collapsed.js.map +0 -1
- package/build/user-event/scroll/state.d.ts +0 -4
- package/build/user-event/scroll/state.js +0 -18
- package/build/user-event/scroll/state.js.map +0 -1
- package/build/user-event/utils/warn-about-real-timers.d.ts +0 -1
- package/build/user-event/utils/warn-about-real-timers.js +0 -23
- package/build/user-event/utils/warn-about-real-timers.js.map +0 -1
|
@@ -5,8 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.configureHostComponentNamesIfNeeded = configureHostComponentNamesIfNeeded;
|
|
7
7
|
exports.getHostComponentNames = getHostComponentNames;
|
|
8
|
+
exports.isHostImage = isHostImage;
|
|
8
9
|
exports.isHostModal = isHostModal;
|
|
9
10
|
exports.isHostScrollView = isHostScrollView;
|
|
11
|
+
exports.isHostSwitch = isHostSwitch;
|
|
10
12
|
exports.isHostText = isHostText;
|
|
11
13
|
exports.isHostTextInput = isHostTextInput;
|
|
12
14
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -43,6 +45,8 @@ function detectHostComponentNames() {
|
|
|
43
45
|
testID: "text"
|
|
44
46
|
}, "Hello"), /*#__PURE__*/React.createElement(_reactNative.TextInput, {
|
|
45
47
|
testID: "textInput"
|
|
48
|
+
}), /*#__PURE__*/React.createElement(_reactNative.Image, {
|
|
49
|
+
testID: "image"
|
|
46
50
|
}), /*#__PURE__*/React.createElement(_reactNative.Switch, {
|
|
47
51
|
testID: "switch"
|
|
48
52
|
}), /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
|
|
@@ -53,6 +57,7 @@ function detectHostComponentNames() {
|
|
|
53
57
|
return {
|
|
54
58
|
text: getByTestId(renderer.root, 'text').type,
|
|
55
59
|
textInput: getByTestId(renderer.root, 'textInput').type,
|
|
60
|
+
image: getByTestId(renderer.root, 'image').type,
|
|
56
61
|
switch: getByTestId(renderer.root, 'switch').type,
|
|
57
62
|
scrollView: getByTestId(renderer.root, 'scrollView').type,
|
|
58
63
|
modal: getByTestId(renderer.root, 'modal').type
|
|
@@ -71,7 +76,7 @@ function getByTestId(instance, testID) {
|
|
|
71
76
|
}
|
|
72
77
|
|
|
73
78
|
/**
|
|
74
|
-
* Checks if the given element is a host Text.
|
|
79
|
+
* Checks if the given element is a host Text element.
|
|
75
80
|
* @param element The element to check.
|
|
76
81
|
*/
|
|
77
82
|
function isHostText(element) {
|
|
@@ -79,7 +84,7 @@ function isHostText(element) {
|
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
/**
|
|
82
|
-
* Checks if the given element is a host TextInput.
|
|
87
|
+
* Checks if the given element is a host TextInput element.
|
|
83
88
|
* @param element The element to check.
|
|
84
89
|
*/
|
|
85
90
|
function isHostTextInput(element) {
|
|
@@ -87,7 +92,23 @@ function isHostTextInput(element) {
|
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
/**
|
|
90
|
-
* Checks if the given element is a host
|
|
95
|
+
* Checks if the given element is a host Image element.
|
|
96
|
+
* @param element The element to check.
|
|
97
|
+
*/
|
|
98
|
+
function isHostImage(element) {
|
|
99
|
+
return element?.type === getHostComponentNames().image;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Checks if the given element is a host Switch element.
|
|
104
|
+
* @param element The element to check.
|
|
105
|
+
*/
|
|
106
|
+
function isHostSwitch(element) {
|
|
107
|
+
return element?.type === getHostComponentNames().switch;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Checks if the given element is a host ScrollView element.
|
|
91
112
|
* @param element The element to check.
|
|
92
113
|
*/
|
|
93
114
|
function isHostScrollView(element) {
|
|
@@ -95,7 +116,7 @@ function isHostScrollView(element) {
|
|
|
95
116
|
}
|
|
96
117
|
|
|
97
118
|
/**
|
|
98
|
-
* Checks if the given element is a host Modal.
|
|
119
|
+
* Checks if the given element is a host Modal element.
|
|
99
120
|
* @param element The element to check.
|
|
100
121
|
*/
|
|
101
122
|
function isHostModal(element) {
|
|
@@ -1 +1 @@
|
|
|
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","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 ? error.message : 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(element?: ReactTestInstance | null): 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(element?: ReactTestInstance | null): 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(element?: ReactTestInstance | null): 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(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().modal;\n}\n"],"mappings":"
|
|
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","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Image","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","image","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Image, 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 <Image testID=\"image\" />\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 image: getByTestId(renderer.root, 'image').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 ? error.message : 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 element.\n * @param element The element to check.\n */\nexport function isHostText(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().image;\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().switch;\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().modal;\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,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CA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OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACuB,KAAK;AACxD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,YAAYA,CAACH,OAAkC,EAA+B;EAC5F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACwB,MAAM;AACzD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,gBAAgBA,CAACJ,OAAkC,EAA+B;EAChG,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACyB,UAAU;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACL,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAAC0B,KAAK;AACxD","ignoreList":[]}
|
|
@@ -10,24 +10,22 @@ var _accessibility = require("../accessibility");
|
|
|
10
10
|
// built in `react-native` types.
|
|
11
11
|
// See: https://github.com/callstack/react-native-testing-library/issues/1351
|
|
12
12
|
|
|
13
|
-
/**
|
|
14
|
-
* Default accessibility state values based on experiments using accessibility
|
|
15
|
-
* inspector/screen reader on iOS and Android.
|
|
16
|
-
*
|
|
17
|
-
* @see https://github.com/callstack/react-native-testing-library/wiki/Accessibility:-State
|
|
18
|
-
*/
|
|
19
|
-
const defaultState = {
|
|
20
|
-
disabled: false,
|
|
21
|
-
selected: false,
|
|
22
|
-
checked: undefined,
|
|
23
|
-
busy: false,
|
|
24
|
-
expanded: undefined
|
|
25
|
-
};
|
|
26
13
|
function matchAccessibilityState(node, matcher) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
14
|
+
if (matcher.busy !== undefined && matcher.busy !== (0, _accessibility.computeAriaBusy)(node)) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (matcher.checked !== undefined && matcher.checked !== (0, _accessibility.computeAriaChecked)(node)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
if (matcher.disabled !== undefined && matcher.disabled !== (0, _accessibility.computeAriaDisabled)(node)) {
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
if (matcher.expanded !== undefined && matcher.expanded !== (0, _accessibility.computeAriaExpanded)(node)) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
if (matcher.selected !== undefined && matcher.selected !== (0, _accessibility.computeAriaSelected)(node)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
32
30
|
}
|
|
33
31
|
//# sourceMappingURL=match-accessibility-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","
|
|
1
|
+
{"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","matchAccessibilityState","node","matcher","busy","undefined","computeAriaBusy","checked","computeAriaChecked","disabled","computeAriaDisabled","expanded","computeAriaExpanded","selected","computeAriaSelected"],"sources":["../../../src/helpers/matchers/match-accessibility-state.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport {\n computeAriaBusy,\n computeAriaChecked,\n computeAriaDisabled,\n computeAriaExpanded,\n computeAriaSelected,\n} from '../accessibility';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\nexport function matchAccessibilityState(\n node: ReactTestInstance,\n matcher: AccessibilityStateMatcher,\n) {\n if (matcher.busy !== undefined && matcher.busy !== computeAriaBusy(node)) {\n return false;\n }\n if (matcher.checked !== undefined && matcher.checked !== computeAriaChecked(node)) {\n return false;\n }\n if (matcher.disabled !== undefined && matcher.disabled !== computeAriaDisabled(node)) {\n return false;\n }\n if (matcher.expanded !== undefined && matcher.expanded !== computeAriaExpanded(node)) {\n return false;\n }\n if (matcher.selected !== undefined && matcher.selected !== computeAriaSelected(node)) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA;;AASO,SAASC,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EAClC;EACA,IAAIA,OAAO,CAACC,IAAI,KAAKC,SAAS,IAAIF,OAAO,CAACC,IAAI,KAAK,IAAAE,8BAAe,EAACJ,IAAI,CAAC,EAAE;IACxE,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACI,OAAO,KAAKF,SAAS,IAAIF,OAAO,CAACI,OAAO,KAAK,IAAAC,iCAAkB,EAACN,IAAI,CAAC,EAAE;IACjF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACM,QAAQ,KAAKJ,SAAS,IAAIF,OAAO,CAACM,QAAQ,KAAK,IAAAC,kCAAmB,EAACR,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACQ,QAAQ,KAAKN,SAAS,IAAIF,OAAO,CAACQ,QAAQ,KAAK,IAAAC,kCAAmB,EAACV,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACU,QAAQ,KAAKR,SAAS,IAAIF,OAAO,CAACU,QAAQ,KAAK,IAAAC,kCAAmB,EAACZ,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|
|
@@ -7,7 +7,7 @@ exports.matchAccessibilityValue = matchAccessibilityValue;
|
|
|
7
7
|
var _accessibility = require("../accessibility");
|
|
8
8
|
var _matchStringProp = require("./match-string-prop");
|
|
9
9
|
function matchAccessibilityValue(node, matcher) {
|
|
10
|
-
const value = (0, _accessibility.
|
|
10
|
+
const value = (0, _accessibility.computeAriaValue)(node);
|
|
11
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));
|
|
12
12
|
}
|
|
13
13
|
//# sourceMappingURL=match-accessibility-value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-accessibility-value.js","names":["_accessibility","require","_matchStringProp","matchAccessibilityValue","node","matcher","value","
|
|
1
|
+
{"version":3,"file":"match-accessibility-value.js","names":["_accessibility","require","_matchStringProp","matchAccessibilityValue","node","matcher","value","computeAriaValue","min","undefined","max","now","text","matchStringProp"],"sources":["../../../src/helpers/matchers/match-accessibility-value.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { computeAriaValue } from '../accessibility';\nimport { TextMatch } from '../../matches';\nimport { matchStringProp } from './match-string-prop';\n\nexport interface AccessibilityValueMatcher {\n min?: number;\n max?: number;\n now?: number;\n text?: TextMatch;\n}\n\nexport function matchAccessibilityValue(\n node: ReactTestInstance,\n matcher: AccessibilityValueMatcher,\n): boolean {\n const value = computeAriaValue(node);\n return (\n (matcher.min === undefined || matcher.min === value?.min) &&\n (matcher.max === undefined || matcher.max === value?.max) &&\n (matcher.now === undefined || matcher.now === value?.now) &&\n (matcher.text === undefined || matchStringProp(value?.text, matcher.text))\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AASO,SAASE,uBAAuBA,CACrCC,IAAuB,EACvBC,OAAkC,EACzB;EACT,MAAMC,KAAK,GAAG,IAAAC,+BAAgB,EAACH,IAAI,CAAC;EACpC,OACE,CAACC,OAAO,CAACG,GAAG,KAAKC,SAAS,IAAIJ,OAAO,CAACG,GAAG,KAAKF,KAAK,EAAEE,GAAG,MACvDH,OAAO,CAACK,GAAG,KAAKD,SAAS,IAAIJ,OAAO,CAACK,GAAG,KAAKJ,KAAK,EAAEI,GAAG,CAAC,KACxDL,OAAO,CAACM,GAAG,KAAKF,SAAS,IAAIJ,OAAO,CAACM,GAAG,KAAKL,KAAK,EAAEK,GAAG,CAAC,KACxDN,OAAO,CAACO,IAAI,KAAKH,SAAS,IAAI,IAAAI,gCAAe,EAACP,KAAK,EAAEM,IAAI,EAAEP,OAAO,CAACO,IAAI,CAAC,CAAC;AAE9E","ignoreList":[]}
|
|
@@ -9,10 +9,10 @@ var _accessibility = require("../accessibility");
|
|
|
9
9
|
var _findAll = require("../find-all");
|
|
10
10
|
var _matchTextContent = require("./match-text-content");
|
|
11
11
|
function matchLabelText(root, element, expectedText, options = {}) {
|
|
12
|
-
return matchAccessibilityLabel(element, expectedText, options) || matchAccessibilityLabelledBy(root, (0, _accessibility.
|
|
12
|
+
return matchAccessibilityLabel(element, expectedText, options) || matchAccessibilityLabelledBy(root, (0, _accessibility.computeAriaLabelledBy)(element), expectedText, options);
|
|
13
13
|
}
|
|
14
|
-
function matchAccessibilityLabel(element,
|
|
15
|
-
return (0, _matches.matches)(
|
|
14
|
+
function matchAccessibilityLabel(element, expectedLabel, options) {
|
|
15
|
+
return (0, _matches.matches)(expectedLabel, (0, _accessibility.computeAriaLabel)(element), options.normalizer, options.exact);
|
|
16
16
|
}
|
|
17
17
|
function matchAccessibilityLabelledBy(root, nativeId, text, options) {
|
|
18
18
|
if (!nativeId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","_findAll","_matchTextContent","matchLabelText","root","element","expectedText","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","
|
|
1
|
+
{"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","_findAll","_matchTextContent","matchLabelText","root","element","expectedText","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","computeAriaLabelledBy","expectedLabel","matches","computeAriaLabel","normalizer","exact","nativeId","text","findAll","node","props","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/match-label-text.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { computeAriaLabel, computeAriaLabelledBy } from '../accessibility';\nimport { findAll } from '../find-all';\nimport { matchTextContent } from './match-text-content';\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(root, computeAriaLabelledBy(element), expectedText, options)\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n expectedLabel: TextMatch,\n options: TextMatchOptions,\n) {\n return matches(expectedLabel, computeAriaLabel(element), options.normalizer, options.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) => node.props.nativeID === nativeId && matchTextContent(node, text, options),\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,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,CAACL,IAAI,EAAE,IAAAM,oCAAqB,EAACL,OAAO,CAAC,EAAEC,YAAY,EAAEC,OAAO,CAAC;AAE7F;AAEA,SAASC,uBAAuBA,CAC9BH,OAA0B,EAC1BM,aAAwB,EACxBJ,OAAyB,EACzB;EACA,OAAO,IAAAK,gBAAO,EAACD,aAAa,EAAE,IAAAE,+BAAgB,EAACR,OAAO,CAAC,EAAEE,OAAO,CAACO,UAAU,EAAEP,OAAO,CAACQ,KAAK,CAAC;AAC7F;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,IAAKA,IAAI,CAACC,KAAK,CAACC,QAAQ,KAAKL,QAAQ,IAAI,IAAAM,kCAAgB,EAACH,IAAI,EAAEF,IAAI,EAAEV,OAAO,CACpF,CAAC,CAACgB,MAAM,GAAG,CAAC;AAEhB","ignoreList":[]}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getTextInputValue = getTextInputValue;
|
|
7
7
|
exports.isTextInputEditable = isTextInputEditable;
|
|
8
|
+
var _nativeState = require("../native-state");
|
|
8
9
|
var _hostComponentNames = require("./host-component-names");
|
|
9
10
|
function isTextInputEditable(element) {
|
|
10
11
|
if (!(0, _hostComponentNames.isHostTextInput)(element)) {
|
|
@@ -16,6 +17,6 @@ function getTextInputValue(element) {
|
|
|
16
17
|
if (!(0, _hostComponentNames.isHostTextInput)(element)) {
|
|
17
18
|
throw new Error(`Element is not a "TextInput", but it has type "${element.type}".`);
|
|
18
19
|
}
|
|
19
|
-
return element.props.value ?? element.props.defaultValue;
|
|
20
|
+
return element.props.value ?? _nativeState.nativeState.valueForElement.get(element) ?? element.props.defaultValue ?? '';
|
|
20
21
|
}
|
|
21
22
|
//# sourceMappingURL=text-input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text-input.js","names":["
|
|
1
|
+
{"version":3,"file":"text-input.js","names":["_nativeState","require","_hostComponentNames","isTextInputEditable","element","isHostTextInput","Error","type","props","editable","getTextInputValue","value","nativeState","valueForElement","get","defaultValue"],"sources":["../../src/helpers/text-input.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { nativeState } from '../native-state';\nimport { isHostTextInput } from './host-component-names';\n\nexport function isTextInputEditable(element: ReactTestInstance) {\n if (!isHostTextInput(element)) {\n throw new Error(`Element is not a \"TextInput\", but it has type \"${element.type}\".`);\n }\n\n return element.props.editable !== false;\n}\n\nexport function getTextInputValue(element: ReactTestInstance) {\n if (!isHostTextInput(element)) {\n throw new Error(`Element is not a \"TextInput\", but it has type \"${element.type}\".`);\n }\n\n return (\n element.props.value ??\n nativeState.valueForElement.get(element) ??\n element.props.defaultValue ??\n ''\n );\n}\n"],"mappings":";;;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AAEO,SAASE,mBAAmBA,CAACC,OAA0B,EAAE;EAC9D,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,KAAK,CAAC,kDAAkDF,OAAO,CAACG,IAAI,IAAI,CAAC;EACrF;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,CAAC,kDAAkDF,OAAO,CAACG,IAAI,IAAI,CAAC;EACrF;EAEA,OACEH,OAAO,CAACI,KAAK,CAACG,KAAK,IACnBC,wBAAW,CAACC,eAAe,CAACC,GAAG,CAACV,OAAO,CAAC,IACxCA,OAAO,CAACI,KAAK,CAACO,YAAY,IAC1B,EAAE;AAEN","ignoreList":[]}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var _toBeOnTheScreen = require("./to-be-on-the-screen");
|
|
4
4
|
var _toBeChecked = require("./to-be-checked");
|
|
5
|
-
var _toBeCollapsed = require("./to-be-collapsed");
|
|
6
5
|
var _toBeDisabled = require("./to-be-disabled");
|
|
7
6
|
var _toBeBusy = require("./to-be-busy");
|
|
8
7
|
var _toBeEmptyElement = require("./to-be-empty-element");
|
|
@@ -20,7 +19,7 @@ var _toHaveTextContent = require("./to-have-text-content");
|
|
|
20
19
|
expect.extend({
|
|
21
20
|
toBeOnTheScreen: _toBeOnTheScreen.toBeOnTheScreen,
|
|
22
21
|
toBeChecked: _toBeChecked.toBeChecked,
|
|
23
|
-
toBeCollapsed:
|
|
22
|
+
toBeCollapsed: _toBeExpanded.toBeCollapsed,
|
|
24
23
|
toBeDisabled: _toBeDisabled.toBeDisabled,
|
|
25
24
|
toBeBusy: _toBeBusy.toBeBusy,
|
|
26
25
|
toBeEmptyElement: _toBeEmptyElement.toBeEmptyElement,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extend-expect.js","names":["_toBeOnTheScreen","require","_toBeChecked","
|
|
1
|
+
{"version":3,"file":"extend-expect.js","names":["_toBeOnTheScreen","require","_toBeChecked","_toBeDisabled","_toBeBusy","_toBeEmptyElement","_toBeExpanded","_toBePartiallyChecked","_toBeSelected","_toBeVisible","_toContainElement","_toHaveAccessibilityValue","_toHaveAccessibleName","_toHaveDisplayValue","_toHaveProp","_toHaveStyle","_toHaveTextContent","expect","extend","toBeOnTheScreen","toBeChecked","toBeCollapsed","toBeDisabled","toBeBusy","toBeEmptyElement","toBeEnabled","toBeExpanded","toBePartiallyChecked","toBeSelected","toBeVisible","toContainElement","toHaveAccessibilityValue","toHaveAccessibleName","toHaveDisplayValue","toHaveProp","toHaveStyle","toHaveTextContent"],"sources":["../../src/matchers/extend-expect.ts"],"sourcesContent":["import { toBeOnTheScreen } from './to-be-on-the-screen';\nimport { toBeChecked } from './to-be-checked';\nimport { toBeDisabled, toBeEnabled } from './to-be-disabled';\nimport { toBeBusy } from './to-be-busy';\nimport { toBeEmptyElement } from './to-be-empty-element';\nimport { toBeExpanded, toBeCollapsed } 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 { toHaveAccessibilityValue } from './to-have-accessibility-value';\nimport { toHaveAccessibleName } from './to-have-accessible-name';\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\nexport type * from './types';\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 toHaveAccessibilityValue,\n toHaveAccessibleName,\n toHaveDisplayValue,\n toHaveProp,\n toHaveStyle,\n toHaveTextContent,\n});\n"],"mappings":";;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,aAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,yBAAA,GAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,YAAA,GAAAd,OAAA;AACA,IAAAe,kBAAA,GAAAf,OAAA;AAIAgB,MAAM,CAACC,MAAM,CAAC;EACZC,eAAe,EAAfA,gCAAe;EACfC,WAAW,EAAXA,wBAAW;EACXC,aAAa,EAAbA,2BAAa;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,wBAAwB,EAAxBA,kDAAwB;EACxBC,oBAAoB,EAApBA,0CAAoB;EACpBC,kBAAkB,EAAlBA,sCAAkB;EAClBC,UAAU,EAAVA,sBAAU;EACVC,WAAW,EAAXA,wBAAW;EACXC,iBAAiB,EAAjBA;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export { toBeBusy } from './to-be-busy';
|
|
2
2
|
export { toBeChecked } from './to-be-checked';
|
|
3
|
-
export { toBeCollapsed } from './to-be-collapsed';
|
|
4
3
|
export { toBeDisabled, toBeEnabled } from './to-be-disabled';
|
|
5
4
|
export { toBeEmptyElement } from './to-be-empty-element';
|
|
6
|
-
export { toBeExpanded } from './to-be-expanded';
|
|
5
|
+
export { toBeExpanded, toBeCollapsed } from './to-be-expanded';
|
|
7
6
|
export { toBeOnTheScreen } from './to-be-on-the-screen';
|
|
8
7
|
export { toBePartiallyChecked } from './to-be-partially-checked';
|
|
9
8
|
export { toBeSelected } from './to-be-selected';
|
package/build/matchers/index.js
CHANGED
|
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "toBeChecked", {
|
|
|
18
18
|
Object.defineProperty(exports, "toBeCollapsed", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _toBeExpanded.toBeCollapsed;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "toBeDisabled", {
|
|
@@ -113,7 +113,6 @@ Object.defineProperty(exports, "toHaveTextContent", {
|
|
|
113
113
|
});
|
|
114
114
|
var _toBeBusy = require("./to-be-busy");
|
|
115
115
|
var _toBeChecked = require("./to-be-checked");
|
|
116
|
-
var _toBeCollapsed = require("./to-be-collapsed");
|
|
117
116
|
var _toBeDisabled = require("./to-be-disabled");
|
|
118
117
|
var _toBeEmptyElement = require("./to-be-empty-element");
|
|
119
118
|
var _toBeExpanded = require("./to-be-expanded");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_toBeBusy","require","_toBeChecked","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_toBeBusy","require","_toBeChecked","_toBeDisabled","_toBeEmptyElement","_toBeExpanded","_toBeOnTheScreen","_toBePartiallyChecked","_toBeSelected","_toBeVisible","_toContainElement","_toHaveAccessibilityValue","_toHaveAccessibleName","_toHaveDisplayValue","_toHaveProp","_toHaveStyle","_toHaveTextContent"],"sources":["../../src/matchers/index.ts"],"sourcesContent":["export { toBeBusy } from './to-be-busy';\nexport { toBeChecked } from './to-be-checked';\nexport { toBeDisabled, toBeEnabled } from './to-be-disabled';\nexport { toBeEmptyElement } from './to-be-empty-element';\nexport { toBeExpanded, toBeCollapsed } 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 { toHaveAccessibilityValue } from './to-have-accessibility-value';\nexport { toHaveAccessibleName } from './to-have-accessible-name';\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,aAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,qBAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AACA,IAAAU,yBAAA,GAAAV,OAAA;AACA,IAAAW,qBAAA,GAAAX,OAAA;AACA,IAAAY,mBAAA,GAAAZ,OAAA;AACA,IAAAa,WAAA,GAAAb,OAAA;AACA,IAAAc,YAAA,GAAAd,OAAA;AACA,IAAAe,kBAAA,GAAAf,OAAA","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
3
2
|
export declare function toBeBusy(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
4
|
-
pass:
|
|
3
|
+
pass: boolean;
|
|
5
4
|
message: () => string;
|
|
6
5
|
};
|
|
@@ -10,7 +10,7 @@ var _utils = require("./utils");
|
|
|
10
10
|
function toBeBusy(element) {
|
|
11
11
|
(0, _utils.checkHostElement)(element, toBeBusy, this);
|
|
12
12
|
return {
|
|
13
|
-
pass: (0, _accessibility.
|
|
13
|
+
pass: (0, _accessibility.computeAriaBusy)(element),
|
|
14
14
|
message: () => {
|
|
15
15
|
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeBusy`, 'element', '');
|
|
16
16
|
return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}busy:`, (0, _utils.formatElement)(element)].join('\n');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-busy.js","names":["_jestMatcherUtils","require","_accessibility","_utils","toBeBusy","element","checkHostElement","pass","
|
|
1
|
+
{"version":3,"file":"to-be-busy.js","names":["_jestMatcherUtils","require","_accessibility","_utils","toBeBusy","element","checkHostElement","pass","computeAriaBusy","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-busy.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { computeAriaBusy } from '../helpers/accessibility';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeBusy(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeBusy, this);\n\n return {\n pass: computeAriaBusy(element),\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeBusy`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}busy:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,QAAQA,CAA4BC,OAA0B,EAAE;EAC9E,IAAAC,uBAAgB,EAACD,OAAO,EAAED,QAAQ,EAAE,IAAI,CAAC;EAEzC,OAAO;IACLG,IAAI,EAAE,IAAAC,8BAAe,EAACH,OAAO,CAAC;IAC9BI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,WAAW,EAAE,SAAS,EAAE,EAAE,CAAC;MAClF,OAAO,CACLF,OAAO,EACP,EAAE,EACF,uBAAuB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAM,OAAO,EACtD,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -7,25 +7,26 @@ exports.toBeChecked = toBeChecked;
|
|
|
7
7
|
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
8
|
var _accessibility = require("../helpers/accessibility");
|
|
9
9
|
var _errors = require("../helpers/errors");
|
|
10
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
10
11
|
var _utils = require("./utils");
|
|
11
12
|
function toBeChecked(element) {
|
|
12
13
|
(0, _utils.checkHostElement)(element, toBeChecked, this);
|
|
13
|
-
if (!
|
|
14
|
-
throw new _errors.ErrorWithStack(`toBeChecked() works only on accessibility elements with "checkbox" or "
|
|
14
|
+
if (!(0, _hostComponentNames.isHostSwitch)(element) && !isSupportedAccessibilityElement(element)) {
|
|
15
|
+
throw new _errors.ErrorWithStack(`toBeChecked() works only on host "Switch" elements or accessibility elements with "checkbox", "radio" or "switch" role.`, toBeChecked);
|
|
15
16
|
}
|
|
16
17
|
return {
|
|
17
|
-
pass: (0, _accessibility.
|
|
18
|
+
pass: (0, _accessibility.computeAriaChecked)(element) === true,
|
|
18
19
|
message: () => {
|
|
19
20
|
const is = this.isNot ? 'is' : 'is not';
|
|
20
21
|
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeChecked`, 'element', ''), '', `Received element ${is} checked:`, (0, _utils.formatElement)(element)].join('\n');
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
+
function isSupportedAccessibilityElement(element) {
|
|
25
26
|
if (!(0, _accessibility.isAccessibilityElement)(element)) {
|
|
26
27
|
return false;
|
|
27
28
|
}
|
|
28
|
-
const role = (0, _accessibility.
|
|
29
|
-
return role
|
|
29
|
+
const role = (0, _accessibility.getRole)(element);
|
|
30
|
+
return _accessibility.rolesSupportingCheckedState[role];
|
|
30
31
|
}
|
|
31
32
|
//# sourceMappingURL=to-be-checked.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-checked.js","names":["_jestMatcherUtils","require","_accessibility","_errors","_utils","toBeChecked","element","checkHostElement","
|
|
1
|
+
{"version":3,"file":"to-be-checked.js","names":["_jestMatcherUtils","require","_accessibility","_errors","_hostComponentNames","_utils","toBeChecked","element","checkHostElement","isHostSwitch","isSupportedAccessibilityElement","ErrorWithStack","pass","computeAriaChecked","message","is","isNot","matcherHint","formatElement","join","isAccessibilityElement","role","getRole","rolesSupportingCheckedState"],"sources":["../../src/matchers/to-be-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n computeAriaChecked,\n getRole,\n isAccessibilityElement,\n rolesSupportingCheckedState,\n} from '../helpers/accessibility';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostSwitch } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeChecked(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeChecked, this);\n\n if (!isHostSwitch(element) && !isSupportedAccessibilityElement(element)) {\n throw new ErrorWithStack(\n `toBeChecked() works only on host \"Switch\" elements or accessibility elements with \"checkbox\", \"radio\" or \"switch\" role.`,\n toBeChecked,\n );\n }\n\n return {\n pass: computeAriaChecked(element) === true,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeChecked`, 'element', ''),\n '',\n `Received element ${is} checked:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isSupportedAccessibilityElement(element: ReactTestInstance) {\n if (!isAccessibilityElement(element)) {\n return false;\n }\n\n const role = getRole(element);\n return rolesSupportingCheckedState[role];\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAMA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEO,SAASK,WAAWA,CAA4BC,OAA0B,EAAE;EACjF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAE5C,IAAI,CAAC,IAAAG,gCAAY,EAACF,OAAO,CAAC,IAAI,CAACG,+BAA+B,CAACH,OAAO,CAAC,EAAE;IACvE,MAAM,IAAII,sBAAc,CACtB,yHAAyH,EACzHL,WACF,CAAC;EACH;EAEA,OAAO;IACLM,IAAI,EAAE,IAAAC,iCAAkB,EAACN,OAAO,CAAC,KAAK,IAAI;IAC1CO,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACF,oBAAoBD,EAAE,WAAW,EACjC,IAAAG,oBAAa,EAACX,OAAO,CAAC,CACvB,CAACY,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAAST,+BAA+BA,CAACH,OAA0B,EAAE;EACnE,IAAI,CAAC,IAAAa,qCAAsB,EAACb,OAAO,CAAC,EAAE;IACpC,OAAO,KAAK;EACd;EAEA,MAAMc,IAAI,GAAG,IAAAC,sBAAO,EAACf,OAAO,CAAC;EAC7B,OAAOgB,0CAA2B,CAACF,IAAI,CAAC;AAC1C","ignoreList":[]}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
2
|
export declare function toBeDisabled(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
4
|
-
pass:
|
|
3
|
+
pass: boolean;
|
|
5
4
|
message: () => string;
|
|
6
5
|
};
|
|
7
6
|
export declare function toBeEnabled(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
@@ -6,13 +6,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.toBeDisabled = toBeDisabled;
|
|
7
7
|
exports.toBeEnabled = toBeEnabled;
|
|
8
8
|
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
9
|
-
var
|
|
10
|
-
var _textInput = require("../helpers/text-input");
|
|
9
|
+
var _accessibility = require("../helpers/accessibility");
|
|
11
10
|
var _componentTree = require("../helpers/component-tree");
|
|
12
11
|
var _utils = require("./utils");
|
|
13
12
|
function toBeDisabled(element) {
|
|
14
13
|
(0, _utils.checkHostElement)(element, toBeDisabled, this);
|
|
15
|
-
const isDisabled =
|
|
14
|
+
const isDisabled = (0, _accessibility.computeAriaDisabled)(element) || isAncestorDisabled(element);
|
|
16
15
|
return {
|
|
17
16
|
pass: isDisabled,
|
|
18
17
|
message: () => {
|
|
@@ -23,7 +22,7 @@ function toBeDisabled(element) {
|
|
|
23
22
|
}
|
|
24
23
|
function toBeEnabled(element) {
|
|
25
24
|
(0, _utils.checkHostElement)(element, toBeEnabled, this);
|
|
26
|
-
const isEnabled = !
|
|
25
|
+
const isEnabled = !(0, _accessibility.computeAriaDisabled)(element) && !isAncestorDisabled(element);
|
|
27
26
|
return {
|
|
28
27
|
pass: isEnabled,
|
|
29
28
|
message: () => {
|
|
@@ -32,21 +31,11 @@ function toBeEnabled(element) {
|
|
|
32
31
|
}
|
|
33
32
|
};
|
|
34
33
|
}
|
|
35
|
-
function isElementDisabled(element) {
|
|
36
|
-
if ((0, _hostComponentNames.isHostTextInput)(element) && !(0, _textInput.isTextInputEditable)(element)) {
|
|
37
|
-
return true;
|
|
38
|
-
}
|
|
39
|
-
const {
|
|
40
|
-
accessibilityState,
|
|
41
|
-
'aria-disabled': ariaDisabled
|
|
42
|
-
} = element.props;
|
|
43
|
-
return ariaDisabled ?? accessibilityState?.disabled ?? false;
|
|
44
|
-
}
|
|
45
34
|
function isAncestorDisabled(element) {
|
|
46
35
|
const parent = (0, _componentTree.getHostParent)(element);
|
|
47
36
|
if (parent == null) {
|
|
48
37
|
return false;
|
|
49
38
|
}
|
|
50
|
-
return
|
|
39
|
+
return (0, _accessibility.computeAriaDisabled)(parent) || isAncestorDisabled(parent);
|
|
51
40
|
}
|
|
52
41
|
//# sourceMappingURL=to-be-disabled.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-disabled.js","names":["_jestMatcherUtils","require","
|
|
1
|
+
{"version":3,"file":"to-be-disabled.js","names":["_jestMatcherUtils","require","_accessibility","_componentTree","_utils","toBeDisabled","element","checkHostElement","isDisabled","computeAriaDisabled","isAncestorDisabled","pass","message","is","isNot","matcherHint","formatElement","join","toBeEnabled","isEnabled","parent","getHostParent"],"sources":["../../src/matchers/to-be-disabled.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { computeAriaDisabled } from '../helpers/accessibility';\nimport { getHostParent } from '../helpers/component-tree';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeDisabled(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeDisabled, this);\n\n const isDisabled = computeAriaDisabled(element) || isAncestorDisabled(element);\n\n return {\n pass: isDisabled,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeDisabled`, 'element', ''),\n '',\n `Received element ${is} disabled:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nexport function toBeEnabled(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeEnabled, this);\n\n const isEnabled = !computeAriaDisabled(element) && !isAncestorDisabled(element);\n\n return {\n pass: isEnabled,\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeEnabled`, 'element', ''),\n '',\n `Received element ${is} enabled:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isAncestorDisabled(element: ReactTestInstance): boolean {\n const parent = getHostParent(element);\n if (parent == null) {\n return false;\n }\n\n return computeAriaDisabled(parent) || isAncestorDisabled(parent);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,MA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kBA,CAACJ,OAA0B,EAAW;EAC/D,MAAMc,MAAM,GAAG,IAAAC,4BAAa,EAACf,OAAO,CAAC;EACrC,IAAIc,MAAM,IAAI,IAAI,EAAE;IAClB,OAAO,KAAK;EACd;EAEA,OAAO,IAAAX,kCAAmB,EAACW,MAAM,CAAC,IAAIV,kBAAkB,CAACU,MAAM,CAAC;AAClE","ignoreList":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
/// <reference types="jest" />
|
|
2
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
3
2
|
export declare function toBeExpanded(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
4
|
-
pass:
|
|
3
|
+
pass: boolean;
|
|
4
|
+
message: () => string;
|
|
5
|
+
};
|
|
6
|
+
export declare function toBeCollapsed(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
7
|
+
pass: boolean;
|
|
5
8
|
message: () => string;
|
|
6
9
|
};
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.toBeCollapsed = toBeCollapsed;
|
|
6
7
|
exports.toBeExpanded = toBeExpanded;
|
|
7
8
|
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
9
|
var _accessibility = require("../helpers/accessibility");
|
|
@@ -10,11 +11,21 @@ var _utils = require("./utils");
|
|
|
10
11
|
function toBeExpanded(element) {
|
|
11
12
|
(0, _utils.checkHostElement)(element, toBeExpanded, this);
|
|
12
13
|
return {
|
|
13
|
-
pass: (0, _accessibility.
|
|
14
|
+
pass: (0, _accessibility.computeAriaExpanded)(element) === true,
|
|
14
15
|
message: () => {
|
|
15
16
|
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeExpanded`, 'element', '');
|
|
16
17
|
return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}expanded:`, (0, _utils.formatElement)(element)].join('\n');
|
|
17
18
|
}
|
|
18
19
|
};
|
|
19
20
|
}
|
|
21
|
+
function toBeCollapsed(element) {
|
|
22
|
+
(0, _utils.checkHostElement)(element, toBeCollapsed, this);
|
|
23
|
+
return {
|
|
24
|
+
pass: (0, _accessibility.computeAriaExpanded)(element) === false,
|
|
25
|
+
message: () => {
|
|
26
|
+
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeCollapsed`, 'element', '');
|
|
27
|
+
return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}collapsed:`, (0, _utils.formatElement)(element)].join('\n');
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
//# sourceMappingURL=to-be-expanded.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-expanded.js","names":["_jestMatcherUtils","require","_accessibility","_utils","toBeExpanded","element","checkHostElement","pass","
|
|
1
|
+
{"version":3,"file":"to-be-expanded.js","names":["_jestMatcherUtils","require","_accessibility","_utils","toBeExpanded","element","checkHostElement","pass","computeAriaExpanded","message","matcher","matcherHint","isNot","formatElement","join","toBeCollapsed"],"sources":["../../src/matchers/to-be-expanded.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { computeAriaExpanded } from '../helpers/accessibility';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeExpanded(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeExpanded, this);\n\n return {\n pass: computeAriaExpanded(element) === true,\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeExpanded`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}expanded:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nexport function toBeCollapsed(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeCollapsed, this);\n\n return {\n pass: computeAriaExpanded(element) === false,\n message: () => {\n const matcher = matcherHint(`${this.isNot ? '.not' : ''}.toBeCollapsed`, 'element', '');\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}collapsed:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAA4BC,OAA0B,EAAE;EAClF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,OAAO;IACLG,IAAI,EAAE,IAAAC,kCAAmB,EAACH,OAAO,CAAC,KAAK,IAAI;IAC3CI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,eAAe,EAAE,SAAS,EAAE,EAAE,CAAC;MACtF,OAAO,CACLF,OAAO,EACP,EAAE,EACF,uBAAuB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAM,WAAW,EAC1D,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEO,SAASC,aAAaA,CAA4BV,OAA0B,EAAE;EACnF,IAAAC,uBAAgB,EAACD,OAAO,EAAEU,aAAa,EAAE,IAAI,CAAC;EAE9C,OAAO;IACLR,IAAI,EAAE,IAAAC,kCAAmB,EAACH,OAAO,CAAC,KAAK,KAAK;IAC5CI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,gBAAgB,EAAE,SAAS,EAAE,EAAE,CAAC;MACvF,OAAO,CACLF,OAAO,EACP,EAAE,EACF,uBAAuB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAM,YAAY,EAC3D,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