@testing-library/react-native 12.8.1 → 13.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/build/act.d.ts +2 -1
- package/build/act.js +14 -10
- package/build/act.js.map +1 -1
- package/build/config.d.ts +5 -20
- package/build/config.js +1 -8
- package/build/config.js.map +1 -1
- package/build/fire-event.js +1 -1
- package/build/fire-event.js.map +1 -1
- package/build/flush-micro-tasks.d.ts +0 -18
- package/build/flush-micro-tasks.js +0 -25
- package/build/flush-micro-tasks.js.map +1 -1
- package/build/helpers/accessibility.d.ts +1 -2
- package/build/helpers/accessibility.js +13 -21
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +2 -2
- package/build/helpers/component-tree.js +0 -3
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/{debug-deep.d.ts → debug.d.ts} +1 -1
- package/build/helpers/{debug-deep.js → debug.js} +3 -3
- package/build/helpers/debug.js.map +1 -0
- package/build/helpers/host-component-names.d.ts +6 -9
- package/build/helpers/host-component-names.js +12 -71
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +1 -1
- package/build/helpers/matchers/match-label-text.js +2 -13
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/wrap-async.js +10 -27
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.flow.js +4 -37
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.js +4 -0
- package/build/matchers/utils.js.map +1 -1
- package/build/queries/label-text.js +1 -1
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/options.js +4 -0
- package/build/render-hook.js +1 -2
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +6 -60
- package/build/render.js +6 -13
- package/build/render.js.map +1 -1
- package/build/screen.js +0 -25
- package/build/screen.js.map +1 -1
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/within.d.ts +0 -24
- package/build/within.js +0 -4
- package/build/within.js.map +1 -1
- package/matchers.d.ts +1 -0
- package/matchers.js +2 -0
- package/package.json +22 -17
- package/typings/index.flow.js +4 -37
- package/build/helpers/debug-deep.js.map +0 -1
- package/build/helpers/debug-shallow.d.ts +0 -6
- package/build/helpers/debug-shallow.js +0 -25
- package/build/helpers/debug-shallow.js.map +0 -1
- package/build/queries/accessibility-state.d.ts +0 -19
- package/build/queries/accessibility-state.js +0 -59
- package/build/queries/accessibility-state.js.map +0 -1
- package/build/queries/accessibility-value.d.ts +0 -19
- package/build/queries/accessibility-value.js +0 -59
- package/build/queries/accessibility-value.js.map +0 -1
- package/build/shallow.d.ts +0 -8
- package/build/shallow.js +0 -24
- package/build/shallow.js.map +0 -1
- package/extend-expect.d.ts +0 -1
- package/extend-expect.js +0 -1
|
@@ -1,35 +1,32 @@
|
|
|
1
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
-
import { HostComponentNames } from '../config';
|
|
3
2
|
import { HostTestInstance } from './component-tree';
|
|
4
|
-
export declare function getHostComponentNames(): HostComponentNames;
|
|
5
|
-
export declare function configureHostComponentNamesIfNeeded(): void;
|
|
6
3
|
/**
|
|
7
4
|
* Checks if the given element is a host Text element.
|
|
8
5
|
* @param element The element to check.
|
|
9
6
|
*/
|
|
10
|
-
export declare function isHostText(element
|
|
7
|
+
export declare function isHostText(element: ReactTestInstance): element is HostTestInstance;
|
|
11
8
|
/**
|
|
12
9
|
* Checks if the given element is a host TextInput element.
|
|
13
10
|
* @param element The element to check.
|
|
14
11
|
*/
|
|
15
|
-
export declare function isHostTextInput(element
|
|
12
|
+
export declare function isHostTextInput(element: ReactTestInstance): element is HostTestInstance;
|
|
16
13
|
/**
|
|
17
14
|
* Checks if the given element is a host Image element.
|
|
18
15
|
* @param element The element to check.
|
|
19
16
|
*/
|
|
20
|
-
export declare function isHostImage(element
|
|
17
|
+
export declare function isHostImage(element: ReactTestInstance): element is HostTestInstance;
|
|
21
18
|
/**
|
|
22
19
|
* Checks if the given element is a host Switch element.
|
|
23
20
|
* @param element The element to check.
|
|
24
21
|
*/
|
|
25
|
-
export declare function isHostSwitch(element
|
|
22
|
+
export declare function isHostSwitch(element: ReactTestInstance): element is HostTestInstance;
|
|
26
23
|
/**
|
|
27
24
|
* Checks if the given element is a host ScrollView element.
|
|
28
25
|
* @param element The element to check.
|
|
29
26
|
*/
|
|
30
|
-
export declare function isHostScrollView(element
|
|
27
|
+
export declare function isHostScrollView(element: ReactTestInstance): element is HostTestInstance;
|
|
31
28
|
/**
|
|
32
29
|
* Checks if the given element is a host Modal element.
|
|
33
30
|
* @param element The element to check.
|
|
34
31
|
*/
|
|
35
|
-
export declare function isHostModal(element
|
|
32
|
+
export declare function isHostModal(element: ReactTestInstance): element is HostTestInstance;
|
|
@@ -3,84 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.configureHostComponentNamesIfNeeded = configureHostComponentNamesIfNeeded;
|
|
7
|
-
exports.getHostComponentNames = getHostComponentNames;
|
|
8
6
|
exports.isHostImage = isHostImage;
|
|
9
7
|
exports.isHostModal = isHostModal;
|
|
10
8
|
exports.isHostScrollView = isHostScrollView;
|
|
11
9
|
exports.isHostSwitch = isHostSwitch;
|
|
12
10
|
exports.isHostText = isHostText;
|
|
13
11
|
exports.isHostTextInput = isHostTextInput;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.
|
|
21
|
-
Please check if you are using compatible versions of React Native and React Native Testing Library.`;
|
|
22
|
-
function getHostComponentNames() {
|
|
23
|
-
let hostComponentNames = (0, _config.getConfig)().hostComponentNames;
|
|
24
|
-
if (!hostComponentNames) {
|
|
25
|
-
hostComponentNames = detectHostComponentNames();
|
|
26
|
-
(0, _config.configureInternal)({
|
|
27
|
-
hostComponentNames
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return hostComponentNames;
|
|
31
|
-
}
|
|
32
|
-
function configureHostComponentNamesIfNeeded() {
|
|
33
|
-
const configHostComponentNames = (0, _config.getConfig)().hostComponentNames;
|
|
34
|
-
if (configHostComponentNames) {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
const hostComponentNames = detectHostComponentNames();
|
|
38
|
-
(0, _config.configureInternal)({
|
|
39
|
-
hostComponentNames
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function detectHostComponentNames() {
|
|
43
|
-
try {
|
|
44
|
-
const renderer = (0, _renderAct.renderWithAct)(/*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNative.Text, {
|
|
45
|
-
testID: "text"
|
|
46
|
-
}, "Hello"), /*#__PURE__*/React.createElement(_reactNative.TextInput, {
|
|
47
|
-
testID: "textInput"
|
|
48
|
-
}), /*#__PURE__*/React.createElement(_reactNative.Image, {
|
|
49
|
-
testID: "image"
|
|
50
|
-
}), /*#__PURE__*/React.createElement(_reactNative.Switch, {
|
|
51
|
-
testID: "switch"
|
|
52
|
-
}), /*#__PURE__*/React.createElement(_reactNative.ScrollView, {
|
|
53
|
-
testID: "scrollView"
|
|
54
|
-
}), /*#__PURE__*/React.createElement(_reactNative.Modal, {
|
|
55
|
-
testID: "modal"
|
|
56
|
-
})));
|
|
57
|
-
return {
|
|
58
|
-
text: getByTestId(renderer.root, 'text').type,
|
|
59
|
-
textInput: getByTestId(renderer.root, 'textInput').type,
|
|
60
|
-
image: getByTestId(renderer.root, 'image').type,
|
|
61
|
-
switch: getByTestId(renderer.root, 'switch').type,
|
|
62
|
-
scrollView: getByTestId(renderer.root, 'scrollView').type,
|
|
63
|
-
modal: getByTestId(renderer.root, 'modal').type
|
|
64
|
-
};
|
|
65
|
-
} catch (error) {
|
|
66
|
-
const errorMessage = error && typeof error === 'object' && 'message' in error ? error.message : null;
|
|
67
|
-
throw new Error(`Trying to detect host component names triggered the following error:\n\n${errorMessage}\n\n${userConfigErrorMessage}`);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function getByTestId(instance, testID) {
|
|
71
|
-
const nodes = instance.findAll(node => typeof node.type === 'string' && node.props.testID === testID);
|
|
72
|
-
if (nodes.length === 0) {
|
|
73
|
-
throw new Error(`Unable to find an element with testID: ${testID}`);
|
|
74
|
-
}
|
|
75
|
-
return nodes[0];
|
|
76
|
-
}
|
|
12
|
+
const HOST_TEXT_NAMES = ['Text', 'RCTText'];
|
|
13
|
+
const HOST_TEXT_INPUT_NAMES = ['TextInput'];
|
|
14
|
+
const HOST_IMAGE_NAMES = ['Image'];
|
|
15
|
+
const HOST_SWITCH_NAMES = ['RCTSwitch'];
|
|
16
|
+
const HOST_SCROLL_VIEW_NAMES = ['RCTScrollView'];
|
|
17
|
+
const HOST_MODAL_NAMES = ['Modal'];
|
|
77
18
|
|
|
78
19
|
/**
|
|
79
20
|
* Checks if the given element is a host Text element.
|
|
80
21
|
* @param element The element to check.
|
|
81
22
|
*/
|
|
82
23
|
function isHostText(element) {
|
|
83
|
-
return element?.type ===
|
|
24
|
+
return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);
|
|
84
25
|
}
|
|
85
26
|
|
|
86
27
|
/**
|
|
@@ -88,7 +29,7 @@ function isHostText(element) {
|
|
|
88
29
|
* @param element The element to check.
|
|
89
30
|
*/
|
|
90
31
|
function isHostTextInput(element) {
|
|
91
|
-
return element?.type ===
|
|
32
|
+
return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);
|
|
92
33
|
}
|
|
93
34
|
|
|
94
35
|
/**
|
|
@@ -96,7 +37,7 @@ function isHostTextInput(element) {
|
|
|
96
37
|
* @param element The element to check.
|
|
97
38
|
*/
|
|
98
39
|
function isHostImage(element) {
|
|
99
|
-
return element?.type ===
|
|
40
|
+
return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);
|
|
100
41
|
}
|
|
101
42
|
|
|
102
43
|
/**
|
|
@@ -104,7 +45,7 @@ function isHostImage(element) {
|
|
|
104
45
|
* @param element The element to check.
|
|
105
46
|
*/
|
|
106
47
|
function isHostSwitch(element) {
|
|
107
|
-
return element?.type ===
|
|
48
|
+
return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);
|
|
108
49
|
}
|
|
109
50
|
|
|
110
51
|
/**
|
|
@@ -112,7 +53,7 @@ function isHostSwitch(element) {
|
|
|
112
53
|
* @param element The element to check.
|
|
113
54
|
*/
|
|
114
55
|
function isHostScrollView(element) {
|
|
115
|
-
return element?.type ===
|
|
56
|
+
return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);
|
|
116
57
|
}
|
|
117
58
|
|
|
118
59
|
/**
|
|
@@ -120,6 +61,6 @@ function isHostScrollView(element) {
|
|
|
120
61
|
* @param element The element to check.
|
|
121
62
|
*/
|
|
122
63
|
function isHostModal(element) {
|
|
123
|
-
return element?.type ===
|
|
64
|
+
return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);
|
|
124
65
|
}
|
|
125
66
|
//# sourceMappingURL=host-component-names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-component-names.js","names":["
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["HOST_TEXT_NAMES","HOST_TEXT_INPUT_NAMES","HOST_IMAGE_NAMES","HOST_SWITCH_NAMES","HOST_SCROLL_VIEW_NAMES","HOST_MODAL_NAMES","isHostText","element","type","includes","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { HostTestInstance } from './component-tree';\n\nconst HOST_TEXT_NAMES = ['Text', 'RCTText'];\nconst HOST_TEXT_INPUT_NAMES = ['TextInput'];\nconst HOST_IMAGE_NAMES = ['Image'];\nconst HOST_SWITCH_NAMES = ['RCTSwitch'];\nconst HOST_SCROLL_VIEW_NAMES = ['RCTScrollView'];\nconst HOST_MODAL_NAMES = ['Modal'];\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element: ReactTestInstance): element is HostTestInstance {\n return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);\n}\n"],"mappings":";;;;;;;;;;;AAGA,MAAMA,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;AAC3C,MAAMC,qBAAqB,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;AAClC,MAAMC,iBAAiB,GAAG,CAAC,WAAW,CAAC;AACvC,MAAMC,sBAAsB,GAAG,CAAC,eAAe,CAAC;AAChD,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;;AAElC;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACC,OAA0B,EAA+B;EAClF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIR,eAAe,CAACS,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACpF;;AAEA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAACH,OAA0B,EAA+B;EACvF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIP,qBAAqB,CAACQ,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC1F;;AAEA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACJ,OAA0B,EAA+B;EACnF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIN,gBAAgB,CAACO,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAACL,OAA0B,EAA+B;EACpF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIL,iBAAiB,CAACM,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACtF;;AAEA;AACA;AACA;AACA;AACO,SAASK,gBAAgBA,CAACN,OAA0B,EAA+B;EACxF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIJ,sBAAsB,CAACK,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC3F;;AAEA;AACA;AACA;AACA;AACO,SAASM,WAAWA,CAACP,OAA0B,EAA+B;EACnF,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIH,gBAAgB,CAACI,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import { TextMatch, TextMatchOptions } from '../../matches';
|
|
3
|
-
export declare function
|
|
3
|
+
export declare function matchAccessibilityLabel(element: ReactTestInstance, expectedLabel: TextMatch, options?: TextMatchOptions): boolean;
|
|
@@ -3,21 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.matchAccessibilityLabel = matchAccessibilityLabel;
|
|
7
7
|
var _matches = require("../../matches");
|
|
8
8
|
var _accessibility = require("../accessibility");
|
|
9
|
-
var _findAll = require("../find-all");
|
|
10
|
-
var _matchTextContent = require("./match-text-content");
|
|
11
|
-
function matchLabelText(root, element, expectedText, options = {}) {
|
|
12
|
-
return matchAccessibilityLabel(element, expectedText, options) || matchAccessibilityLabelledBy(root, (0, _accessibility.computeAriaLabelledBy)(element), expectedText, options);
|
|
13
|
-
}
|
|
14
9
|
function matchAccessibilityLabel(element, expectedLabel, options) {
|
|
15
|
-
return (0, _matches.matches)(expectedLabel, (0, _accessibility.computeAriaLabel)(element), options
|
|
16
|
-
}
|
|
17
|
-
function matchAccessibilityLabelledBy(root, nativeId, text, options) {
|
|
18
|
-
if (!nativeId) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
return (0, _findAll.findAll)(root, node => node.props.nativeID === nativeId && (0, _matchTextContent.matchTextContent)(node, text, options)).length > 0;
|
|
10
|
+
return (0, _matches.matches)(expectedLabel, (0, _accessibility.computeAriaLabel)(element), options?.normalizer, options?.exact);
|
|
22
11
|
}
|
|
23
12
|
//# sourceMappingURL=match-label-text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","
|
|
1
|
+
{"version":3,"file":"match-label-text.js","names":["_matches","require","_accessibility","matchAccessibilityLabel","element","expectedLabel","options","matches","computeAriaLabel","normalizer","exact"],"sources":["../../../src/helpers/matchers/match-label-text.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { computeAriaLabel } from '../accessibility';\n\nexport function matchAccessibilityLabel(\n element: ReactTestInstance,\n expectedLabel: TextMatch,\n options?: TextMatchOptions,\n) {\n return matches(expectedLabel, computeAriaLabel(element), options?.normalizer, options?.exact);\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEO,SAASE,uBAAuBA,CACrCC,OAA0B,EAC1BC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,OAAO,IAAAC,gBAAO,EAACF,aAAa,EAAE,IAAAG,+BAAgB,EAACJ,OAAO,CAAC,EAAEE,OAAO,EAAEG,UAAU,EAAEH,OAAO,EAAEI,KAAK,CAAC;AAC/F","ignoreList":[]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.wrapAsync = wrapAsync;
|
|
7
|
-
var _act =
|
|
7
|
+
var _act = require("../act");
|
|
8
8
|
var _flushMicroTasks = require("../flush-micro-tasks");
|
|
9
|
-
var _reactVersions = require("../react-versions");
|
|
10
|
-
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); }
|
|
11
|
-
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 && {}.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; }
|
|
12
9
|
/* istanbul ignore file */
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,29 +15,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
18
15
|
* @returns Result of the callback
|
|
19
16
|
*/
|
|
20
17
|
async function wrapAsync(callback) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(0, _act.setReactActEnvironment)(previousActEnvironment);
|
|
31
|
-
}
|
|
18
|
+
const previousActEnvironment = (0, _act.getIsReactActEnvironment)();
|
|
19
|
+
(0, _act.setReactActEnvironment)(false);
|
|
20
|
+
try {
|
|
21
|
+
const result = await callback();
|
|
22
|
+
// Flush the microtask queue before restoring the `act` environment
|
|
23
|
+
await (0, _flushMicroTasks.flushMicroTasks)();
|
|
24
|
+
return result;
|
|
25
|
+
} finally {
|
|
26
|
+
(0, _act.setReactActEnvironment)(previousActEnvironment);
|
|
32
27
|
}
|
|
33
|
-
if (!(0, _reactVersions.checkReactVersionAtLeast)(16, 9)) {
|
|
34
|
-
return callback();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Wrapping with act for react version 16.9 to 17.x
|
|
38
|
-
let result;
|
|
39
|
-
await (0, _act.default)(async () => {
|
|
40
|
-
result = await callback();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Either we have result or `callback` threw error
|
|
44
|
-
return result;
|
|
45
28
|
}
|
|
46
29
|
//# sourceMappingURL=wrap-async.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-async.js","names":["_act","
|
|
1
|
+
{"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasks();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,SAASA,CAASC,QAA+B,EAAmB;EACxF,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;EACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;EAE7B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAAC,CAAC;IAC/B;IACA,MAAM,IAAAK,gCAAe,EAAC,CAAC;IACvB,OAAOD,MAAM;EACf,CAAC,SAAS;IACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;EAChD;AACF","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
package/build/index.flow.js
CHANGED
|
@@ -55,10 +55,10 @@ declare type A11yRole =
|
|
|
55
55
|
|
|
56
56
|
declare type A11yState = {|
|
|
57
57
|
disabled?: boolean,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
selected ?: boolean,
|
|
59
|
+
checked ?: boolean | 'mixed',
|
|
60
|
+
busy ?: boolean,
|
|
61
|
+
expanded ?: boolean,
|
|
62
62
|
|};
|
|
63
63
|
|
|
64
64
|
declare type A11yValue = {
|
|
@@ -258,38 +258,6 @@ interface A11yAPI {
|
|
|
258
258
|
queryOptions?: ByRoleOptions,
|
|
259
259
|
waitForOptions?: WaitForOptions
|
|
260
260
|
) => FindAllReturn;
|
|
261
|
-
|
|
262
|
-
// State
|
|
263
|
-
getByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetReturn;
|
|
264
|
-
getAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetAllReturn;
|
|
265
|
-
queryByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryReturn;
|
|
266
|
-
queryAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryAllReturn;
|
|
267
|
-
findByA11yState: (
|
|
268
|
-
matcher: A11yState,
|
|
269
|
-
queryOptions?: CommonQueryOptions,
|
|
270
|
-
waitForOptions?: WaitForOptions
|
|
271
|
-
) => FindReturn;
|
|
272
|
-
findAllByA11yState: (
|
|
273
|
-
matcher: A11yState,
|
|
274
|
-
queryOptions?: CommonQueryOptions,
|
|
275
|
-
waitForOptions?: WaitForOptions
|
|
276
|
-
) => FindAllReturn;
|
|
277
|
-
|
|
278
|
-
// Value
|
|
279
|
-
getByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetReturn;
|
|
280
|
-
getAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetAllReturn;
|
|
281
|
-
queryByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryReturn;
|
|
282
|
-
queryAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryAllReturn;
|
|
283
|
-
findByA11yValue: (
|
|
284
|
-
matcher: A11yValue,
|
|
285
|
-
queryOptions?: CommonQueryOptions,
|
|
286
|
-
waitForOptions?: WaitForOptions
|
|
287
|
-
) => FindReturn;
|
|
288
|
-
findAllByA11yValue: (
|
|
289
|
-
matcher: A11yValue,
|
|
290
|
-
queryOptions?: CommonQueryOptions,
|
|
291
|
-
waitForOptions?: WaitForOptions
|
|
292
|
-
) => FindAllReturn;
|
|
293
261
|
}
|
|
294
262
|
|
|
295
263
|
interface Thenable {
|
|
@@ -308,7 +276,6 @@ type DebugOptions = {
|
|
|
308
276
|
|
|
309
277
|
type Debug = {
|
|
310
278
|
(options?: DebugOptions | string): void,
|
|
311
|
-
shallow: (message?: string) => void,
|
|
312
279
|
};
|
|
313
280
|
|
|
314
281
|
type Queries = ByTextQueries &
|
package/build/index.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.keys(_pure).forEach(function (key) {
|
|
|
16
16
|
});
|
|
17
17
|
var _flushMicroTasks = require("./flush-micro-tasks");
|
|
18
18
|
var _act = require("./act");
|
|
19
|
+
require("./matchers/extend-expect");
|
|
19
20
|
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
20
21
|
// If we're running in a test runner that supports afterEach
|
|
21
22
|
// then we'll automatically run cleanup afterEach test
|
|
@@ -25,7 +26,7 @@ if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
|
25
26
|
if (typeof afterEach === 'function') {
|
|
26
27
|
// eslint-disable-next-line no-undef
|
|
27
28
|
afterEach(async () => {
|
|
28
|
-
await (0, _flushMicroTasks.
|
|
29
|
+
await (0, _flushMicroTasks.flushMicroTasks)();
|
|
29
30
|
(0, _pure.cleanup)();
|
|
30
31
|
});
|
|
31
32
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","flushMicroTasks","cleanup","beforeAll","afterAll","previousIsReactActEnvironment","getIsReactActEnvironment","setReactActEnvironment"],"sources":["../src/index.ts"],"sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { getIsReactActEnvironment, setReactActEnvironment } from './act';\nimport './matchers/extend-expect';\n\nif (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {\n // If we're running in a test runner that supports afterEach\n // then we'll automatically run cleanup afterEach test\n // this ensures that tests run in isolation from each other\n // if you don't like this then either import the `pure` module\n // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\n if (typeof afterEach === 'function') {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasks();\n cleanup();\n });\n }\n\n if (typeof beforeAll === 'function' && typeof afterAll === 'function') {\n // This matches the behavior of React < 18.\n let previousIsReactActEnvironment = getIsReactActEnvironment();\n beforeAll(() => {\n previousIsReactActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(true);\n });\n\n afterAll(() => {\n setReactActEnvironment(previousIsReactActEnvironment);\n });\n }\n}\n\nexport * from './pure';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAiCAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAhCA,IAAAK,gBAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AACAA,OAAA;AAEA,IAAI,CAACW,OAAO,EAAEC,GAAG,EAAEC,sBAAsB,EAAE;EACzC;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;IACnC;IACAA,SAAS,CAAC,YAAY;MACpB,MAAM,IAAAC,gCAAe,EAAC,CAAC;MACvB,IAAAC,aAAO,EAAC,CAAC;IACX,CAAC,CAAC;EACJ;EAEA,IAAI,OAAOC,SAAS,KAAK,UAAU,IAAI,OAAOC,QAAQ,KAAK,UAAU,EAAE;IACrE;IACA,IAAIC,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IAC9DH,SAAS,CAAC,MAAM;MACdE,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;MAC1D,IAAAC,2BAAsB,EAAC,IAAI,CAAC;IAC9B,CAAC,CAAC;IAEFH,QAAQ,CAAC,MAAM;MACb,IAAAG,2BAAsB,EAACF,6BAA6B,CAAC;IACvD,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.ts"],"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":[]}
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.ts"],"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 +1 @@
|
|
|
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.
|
|
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.ts"],"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,MAAA,GAAAH,OAAA;AAEO,SAASI,YAAYA,CAA4BC,OAA0B,EAAE;EAClF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,MAAMG,UAAU,GAAG,IAAAC,kCAAmB,EAACH,OAAO,CAAC,IAAII,kBAAkB,CAACJ,OAAO,CAAC;EAE9E,OAAO;IACLK,IAAI,EAAEH,UAAU;IAChBI,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,eAAe,EAAE,SAAS,EAAE,EAAE,CAAC,EACtE,EAAE,EACF,oBAAoBD,EAAE,YAAY,EAClC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEO,SAASC,WAAWA,CAA4BZ,OAA0B,EAAE;EACjF,IAAAC,uBAAgB,EAACD,OAAO,EAAEY,WAAW,EAAE,IAAI,CAAC;EAE5C,MAAMC,SAAS,GAAG,CAAC,IAAAV,kCAAmB,EAACH,OAAO,CAAC,IAAI,CAACI,kBAAkB,CAACJ,OAAO,CAAC;EAE/E,OAAO;IACLK,IAAI,EAAEQ,SAAS;IACfP,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,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASP,kBAAkBA,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-empty-element.js","names":["_jestMatcherUtils","require","_componentTree","_utils","toBeEmptyElement","element","checkHostElement","hostChildren","getHostChildren","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElementArray","join"],"sources":["../../src/matchers/to-be-empty-element.
|
|
1
|
+
{"version":3,"file":"to-be-empty-element.js","names":["_jestMatcherUtils","require","_componentTree","_utils","toBeEmptyElement","element","checkHostElement","hostChildren","getHostChildren","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElementArray","join"],"sources":["../../src/matchers/to-be-empty-element.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getHostChildren } from '../helpers/component-tree';\nimport { checkHostElement, formatElementArray } from './utils';\n\nexport function toBeEmptyElement(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBeEmptyElement, this);\n\n const hostChildren = getHostChildren(element);\n\n return {\n pass: hostChildren.length === 0,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeEmptyElement`, 'element', ''),\n '',\n 'Received:',\n `${RECEIVED_COLOR(formatElementArray(hostChildren))}`,\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,gBAAgBA,CAA4BC,OAA0B,EAAE;EACtF,IAAAC,uBAAgB,EAACD,OAAO,EAAED,gBAAgB,EAAE,IAAI,CAAC;EAEjD,MAAMG,YAAY,GAAG,IAAAC,8BAAe,EAACH,OAAO,CAAC;EAE7C,OAAO;IACLI,IAAI,EAAEF,YAAY,CAACG,MAAM,KAAK,CAAC;IAC/BC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,mBAAmB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC1E,EAAE,EACF,WAAW,EACX,GAAG,IAAAC,gCAAc,EAAC,IAAAC,yBAAkB,EAACR,YAAY,CAAC,CAAC,EAAE,CACtD,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
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.
|
|
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.ts"],"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,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-on-the-screen.js","names":["_jestMatcherUtils","require","_componentTree","_screen","_utils","toBeOnTheScreen","element","isNot","checkHostElement","pass","screen","UNSAFE_root","getUnsafeRootElement","errorFound","formatElement","errorNotFound","message","matcherHint","RECEIVED_COLOR","join"],"sources":["../../src/matchers/to-be-on-the-screen.
|
|
1
|
+
{"version":3,"file":"to-be-on-the-screen.js","names":["_jestMatcherUtils","require","_componentTree","_screen","_utils","toBeOnTheScreen","element","isNot","checkHostElement","pass","screen","UNSAFE_root","getUnsafeRootElement","errorFound","formatElement","errorNotFound","message","matcherHint","RECEIVED_COLOR","join"],"sources":["../../src/matchers/to-be-on-the-screen.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { getUnsafeRootElement } from '../helpers/component-tree';\nimport { screen } from '../screen';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeOnTheScreen(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeOnTheScreen, this);\n }\n\n const pass = element === null ? false : screen.UNSAFE_root === getUnsafeRootElement(element);\n\n const errorFound = () => {\n return `expected element tree not to contain element, but found\\n${formatElement(element)}`;\n };\n\n const errorNotFound = () => {\n return `element could not be found in the element tree`;\n };\n\n return {\n pass,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeOnTheScreen`, 'element', ''),\n '',\n RECEIVED_COLOR(this.isNot ? errorFound() : errorNotFound()),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,eAAeA,CAA4BC,OAA0B,EAAE;EACrF,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,eAAe,EAAE,IAAI,CAAC;EAClD;EAEA,MAAMI,IAAI,GAAGH,OAAO,KAAK,IAAI,GAAG,KAAK,GAAGI,cAAM,CAACC,WAAW,KAAK,IAAAC,mCAAoB,EAACN,OAAO,CAAC;EAE5F,MAAMO,UAAU,GAAGA,CAAA,KAAM;IACvB,OAAO,4DAA4D,IAAAC,oBAAa,EAACR,OAAO,CAAC,EAAE;EAC7F,CAAC;EAED,MAAMS,aAAa,GAAGA,CAAA,KAAM;IAC1B,OAAO,gDAAgD;EACzD,CAAC;EAED,OAAO;IACLN,IAAI;IACJO,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACV,KAAK,GAAG,MAAM,GAAG,EAAE,kBAAkB,EAAE,SAAS,EAAE,EAAE,CAAC,EACzE,EAAE,EACF,IAAAW,gCAAc,EAAC,IAAI,CAACX,KAAK,GAAGM,UAAU,CAAC,CAAC,GAAGE,aAAa,CAAC,CAAC,CAAC,CAC5D,CAACI,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-partially-checked.js","names":["_jestMatcherUtils","require","_accessibility","_errors","_utils","toBePartiallyChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","computeAriaChecked","message","is","isNot","matcherHint","formatElement","join","role","getRole","isAccessibilityElement"],"sources":["../../src/matchers/to-be-partially-checked.
|
|
1
|
+
{"version":3,"file":"to-be-partially-checked.js","names":["_jestMatcherUtils","require","_accessibility","_errors","_utils","toBePartiallyChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","computeAriaChecked","message","is","isNot","matcherHint","formatElement","join","role","getRole","isAccessibilityElement"],"sources":["../../src/matchers/to-be-partially-checked.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { computeAriaChecked, getRole, isAccessibilityElement } from '../helpers/accessibility';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBePartiallyChecked(this: jest.MatcherContext, element: ReactTestInstance) {\n checkHostElement(element, toBePartiallyChecked, this);\n\n if (!hasValidAccessibilityRole(element)) {\n throw new ErrorWithStack(\n 'toBePartiallyChecked() works only on accessibility elements with \"checkbox\" role.',\n toBePartiallyChecked,\n );\n }\n\n return {\n pass: computeAriaChecked(element) === 'mixed',\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBePartiallyChecked`, 'element', ''),\n '',\n `Received element ${is} partially checked:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction hasValidAccessibilityRole(element: ReactTestInstance) {\n const role = getRole(element);\n return isAccessibilityElement(element) && role === 'checkbox';\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,oBAAoBA,CAA4BC,OAA0B,EAAE;EAC1F,IAAAC,uBAAgB,EAACD,OAAO,EAAED,oBAAoB,EAAE,IAAI,CAAC;EAErD,IAAI,CAACG,yBAAyB,CAACF,OAAO,CAAC,EAAE;IACvC,MAAM,IAAIG,sBAAc,CACtB,mFAAmF,EACnFJ,oBACF,CAAC;EACH;EAEA,OAAO;IACLK,IAAI,EAAE,IAAAC,iCAAkB,EAACL,OAAO,CAAC,KAAK,OAAO;IAC7CM,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,uBAAuB,EAAE,SAAS,EAAE,EAAE,CAAC,EAC9E,EAAE,EACF,oBAAoBD,EAAE,qBAAqB,EAC3C,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAAST,yBAAyBA,CAACF,OAA0B,EAAE;EAC7D,MAAMY,IAAI,GAAG,IAAAC,sBAAO,EAACb,OAAO,CAAC;EAC7B,OAAO,IAAAc,qCAAsB,EAACd,OAAO,CAAC,IAAIY,IAAI,KAAK,UAAU;AAC/D","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessibility","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","flatStyle","StyleSheet","flatten","style","display","opacity"],"sources":["../../src/matchers/to-be-visible.
|
|
1
|
+
{"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessibility","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","flatStyle","StyleSheet","flatten","style","display","opacity"],"sources":["../../src/matchers/to-be-visible.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessibility';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(this: jest.MatcherContext, element: ReactTestInstance) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeVisible, this);\n }\n\n return {\n pass: isElementVisible(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeVisible`, 'element', ''),\n '',\n `Received element ${is} visible:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction isElementVisible(\n element: ReactTestInstance,\n accessibilityCache?: WeakMap<ReactTestInstance, boolean>,\n): boolean {\n // Use cache to speed up repeated searches by `isHiddenFromAccessibility`.\n const cache = accessibilityCache ?? new WeakMap<ReactTestInstance, boolean>();\n if (isHiddenFromAccessibility(element, { cache })) {\n return false;\n }\n\n if (isHiddenForStyles(element)) {\n return false;\n }\n\n // Note: this seems to be a bug in React Native.\n // PR with fix: https://github.com/facebook/react-native/pull/39157\n if (isHostModal(element) && element.props.visible === false) {\n return false;\n }\n\n const hostParent = getHostParent(element);\n if (hostParent === null) {\n return true;\n }\n\n return isElementVisible(hostParent, cache);\n}\n\nfunction isHiddenForStyles(element: ReactTestInstance) {\n const flatStyle = StyleSheet.flatten(element.props.style);\n return flatStyle?.display === 'none' || flatStyle?.opacity === 0;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,WAAWA,CAA4BC,OAA0B,EAAE;EACjF,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAC9C;EAEA,OAAO;IACLI,IAAI,EAAEC,gBAAgB,CAACJ,OAAO,CAAC;IAC/BK,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACL,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAM,6BAAW,EAAC,GAAG,IAAI,CAACN,KAAK,GAAG,MAAM,GAAG,EAAE,cAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACF,oBAAoBK,EAAE,WAAW,EACjC,IAAAE,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASL,gBAAgBA,CACvBJ,OAA0B,EAC1BU,kBAAwD,EAC/C;EACT;EACA,MAAMC,KAAK,GAAGD,kBAAkB,IAAI,IAAIE,OAAO,CAA6B,CAAC;EAC7E,IAAI,IAAAC,wCAAyB,EAACb,OAAO,EAAE;IAAEW;EAAM,CAAC,CAAC,EAAE;IACjD,OAAO,KAAK;EACd;EAEA,IAAIG,iBAAiB,CAACd,OAAO,CAAC,EAAE;IAC9B,OAAO,KAAK;EACd;;EAEA;EACA;EACA,IAAI,IAAAe,+BAAW,EAACf,OAAO,CAAC,IAAIA,OAAO,CAACgB,KAAK,CAACC,OAAO,KAAK,KAAK,EAAE;IAC3D,OAAO,KAAK;EACd;EAEA,MAAMC,UAAU,GAAG,IAAAC,4BAAa,EAACnB,OAAO,CAAC;EACzC,IAAIkB,UAAU,KAAK,IAAI,EAAE;IACvB,OAAO,IAAI;EACb;EAEA,OAAOd,gBAAgB,CAACc,UAAU,EAAEP,KAAK,CAAC;AAC5C;AAEA,SAASG,iBAAiBA,CAACd,OAA0B,EAAE;EACrD,MAAMoB,SAAS,GAAGC,uBAAU,CAACC,OAAO,CAACtB,OAAO,CAACgB,KAAK,CAACO,KAAK,CAAC;EACzD,OAAOH,SAAS,EAAEI,OAAO,KAAK,MAAM,IAAIJ,SAAS,EAAEK,OAAO,KAAK,CAAC;AAClE","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-contain-element.js","names":["_jestMatcherUtils","require","_utils","toContainElement","container","element","checkHostElement","matches","findAll","node","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElement","join"],"sources":["../../src/matchers/to-contain-element.
|
|
1
|
+
{"version":3,"file":"to-contain-element.js","names":["_jestMatcherUtils","require","_utils","toContainElement","container","element","checkHostElement","matches","findAll","node","pass","length","message","matcherHint","isNot","RECEIVED_COLOR","formatElement","join"],"sources":["../../src/matchers/to-contain-element.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, RECEIVED_COLOR } from 'jest-matcher-utils';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toContainElement(\n this: jest.MatcherContext,\n container: ReactTestInstance,\n element: ReactTestInstance | null,\n) {\n checkHostElement(container, toContainElement, this);\n\n if (element !== null) {\n checkHostElement(element, toContainElement, this);\n }\n\n let matches: ReactTestInstance[] = [];\n if (element) {\n matches = container.findAll((node) => node === element);\n }\n\n return {\n pass: matches.length > 0,\n message: () => {\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toContainElement`, 'container', 'element'),\n '',\n RECEIVED_COLOR(`${formatElement(container)} ${\n this.isNot ? '\\n\\ncontains:\\n\\n' : '\\n\\ndoes not contain:\\n\\n'\n } ${formatElement(element)}\n `),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,gBAAgBA,CAE9BC,SAA4B,EAC5BC,OAAiC,EACjC;EACA,IAAAC,uBAAgB,EAACF,SAAS,EAAED,gBAAgB,EAAE,IAAI,CAAC;EAEnD,IAAIE,OAAO,KAAK,IAAI,EAAE;IACpB,IAAAC,uBAAgB,EAACD,OAAO,EAAEF,gBAAgB,EAAE,IAAI,CAAC;EACnD;EAEA,IAAII,OAA4B,GAAG,EAAE;EACrC,IAAIF,OAAO,EAAE;IACXE,OAAO,GAAGH,SAAS,CAACI,OAAO,CAAEC,IAAI,IAAKA,IAAI,KAAKJ,OAAO,CAAC;EACzD;EAEA,OAAO;IACLK,IAAI,EAAEH,OAAO,CAACI,MAAM,GAAG,CAAC;IACxBC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EAAC,GAAG,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAE,mBAAmB,EAAE,WAAW,EAAE,SAAS,CAAC,EACnF,EAAE,EACF,IAAAC,gCAAc,EAAC,GAAG,IAAAC,oBAAa,EAACZ,SAAS,CAAC,IACxC,IAAI,CAACU,KAAK,GAAG,mBAAmB,GAAG,2BAA2B,IAC5D,IAAAE,oBAAa,EAACX,OAAO,CAAC;AAClC,SAAS,CAAC,CACH,CAACY,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH","ignoreList":[]}
|