@testing-library/react-native 12.2.2 → 12.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/act.js +1 -2
- package/build/act.js.map +1 -1
- package/build/config.d.ts +2 -0
- package/build/config.js.map +1 -1
- package/build/fireEvent.js +3 -3
- package/build/fireEvent.js.map +1 -1
- package/build/helpers/accessiblity.d.ts +11 -0
- package/build/helpers/accessiblity.js +108 -8
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.d.ts +7 -0
- package/build/helpers/component-tree.js +18 -0
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/format-default.d.ts +1 -2
- package/build/helpers/format-default.js +22 -13
- package/build/helpers/format-default.js.map +1 -1
- package/build/helpers/format.js +4 -8
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +10 -0
- package/build/helpers/host-component-names.js +27 -3
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/accessibilityState.js +3 -3
- package/build/helpers/matchers/accessibilityState.js.map +1 -1
- package/build/helpers/matchers/accessibilityValue.js +3 -2
- package/build/helpers/matchers/accessibilityValue.js.map +1 -1
- package/build/helpers/matchers/matchLabelText.d.ts +1 -1
- package/build/helpers/matchers/matchLabelText.js +5 -8
- package/build/helpers/matchers/matchLabelText.js.map +1 -1
- package/build/helpers/matchers/matchTextContent.js +2 -2
- package/build/helpers/matchers/matchTextContent.js.map +1 -1
- package/build/helpers/object.d.ts +1 -0
- package/build/helpers/object.js +16 -0
- package/build/helpers/object.js.map +1 -0
- package/build/helpers/{getTextContent.js → text-content.js} +1 -1
- package/build/helpers/text-content.js.map +1 -0
- package/build/helpers/text-input.d.ts +3 -0
- package/build/helpers/text-input.js +21 -0
- package/build/helpers/text-input.js.map +1 -0
- package/build/helpers/wrap-async.d.ts +7 -0
- package/build/helpers/wrap-async.js +45 -0
- package/build/helpers/wrap-async.js.map +1 -0
- package/build/matchers/extend-expect.d.js +2 -0
- package/build/matchers/extend-expect.d.js.map +1 -0
- package/build/matchers/extend-expect.d.ts +2 -0
- package/build/matchers/extend-expect.js +38 -0
- package/build/matchers/extend-expect.js.map +1 -0
- package/build/matchers/index.d.ts +15 -0
- package/build/matchers/index.js +117 -0
- package/build/matchers/index.js.map +1 -0
- package/build/matchers/to-be-busy.d.ts +6 -0
- package/build/matchers/to-be-busy.js +20 -0
- package/build/matchers/to-be-busy.js.map +1 -0
- package/build/matchers/to-be-checked.d.ts +6 -0
- package/build/matchers/to-be-checked.js +31 -0
- package/build/matchers/to-be-checked.js.map +1 -0
- package/build/matchers/to-be-collapsed.d.ts +6 -0
- package/build/matchers/to-be-collapsed.js +20 -0
- package/build/matchers/to-be-collapsed.js.map +1 -0
- package/build/matchers/to-be-disabled.d.ts +10 -0
- package/build/matchers/to-be-disabled.js +52 -0
- package/build/matchers/to-be-disabled.js.map +1 -0
- package/build/matchers/to-be-empty-element.d.ts +6 -0
- package/build/matchers/to-be-empty-element.js +20 -0
- package/build/matchers/to-be-empty-element.js.map +1 -0
- package/build/matchers/to-be-expanded.d.ts +6 -0
- package/build/matchers/to-be-expanded.js +20 -0
- package/build/matchers/to-be-expanded.js.map +1 -0
- package/build/matchers/to-be-on-the-screen.d.ts +6 -0
- package/build/matchers/to-be-on-the-screen.js +29 -0
- package/build/matchers/to-be-on-the-screen.js.map +1 -0
- package/build/matchers/to-be-partially-checked.d.ts +6 -0
- package/build/matchers/to-be-partially-checked.js +28 -0
- package/build/matchers/to-be-partially-checked.js.map +1 -0
- package/build/matchers/to-be-selected.d.ts +6 -0
- package/build/matchers/to-be-selected.js +20 -0
- package/build/matchers/to-be-selected.js.map +1 -0
- package/build/matchers/to-be-visible.d.ts +6 -0
- package/build/matchers/to-be-visible.js +56 -0
- package/build/matchers/to-be-visible.js.map +1 -0
- package/build/matchers/to-contain-element.d.ts +6 -0
- package/build/matchers/to-contain-element.js +26 -0
- package/build/matchers/to-contain-element.js.map +1 -0
- package/build/matchers/to-have-display-value.d.ts +7 -0
- package/build/matchers/to-have-display-value.js +26 -0
- package/build/matchers/to-have-display-value.js.map +1 -0
- package/build/matchers/to-have-prop.d.ts +6 -0
- package/build/matchers/to-have-prop.js +35 -0
- package/build/matchers/to-have-prop.js.map +1 -0
- package/build/matchers/to-have-style.d.ts +8 -0
- package/build/matchers/to-have-style.js +52 -0
- package/build/matchers/to-have-style.js.map +1 -0
- package/build/matchers/to-have-text-content.d.ts +7 -0
- package/build/matchers/to-have-text-content.js +21 -0
- package/build/matchers/to-have-text-content.js.map +1 -0
- package/build/matchers/utils.d.ts +18 -0
- package/build/matchers/utils.js +90 -0
- package/build/matchers/utils.js.map +1 -0
- package/build/matches.d.ts +1 -1
- package/build/matches.js.map +1 -1
- package/build/queries/displayValue.js +4 -3
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/labelText.js +2 -2
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/role.js +1 -1
- package/build/queries/role.js.map +1 -1
- package/build/react-versions.js +2 -2
- package/build/react-versions.js.map +1 -1
- package/build/render.d.ts +12 -48
- package/build/render.js +5 -4
- package/build/render.js.map +1 -1
- package/build/screen.js +1 -2
- package/build/screen.js.map +1 -1
- package/build/shallow.js +2 -2
- package/build/shallow.js.map +1 -1
- package/build/test-utils/events.d.ts +1 -2
- package/build/test-utils/events.js.map +1 -1
- package/build/user-event/clear.js +2 -1
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/common.js +1 -2
- package/build/user-event/event-builder/common.js.map +1 -1
- package/build/user-event/event-builder/index.d.ts +30 -0
- package/build/user-event/event-builder/index.js +3 -2
- package/build/user-event/event-builder/index.js.map +1 -1
- package/build/user-event/event-builder/scroll-view.d.ts +42 -0
- package/build/user-event/event-builder/scroll-view.js +52 -0
- package/build/user-event/event-builder/scroll-view.js.map +1 -0
- package/build/user-event/event-builder/text-input.js +1 -2
- package/build/user-event/event-builder/text-input.js.map +1 -1
- package/build/user-event/index.d.ts +2 -0
- package/build/user-event/index.js +3 -3
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/press/constants.js +2 -4
- package/build/user-event/press/constants.js.map +1 -1
- package/build/user-event/press/press.js +11 -14
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/index.d.ts +1 -0
- package/build/user-event/scroll/index.js +19 -0
- package/build/user-event/scroll/index.js.map +1 -0
- package/build/user-event/scroll/scrollTo.d.ts +16 -0
- package/build/user-event/scroll/scrollTo.js +82 -0
- package/build/user-event/scroll/scrollTo.js.map +1 -0
- package/build/user-event/scroll/state.d.ts +4 -0
- package/build/user-event/scroll/state.js +18 -0
- package/build/user-event/scroll/state.js.map +1 -0
- package/build/user-event/scroll/utils.d.ts +20 -0
- package/build/user-event/scroll/utils.js +68 -0
- package/build/user-event/scroll/utils.js.map +1 -0
- package/build/user-event/setup/setup.d.ts +8 -0
- package/build/user-event/setup/setup.js +34 -6
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.js +2 -1
- package/build/user-event/type/type.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/waitFor.js +2 -26
- package/build/waitFor.js.map +1 -1
- package/build/within.js +1 -2
- package/build/within.js.map +1 -1
- package/package.json +23 -37
- package/build/helpers/getTextContent.js.map +0 -1
- package/build/user-event/utils/host-components.d.ts +0 -2
- package/build/user-event/utils/host-components.js +0 -11
- package/build/user-event/utils/host-components.js.map +0 -1
- /package/build/helpers/{getTextContent.d.ts → text-content.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-busy.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeBusy","element","checkHostElement","pass","isElementBusy","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 { isElementBusy } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeBusy(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeBusy, this);\n\n return {\n pass: isElementBusy(element),\n message: () => {\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toBeBusy`,\n 'element',\n ''\n );\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,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,QAAQA,CAEtBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,QAAQ,EAAE,IAAI,CAAC;EAEzC,OAAO;IACLG,IAAI,EAAE,IAAAC,2BAAa,EAACH,OAAO,CAAC;IAC5BI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,WAAU,EACtC,SAAS,EACT,EACF,CAAC;MACD,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,OAAM,EACtD,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeChecked = toBeChecked;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
9
|
+
var _errors = require("../helpers/errors");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function toBeChecked(element) {
|
|
12
|
+
(0, _utils.checkHostElement)(element, toBeChecked, this);
|
|
13
|
+
if (!hasValidAccessibilityRole(element)) {
|
|
14
|
+
throw new _errors.ErrorWithStack(`toBeChecked() works only on accessibility elements with "checkbox" or "radio" role.`, toBeChecked);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
pass: (0, _accessiblity.getAccessibilityCheckedState)(element) === true,
|
|
18
|
+
message: () => {
|
|
19
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
20
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeChecked`, 'element', ''), '', `Received element ${is} checked:`, (0, _utils.formatElement)(element)].join('\n');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function hasValidAccessibilityRole(element) {
|
|
25
|
+
if (!(0, _accessiblity.isAccessibilityElement)(element)) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
const role = (0, _accessiblity.getAccessibilityRole)(element);
|
|
29
|
+
return role === 'checkbox' || role === 'radio';
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=to-be-checked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBeChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","isAccessibilityElement","role","getAccessibilityRole"],"sources":["../../src/matchers/to-be-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeChecked(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeChecked, this);\n\n if (!hasValidAccessibilityRole(element)) {\n throw new ErrorWithStack(\n `toBeChecked() works only on accessibility elements with \"checkbox\" or \"radio\" role.`,\n toBeChecked\n );\n }\n\n return {\n pass: getAccessibilityCheckedState(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 hasValidAccessibilityRole(element: ReactTestInstance) {\n if (!isAccessibilityElement(element)) {\n return false;\n }\n\n const role = getAccessibilityRole(element);\n return role === 'checkbox' || role === 'radio';\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,WAAWA,CAEzBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,WAAW,EAAE,IAAI,CAAC;EAE5C,IAAI,CAACG,yBAAyB,CAACF,OAAO,CAAC,EAAE;IACvC,MAAM,IAAIG,sBAAc,CACrB,qFAAoF,EACrFJ,WACF,CAAC;EACH;EAEA,OAAO;IACLK,IAAI,EAAE,IAAAC,0CAA4B,EAACL,OAAO,CAAC,KAAK,IAAI;IACpDM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAAST,yBAAyBA,CAACF,OAA0B,EAAE;EAC7D,IAAI,CAAC,IAAAY,oCAAsB,EAACZ,OAAO,CAAC,EAAE;IACpC,OAAO,KAAK;EACd;EAEA,MAAMa,IAAI,GAAG,IAAAC,kCAAoB,EAACd,OAAO,CAAC;EAC1C,OAAOa,IAAI,KAAK,UAAU,IAAIA,IAAI,KAAK,OAAO;AAChD"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeCollapsed = toBeCollapsed;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function toBeCollapsed(element) {
|
|
11
|
+
(0, _utils.checkHostElement)(element, toBeCollapsed, this);
|
|
12
|
+
return {
|
|
13
|
+
pass: (0, _accessiblity.isElementCollapsed)(element),
|
|
14
|
+
message: () => {
|
|
15
|
+
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeCollapsed`, 'element', '');
|
|
16
|
+
return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}collapsed:`, (0, _utils.formatElement)(element)].join('\n');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=to-be-collapsed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-collapsed.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeCollapsed","element","checkHostElement","pass","isElementCollapsed","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-collapsed.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementCollapsed } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeCollapsed(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeCollapsed, this);\n\n return {\n pass: isElementCollapsed(element),\n message: () => {\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toBeCollapsed`,\n 'element',\n ''\n );\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,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,aAAaA,CAE3BC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,aAAa,EAAE,IAAI,CAAC;EAE9C,OAAO;IACLG,IAAI,EAAE,IAAAC,gCAAkB,EAACH,OAAO,CAAC;IACjCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,gBAAe,EAC3C,SAAS,EACT,EACF,CAAC;MACD,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,YAAW,EAC3D,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
export declare function toBeDisabled(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
4
|
+
pass: any;
|
|
5
|
+
message: () => string;
|
|
6
|
+
};
|
|
7
|
+
export declare function toBeEnabled(this: jest.MatcherContext, element: ReactTestInstance): {
|
|
8
|
+
pass: boolean;
|
|
9
|
+
message: () => string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeDisabled = toBeDisabled;
|
|
7
|
+
exports.toBeEnabled = toBeEnabled;
|
|
8
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
9
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
10
|
+
var _textInput = require("../helpers/text-input");
|
|
11
|
+
var _componentTree = require("../helpers/component-tree");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
function toBeDisabled(element) {
|
|
14
|
+
(0, _utils.checkHostElement)(element, toBeDisabled, this);
|
|
15
|
+
const isDisabled = isElementDisabled(element) || isAncestorDisabled(element);
|
|
16
|
+
return {
|
|
17
|
+
pass: isDisabled,
|
|
18
|
+
message: () => {
|
|
19
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
20
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeDisabled`, 'element', ''), '', `Received element ${is} disabled:`, (0, _utils.formatElement)(element)].join('\n');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function toBeEnabled(element) {
|
|
25
|
+
(0, _utils.checkHostElement)(element, toBeEnabled, this);
|
|
26
|
+
const isEnabled = !isElementDisabled(element) && !isAncestorDisabled(element);
|
|
27
|
+
return {
|
|
28
|
+
pass: isEnabled,
|
|
29
|
+
message: () => {
|
|
30
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
31
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeEnabled`, 'element', ''), '', `Received element ${is} enabled:`, (0, _utils.formatElement)(element)].join('\n');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
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
|
+
function isAncestorDisabled(element) {
|
|
46
|
+
const parent = (0, _componentTree.getHostParent)(element);
|
|
47
|
+
if (parent == null) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
return isElementDisabled(parent) || isAncestorDisabled(parent);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=to-be-disabled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-disabled.js","names":["_jestMatcherUtils","require","_hostComponentNames","_textInput","_componentTree","_utils","toBeDisabled","element","checkHostElement","isDisabled","isElementDisabled","isAncestorDisabled","pass","message","is","isNot","matcherHint","formatElement","join","toBeEnabled","isEnabled","isHostTextInput","isTextInputEditable","accessibilityState","ariaDisabled","props","disabled","parent","getHostParent"],"sources":["../../src/matchers/to-be-disabled.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isTextInputEditable } from '../helpers/text-input';\nimport { getHostParent } from '../helpers/component-tree';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeDisabled(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeDisabled, this);\n\n const isDisabled = isElementDisabled(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(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeEnabled, this);\n\n const isEnabled = !isElementDisabled(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 isElementDisabled(element: ReactTestInstance) {\n if (isHostTextInput(element) && !isTextInputEditable(element)) {\n return true;\n }\n\n const { accessibilityState, 'aria-disabled': ariaDisabled } = element.props;\n return ariaDisabled ?? accessibilityState?.disabled ?? false;\n}\n\nfunction isAncestorDisabled(element: ReactTestInstance): boolean {\n const parent = getHostParent(element);\n if (parent == null) {\n return false;\n }\n\n return isElementDisabled(parent) || isAncestorDisabled(parent);\n}\n"],"mappings":";;;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEO,SAASK,YAAYA,CAE1BC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,MAAMG,UAAU,GAAGC,iBAAiB,CAACH,OAAO,CAAC,IAAII,kBAAkB,CAACJ,OAAO,CAAC;EAE5E,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,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACtE,EAAE,EACD,oBAAmBD,EAAG,YAAW,EAClC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEO,SAASC,WAAWA,CAEzBZ,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAEY,WAAW,EAAE,IAAI,CAAC;EAE5C,MAAMC,SAAS,GAAG,CAACV,iBAAiB,CAACH,OAAO,CAAC,IAAI,CAACI,kBAAkB,CAACJ,OAAO,CAAC;EAE7E,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,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACV,OAAO,CAAC,CACvB,CAACW,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH;AAEA,SAASR,iBAAiBA,CAACH,OAA0B,EAAE;EACrD,IAAI,IAAAc,mCAAe,EAACd,OAAO,CAAC,IAAI,CAAC,IAAAe,8BAAmB,EAACf,OAAO,CAAC,EAAE;IAC7D,OAAO,IAAI;EACb;EAEA,MAAM;IAAEgB,kBAAkB;IAAE,eAAe,EAAEC;EAAa,CAAC,GAAGjB,OAAO,CAACkB,KAAK;EAC3E,OAAOD,YAAY,IAAID,kBAAkB,EAAEG,QAAQ,IAAI,KAAK;AAC9D;AAEA,SAASf,kBAAkBA,CAACJ,OAA0B,EAAW;EAC/D,MAAMoB,MAAM,GAAG,IAAAC,4BAAa,EAACrB,OAAO,CAAC;EACrC,IAAIoB,MAAM,IAAI,IAAI,EAAE;IAClB,OAAO,KAAK;EACd;EAEA,OAAOjB,iBAAiB,CAACiB,MAAM,CAAC,IAAIhB,kBAAkB,CAACgB,MAAM,CAAC;AAChE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeEmptyElement = toBeEmptyElement;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _componentTree = require("../helpers/component-tree");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function toBeEmptyElement(element) {
|
|
11
|
+
(0, _utils.checkHostElement)(element, toBeEmptyElement, this);
|
|
12
|
+
const hostChildren = (0, _componentTree.getHostChildren)(element);
|
|
13
|
+
return {
|
|
14
|
+
pass: hostChildren.length === 0,
|
|
15
|
+
message: () => {
|
|
16
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeEmptyElement`, 'element', ''), '', 'Received:', `${(0, _jestMatcherUtils.RECEIVED_COLOR)((0, _utils.formatElementArray)(hostChildren))}`].join('\n');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=to-be-empty-element.js.map
|
|
@@ -0,0 +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.tsx"],"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(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\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(\n `${this.isNot ? '.not' : ''}.toBeEmptyElement`,\n 'element',\n ''\n ),\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,CAE9BC,OAA0B,EAC1B;EACA,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,EACR,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,mBAAkB,EAC9C,SAAS,EACT,EACF,CAAC,EACD,EAAE,EACF,WAAW,EACV,GAAE,IAAAC,gCAAc,EAAC,IAAAC,yBAAkB,EAACR,YAAY,CAAC,CAAE,EAAC,CACtD,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeExpanded = toBeExpanded;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function toBeExpanded(element) {
|
|
11
|
+
(0, _utils.checkHostElement)(element, toBeExpanded, this);
|
|
12
|
+
return {
|
|
13
|
+
pass: (0, _accessiblity.isElementExpanded)(element),
|
|
14
|
+
message: () => {
|
|
15
|
+
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeExpanded`, 'element', '');
|
|
16
|
+
return [matcher, '', `Received element is ${this.isNot ? '' : 'not '}expanded:`, (0, _utils.formatElement)(element)].join('\n');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=to-be-expanded.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-expanded.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeExpanded","element","checkHostElement","pass","isElementExpanded","message","matcher","matcherHint","isNot","formatElement","join"],"sources":["../../src/matchers/to-be-expanded.tsx"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementExpanded } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeExpanded(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeExpanded, this);\n\n return {\n pass: isElementExpanded(element),\n message: () => {\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toBeExpanded`,\n 'element',\n ''\n );\n return [\n matcher,\n '',\n `Received element is ${this.isNot ? '' : 'not '}expanded:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAE1BC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,OAAO;IACLG,IAAI,EAAE,IAAAC,+BAAiB,EAACH,OAAO,CAAC;IAChCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAC1C,SAAS,EACT,EACF,CAAC;MACD,OAAO,CACLF,OAAO,EACP,EAAE,EACD,uBAAsB,IAAI,CAACE,KAAK,GAAG,EAAE,GAAG,MAAO,WAAU,EAC1D,IAAAC,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeOnTheScreen = toBeOnTheScreen;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _componentTree = require("../helpers/component-tree");
|
|
9
|
+
var _screen = require("../screen");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function toBeOnTheScreen(element) {
|
|
12
|
+
if (element !== null || !this.isNot) {
|
|
13
|
+
(0, _utils.checkHostElement)(element, toBeOnTheScreen, this);
|
|
14
|
+
}
|
|
15
|
+
const pass = element === null ? false : _screen.screen.UNSAFE_root === (0, _componentTree.getUnsafeRootElement)(element);
|
|
16
|
+
const errorFound = () => {
|
|
17
|
+
return `expected element tree not to contain element, but found\n${(0, _utils.formatElement)(element)}`;
|
|
18
|
+
};
|
|
19
|
+
const errorNotFound = () => {
|
|
20
|
+
return `element could not be found in the element tree`;
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
pass,
|
|
24
|
+
message: () => {
|
|
25
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeOnTheScreen`, 'element', ''), '', (0, _jestMatcherUtils.RECEIVED_COLOR)(this.isNot ? errorFound() : errorNotFound())].join('\n');
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=to-be-on-the-screen.js.map
|
|
@@ -0,0 +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.tsx"],"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(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n if (element !== null || !this.isNot) {\n checkHostElement(element, toBeOnTheScreen, this);\n }\n\n const pass =\n element === null\n ? false\n : screen.UNSAFE_root === getUnsafeRootElement(element);\n\n const errorFound = () => {\n return `expected element tree not to contain element, but found\\n${formatElement(\n element\n )}`;\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(\n `${this.isNot ? '.not' : ''}.toBeOnTheScreen`,\n 'element',\n ''\n ),\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,CAE7BC,OAA0B,EAC1B;EACA,IAAIA,OAAO,KAAK,IAAI,IAAI,CAAC,IAAI,CAACC,KAAK,EAAE;IACnC,IAAAC,uBAAgB,EAACF,OAAO,EAAED,eAAe,EAAE,IAAI,CAAC;EAClD;EAEA,MAAMI,IAAI,GACRH,OAAO,KAAK,IAAI,GACZ,KAAK,GACLI,cAAM,CAACC,WAAW,KAAK,IAAAC,mCAAoB,EAACN,OAAO,CAAC;EAE1D,MAAMO,UAAU,GAAGA,CAAA,KAAM;IACvB,OAAQ,4DAA2D,IAAAC,oBAAa,EAC9ER,OACF,CAAE,EAAC;EACL,CAAC;EAED,MAAMS,aAAa,GAAGA,CAAA,KAAM;IAC1B,OAAQ,gDAA+C;EACzD,CAAC;EAED,OAAO;IACLN,IAAI;IACJO,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,6BAAW,EACR,GAAE,IAAI,CAACV,KAAK,GAAG,MAAM,GAAG,EAAG,kBAAiB,EAC7C,SAAS,EACT,EACF,CAAC,EACD,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBePartiallyChecked = toBePartiallyChecked;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
9
|
+
var _errors = require("../helpers/errors");
|
|
10
|
+
var _utils = require("./utils");
|
|
11
|
+
function toBePartiallyChecked(element) {
|
|
12
|
+
(0, _utils.checkHostElement)(element, toBePartiallyChecked, this);
|
|
13
|
+
if (!hasValidAccessibilityRole(element)) {
|
|
14
|
+
throw new _errors.ErrorWithStack('toBePartiallyChecked() works only on accessibility elements with "checkbox" role.', toBePartiallyChecked);
|
|
15
|
+
}
|
|
16
|
+
return {
|
|
17
|
+
pass: (0, _accessiblity.getAccessibilityCheckedState)(element) === 'mixed',
|
|
18
|
+
message: () => {
|
|
19
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
20
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBePartiallyChecked`, 'element', ''), '', `Received element ${is} partially checked:`, (0, _utils.formatElement)(element)].join('\n');
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function hasValidAccessibilityRole(element) {
|
|
25
|
+
const role = (0, _accessiblity.getAccessibilityRole)(element);
|
|
26
|
+
return (0, _accessiblity.isAccessibilityElement)(element) && role === 'checkbox';
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=to-be-partially-checked.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-partially-checked.js","names":["_jestMatcherUtils","require","_accessiblity","_errors","_utils","toBePartiallyChecked","element","checkHostElement","hasValidAccessibilityRole","ErrorWithStack","pass","getAccessibilityCheckedState","message","is","isNot","matcherHint","formatElement","join","role","getAccessibilityRole","isAccessibilityElement"],"sources":["../../src/matchers/to-be-partially-checked.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport {\n getAccessibilityCheckedState,\n getAccessibilityRole,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBePartiallyChecked(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\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: getAccessibilityCheckedState(element) === 'mixed',\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(\n `${this.isNot ? '.not' : ''}.toBePartiallyChecked`,\n 'element',\n ''\n ),\n '',\n `Received element ${is} partially checked:`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n\nfunction hasValidAccessibilityRole(element: ReactTestInstance) {\n const role = getAccessibilityRole(element);\n return isAccessibilityElement(element) && role === 'checkbox';\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,SAASI,oBAAoBA,CAElCC,OAA0B,EAC1B;EACA,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,0CAA4B,EAACL,OAAO,CAAC,KAAK,OAAO;IACvDM,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EACR,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,uBAAsB,EAClD,SAAS,EACT,EACF,CAAC,EACD,EAAE,EACD,oBAAmBD,EAAG,qBAAoB,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,kCAAoB,EAACb,OAAO,CAAC;EAC1C,OAAO,IAAAc,oCAAsB,EAACd,OAAO,CAAC,IAAIY,IAAI,KAAK,UAAU;AAC/D"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeSelected = toBeSelected;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
function toBeSelected(element) {
|
|
11
|
+
(0, _utils.checkHostElement)(element, toBeSelected, this);
|
|
12
|
+
return {
|
|
13
|
+
pass: (0, _accessiblity.isElementSelected)(element),
|
|
14
|
+
message: () => {
|
|
15
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
16
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeSelected`, 'element', ''), '', `Received element ${is} selected`, (0, _utils.formatElement)(element)].join('\n');
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=to-be-selected.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-selected.js","names":["_jestMatcherUtils","require","_accessiblity","_utils","toBeSelected","element","checkHostElement","pass","isElementSelected","message","is","isNot","matcherHint","formatElement","join"],"sources":["../../src/matchers/to-be-selected.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isElementSelected } from '../helpers/accessiblity';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeSelected(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\n checkHostElement(element, toBeSelected, this);\n\n return {\n pass: isElementSelected(element),\n message: () => {\n const is = this.isNot ? 'is' : 'is not';\n return [\n matcherHint(`${this.isNot ? '.not' : ''}.toBeSelected`, 'element', ''),\n '',\n `Received element ${is} selected`,\n formatElement(element),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEO,SAASG,YAAYA,CAE1BC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACD,OAAO,EAAED,YAAY,EAAE,IAAI,CAAC;EAE7C,OAAO;IACLG,IAAI,EAAE,IAAAC,+BAAiB,EAACH,OAAO,CAAC;IAChCI,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,IAAI,GAAG,QAAQ;MACvC,OAAO,CACL,IAAAC,6BAAW,EAAE,GAAE,IAAI,CAACD,KAAK,GAAG,MAAM,GAAG,EAAG,eAAc,EAAE,SAAS,EAAE,EAAE,CAAC,EACtE,EAAE,EACD,oBAAmBD,EAAG,WAAU,EACjC,IAAAG,oBAAa,EAACR,OAAO,CAAC,CACvB,CAACS,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toBeVisible = toBeVisible;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _accessiblity = require("../helpers/accessiblity");
|
|
10
|
+
var _componentTree = require("../helpers/component-tree");
|
|
11
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
function toBeVisible(element) {
|
|
14
|
+
if (element !== null || !this.isNot) {
|
|
15
|
+
(0, _utils.checkHostElement)(element, toBeVisible, this);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
pass: isElementVisible(element),
|
|
19
|
+
message: () => {
|
|
20
|
+
const is = this.isNot ? 'is' : 'is not';
|
|
21
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toBeVisible`, 'element', ''), '', `Received element ${is} visible:`, (0, _utils.formatElement)(element)].join('\n');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function isElementVisible(element, accessibilityCache) {
|
|
26
|
+
// Use cache to speed up repeated searches by `isHiddenFromAccessibility`.
|
|
27
|
+
const cache = accessibilityCache ?? new WeakMap();
|
|
28
|
+
if ((0, _accessiblity.isHiddenFromAccessibility)(element, {
|
|
29
|
+
cache
|
|
30
|
+
})) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (isHiddenForStyles(element)) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Note: this seems to be a bug in React Native.
|
|
38
|
+
// PR with fix: https://github.com/facebook/react-native/pull/39157
|
|
39
|
+
if ((0, _hostComponentNames.isHostModal)(element) && element.props.visible === false) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
const hostParent = (0, _componentTree.getHostParent)(element);
|
|
43
|
+
if (hostParent === null) {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return isElementVisible(hostParent, cache);
|
|
47
|
+
}
|
|
48
|
+
function isHiddenForStyles(element) {
|
|
49
|
+
const style = element.props.style ?? {};
|
|
50
|
+
const {
|
|
51
|
+
display,
|
|
52
|
+
opacity
|
|
53
|
+
} = _reactNative.StyleSheet.flatten(style);
|
|
54
|
+
return display === 'none' || opacity === 0;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=to-be-visible.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-be-visible.js","names":["_jestMatcherUtils","require","_reactNative","_accessiblity","_componentTree","_hostComponentNames","_utils","toBeVisible","element","isNot","checkHostElement","pass","isElementVisible","message","is","matcherHint","formatElement","join","accessibilityCache","cache","WeakMap","isHiddenFromAccessibility","isHiddenForStyles","isHostModal","props","visible","hostParent","getHostParent","style","display","opacity","StyleSheet","flatten"],"sources":["../../src/matchers/to-be-visible.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { StyleSheet } from 'react-native';\nimport { isHiddenFromAccessibility } from '../helpers/accessiblity';\nimport { getHostParent } from '../helpers/component-tree';\nimport { isHostModal } from '../helpers/host-component-names';\nimport { checkHostElement, formatElement } from './utils';\n\nexport function toBeVisible(\n this: jest.MatcherContext,\n element: ReactTestInstance\n) {\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 style = element.props.style ?? {};\n const { display, opacity } = StyleSheet.flatten(style);\n return display === 'none' || opacity === 0;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,aAAA,GAAAF,OAAA;AACA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,WAAWA,CAEzBC,OAA0B,EAC1B;EACA,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,EAAE,GAAE,IAAI,CAACN,KAAK,GAAG,MAAM,GAAG,EAAG,cAAa,EAAE,SAAS,EAAE,EAAE,CAAC,EACrE,EAAE,EACD,oBAAmBK,EAAG,WAAU,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,uCAAyB,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,KAAK,GAAGpB,OAAO,CAACgB,KAAK,CAACI,KAAK,IAAI,CAAC,CAAC;EACvC,MAAM;IAAEC,OAAO;IAAEC;EAAQ,CAAC,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAAC;EACtD,OAAOC,OAAO,KAAK,MAAM,IAAIC,OAAO,KAAK,CAAC;AAC5C"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
export declare function toContainElement(this: jest.MatcherContext, container: ReactTestInstance, element: ReactTestInstance | null): {
|
|
4
|
+
pass: boolean;
|
|
5
|
+
message: () => string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toContainElement = toContainElement;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
function toContainElement(container, element) {
|
|
10
|
+
(0, _utils.checkHostElement)(container, toContainElement, this);
|
|
11
|
+
if (element !== null) {
|
|
12
|
+
(0, _utils.checkHostElement)(element, toContainElement, this);
|
|
13
|
+
}
|
|
14
|
+
let matches = [];
|
|
15
|
+
if (element) {
|
|
16
|
+
matches = container.findAll(node => node === element);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
pass: matches.length > 0,
|
|
20
|
+
message: () => {
|
|
21
|
+
return [(0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toContainElement`, 'container', 'element'), '', (0, _jestMatcherUtils.RECEIVED_COLOR)(`${(0, _utils.formatElement)(container)} ${this.isNot ? '\n\ncontains:\n\n' : '\n\ndoes not contain:\n\n'} ${(0, _utils.formatElement)(element)}
|
|
22
|
+
`)].join('\n');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=to-contain-element.js.map
|
|
@@ -0,0 +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.tsx"],"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(\n `${this.isNot ? '.not' : ''}.toContainElement`,\n 'container',\n 'element'\n ),\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,EACR,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,mBAAkB,EAC9C,WAAW,EACX,SACF,CAAC,EACD,EAAE,EACF,IAAAC,gCAAc,EAAE,GAAE,IAAAC,oBAAa,EAACZ,SAAS,CAAE,IACzC,IAAI,CAACU,KAAK,GAAG,mBAAmB,GAAG,2BACpC,IAAG,IAAAE,oBAAa,EAACX,OAAO,CAAE;AACnC,SAAS,CAAC,CACH,CAACY,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
import { TextMatch, TextMatchOptions } from '../matches';
|
|
4
|
+
export declare function toHaveDisplayValue(this: jest.MatcherContext, element: ReactTestInstance, expectedValue: TextMatch, options?: TextMatchOptions): {
|
|
5
|
+
pass: boolean;
|
|
6
|
+
message: () => string;
|
|
7
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toHaveDisplayValue = toHaveDisplayValue;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _hostComponentNames = require("../helpers/host-component-names");
|
|
9
|
+
var _errors = require("../helpers/errors");
|
|
10
|
+
var _textInput = require("../helpers/text-input");
|
|
11
|
+
var _matches = require("../matches");
|
|
12
|
+
var _utils = require("./utils");
|
|
13
|
+
function toHaveDisplayValue(element, expectedValue, options) {
|
|
14
|
+
(0, _utils.checkHostElement)(element, toHaveDisplayValue, this);
|
|
15
|
+
if (!(0, _hostComponentNames.isHostTextInput)(element)) {
|
|
16
|
+
throw new _errors.ErrorWithStack(`toHaveDisplayValue() works only with host "TextInput" elements. Passed element has type "${element.type}".`, toHaveDisplayValue);
|
|
17
|
+
}
|
|
18
|
+
const receivedValue = (0, _textInput.getTextInputValue)(element);
|
|
19
|
+
return {
|
|
20
|
+
pass: (0, _matches.matches)(expectedValue, receivedValue, options?.normalizer, options?.exact),
|
|
21
|
+
message: () => {
|
|
22
|
+
return [(0, _utils.formatMessage)((0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveDisplayValue`, 'element', ''), `Expected element ${this.isNot ? 'not to' : 'to'} have display value`, expectedValue, 'Received', receivedValue)].join('\n');
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=to-have-display-value.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-have-display-value.js","names":["_jestMatcherUtils","require","_hostComponentNames","_errors","_textInput","_matches","_utils","toHaveDisplayValue","element","expectedValue","options","checkHostElement","isHostTextInput","ErrorWithStack","type","receivedValue","getTextInputValue","pass","matches","normalizer","exact","message","formatMessage","matcherHint","isNot","join"],"sources":["../../src/matchers/to-have-display-value.tsx"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint } from 'jest-matcher-utils';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { ErrorWithStack } from '../helpers/errors';\nimport { getTextInputValue } from '../helpers/text-input';\nimport { TextMatch, TextMatchOptions, matches } from '../matches';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveDisplayValue(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n expectedValue: TextMatch,\n options?: TextMatchOptions\n) {\n checkHostElement(element, toHaveDisplayValue, this);\n\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `toHaveDisplayValue() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n toHaveDisplayValue\n );\n }\n\n const receivedValue = getTextInputValue(element);\n\n return {\n pass: matches(\n expectedValue,\n receivedValue,\n options?.normalizer,\n options?.exact\n ),\n message: () => {\n return [\n formatMessage(\n matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveDisplayValue`,\n 'element',\n ''\n ),\n `Expected element ${this.isNot ? 'not to' : 'to'} have display value`,\n expectedValue,\n 'Received',\n receivedValue\n ),\n ].join('\\n');\n },\n };\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAEO,SAASM,kBAAkBA,CAEhCC,OAA0B,EAC1BC,aAAwB,EACxBC,OAA0B,EAC1B;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,kBAAkB,EAAE,IAAI,CAAC;EAEnD,IAAI,CAAC,IAAAK,mCAAe,EAACJ,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIK,sBAAc,CACrB,4FAA2FL,OAAO,CAACM,IAAK,IAAG,EAC5GP,kBACF,CAAC;EACH;EAEA,MAAMQ,aAAa,GAAG,IAAAC,4BAAiB,EAACR,OAAO,CAAC;EAEhD,OAAO;IACLS,IAAI,EAAE,IAAAC,gBAAO,EACXT,aAAa,EACbM,aAAa,EACbL,OAAO,EAAES,UAAU,EACnBT,OAAO,EAAEU,KACX,CAAC;IACDC,OAAO,EAAEA,CAAA,KAAM;MACb,OAAO,CACL,IAAAC,oBAAa,EACX,IAAAC,6BAAW,EACR,GAAE,IAAI,CAACC,KAAK,GAAG,MAAM,GAAG,EAAG,qBAAoB,EAChD,SAAS,EACT,EACF,CAAC,EACA,oBAAmB,IAAI,CAACA,KAAK,GAAG,QAAQ,GAAG,IAAK,qBAAoB,EACrEf,aAAa,EACb,UAAU,EACVM,aACF,CAAC,CACF,CAACU,IAAI,CAAC,IAAI,CAAC;IACd;EACF,CAAC;AACH"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
export declare function toHaveProp(this: jest.MatcherContext, element: ReactTestInstance, name: string, expectedValue: unknown): {
|
|
4
|
+
pass: boolean;
|
|
5
|
+
message: () => string;
|
|
6
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toHaveProp = toHaveProp;
|
|
7
|
+
var _jestMatcherUtils = require("jest-matcher-utils");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
function toHaveProp(element, name, expectedValue) {
|
|
10
|
+
(0, _utils.checkHostElement)(element, toHaveProp, this);
|
|
11
|
+
const isExpectedValueDefined = expectedValue !== undefined;
|
|
12
|
+
const hasProp = (name in element.props);
|
|
13
|
+
const receivedValue = element.props[name];
|
|
14
|
+
const pass = isExpectedValueDefined ? hasProp && this.equals(expectedValue, receivedValue) : hasProp;
|
|
15
|
+
return {
|
|
16
|
+
pass,
|
|
17
|
+
message: () => {
|
|
18
|
+
const to = this.isNot ? 'not to' : 'to';
|
|
19
|
+
const matcher = (0, _jestMatcherUtils.matcherHint)(`${this.isNot ? '.not' : ''}.toHaveProp`, 'element', (0, _jestMatcherUtils.printExpected)(name), {
|
|
20
|
+
secondArgument: isExpectedValueDefined ? (0, _jestMatcherUtils.printExpected)(expectedValue) : undefined
|
|
21
|
+
});
|
|
22
|
+
return (0, _utils.formatMessage)(matcher, `Expected element ${to} have prop`, formatProp(name, expectedValue), 'Received', hasProp ? formatProp(name, receivedValue) : undefined);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
function formatProp(name, value) {
|
|
27
|
+
if (value === undefined) {
|
|
28
|
+
return name;
|
|
29
|
+
}
|
|
30
|
+
if (typeof value === 'string') {
|
|
31
|
+
return `${name}="${value}"`;
|
|
32
|
+
}
|
|
33
|
+
return `${name}={${(0, _jestMatcherUtils.stringify)(value)}}`;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=to-have-prop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-have-prop.js","names":["_jestMatcherUtils","require","_utils","toHaveProp","element","name","expectedValue","checkHostElement","isExpectedValueDefined","undefined","hasProp","props","receivedValue","pass","equals","message","to","isNot","matcher","matcherHint","printExpected","secondArgument","formatMessage","formatProp","value","stringify"],"sources":["../../src/matchers/to-have-prop.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { matcherHint, stringify, printExpected } from 'jest-matcher-utils';\nimport { checkHostElement, formatMessage } from './utils';\n\nexport function toHaveProp(\n this: jest.MatcherContext,\n element: ReactTestInstance,\n name: string,\n expectedValue: unknown\n) {\n checkHostElement(element, toHaveProp, this);\n\n const isExpectedValueDefined = expectedValue !== undefined;\n const hasProp = name in element.props;\n const receivedValue = element.props[name];\n\n const pass = isExpectedValueDefined\n ? hasProp && this.equals(expectedValue, receivedValue)\n : hasProp;\n\n return {\n pass,\n message: () => {\n const to = this.isNot ? 'not to' : 'to';\n const matcher = matcherHint(\n `${this.isNot ? '.not' : ''}.toHaveProp`,\n 'element',\n printExpected(name),\n {\n secondArgument: isExpectedValueDefined\n ? printExpected(expectedValue)\n : undefined,\n }\n );\n return formatMessage(\n matcher,\n `Expected element ${to} have prop`,\n formatProp(name, expectedValue),\n 'Received',\n hasProp ? formatProp(name, receivedValue) : undefined\n );\n },\n };\n}\n\nfunction formatProp(name: string, value: unknown) {\n if (value === undefined) {\n return name;\n }\n\n if (typeof value === 'string') {\n return `${name}=\"${value}\"`;\n }\n\n return `${name}={${stringify(value)}}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,iBAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEO,SAASE,UAAUA,CAExBC,OAA0B,EAC1BC,IAAY,EACZC,aAAsB,EACtB;EACA,IAAAC,uBAAgB,EAACH,OAAO,EAAED,UAAU,EAAE,IAAI,CAAC;EAE3C,MAAMK,sBAAsB,GAAGF,aAAa,KAAKG,SAAS;EAC1D,MAAMC,OAAO,IAAGL,IAAI,IAAID,OAAO,CAACO,KAAK;EACrC,MAAMC,aAAa,GAAGR,OAAO,CAACO,KAAK,CAACN,IAAI,CAAC;EAEzC,MAAMQ,IAAI,GAAGL,sBAAsB,GAC/BE,OAAO,IAAI,IAAI,CAACI,MAAM,CAACR,aAAa,EAAEM,aAAa,CAAC,GACpDF,OAAO;EAEX,OAAO;IACLG,IAAI;IACJE,OAAO,EAAEA,CAAA,KAAM;MACb,MAAMC,EAAE,GAAG,IAAI,CAACC,KAAK,GAAG,QAAQ,GAAG,IAAI;MACvC,MAAMC,OAAO,GAAG,IAAAC,6BAAW,EACxB,GAAE,IAAI,CAACF,KAAK,GAAG,MAAM,GAAG,EAAG,aAAY,EACxC,SAAS,EACT,IAAAG,+BAAa,EAACf,IAAI,CAAC,EACnB;QACEgB,cAAc,EAAEb,sBAAsB,GAClC,IAAAY,+BAAa,EAACd,aAAa,CAAC,GAC5BG;MACN,CACF,CAAC;MACD,OAAO,IAAAa,oBAAa,EAClBJ,OAAO,EACN,oBAAmBF,EAAG,YAAW,EAClCO,UAAU,CAAClB,IAAI,EAAEC,aAAa,CAAC,EAC/B,UAAU,EACVI,OAAO,GAAGa,UAAU,CAAClB,IAAI,EAAEO,aAAa,CAAC,GAAGH,SAC9C,CAAC;IACH;EACF,CAAC;AACH;AAEA,SAASc,UAAUA,CAAClB,IAAY,EAAEmB,KAAc,EAAE;EAChD,IAAIA,KAAK,KAAKf,SAAS,EAAE;IACvB,OAAOJ,IAAI;EACb;EAEA,IAAI,OAAOmB,KAAK,KAAK,QAAQ,EAAE;IAC7B,OAAQ,GAAEnB,IAAK,KAAImB,KAAM,GAAE;EAC7B;EAEA,OAAQ,GAAEnB,IAAK,KAAI,IAAAoB,2BAAS,EAACD,KAAK,CAAE,GAAE;AACxC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="jest" />
|
|
2
|
+
import type { ReactTestInstance } from 'react-test-renderer';
|
|
3
|
+
import { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
4
|
+
export type Style = ViewStyle | TextStyle | ImageStyle;
|
|
5
|
+
export declare function toHaveStyle(this: jest.MatcherContext, element: ReactTestInstance, style: StyleProp<Style>): {
|
|
6
|
+
pass: boolean;
|
|
7
|
+
message: () => string;
|
|
8
|
+
};
|