@testing-library/react-native 14.0.0-alpha.6 → 14.0.0-beta.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 +30 -30
- package/build/config.js +10 -4
- package/build/config.js.map +1 -1
- package/build/event-builder/base.d.ts +7 -0
- package/build/{user-event/event-builder → event-builder}/base.js +1 -1
- package/build/event-builder/base.js.map +1 -0
- package/build/event-builder/common.d.ts +152 -0
- package/build/event-builder/common.js +80 -0
- package/build/event-builder/common.js.map +1 -0
- package/build/event-builder/index.d.ts +3 -0
- package/build/event-builder/index.js +39 -0
- package/build/event-builder/index.js.map +1 -0
- package/build/event-builder/scroll.d.ts +56 -0
- package/build/event-builder/scroll.js +51 -0
- package/build/event-builder/scroll.js.map +1 -0
- package/build/event-builder/text.d.ts +162 -0
- package/build/event-builder/text.js +113 -0
- package/build/event-builder/text.js.map +1 -0
- package/build/event-handler.d.ts +0 -1
- package/build/event-handler.js +0 -1
- package/build/event-handler.js.map +1 -1
- package/build/fire-event.d.ts +6 -7
- package/build/fire-event.js +47 -28
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +18 -15
- package/build/helpers/accessibility.js +64 -47
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +9 -9
- package/build/helpers/component-tree.js +17 -17
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/errors.d.ts +1 -3
- package/build/helpers/errors.js +3 -36
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/find-all.d.ts +2 -2
- package/build/helpers/find-all.js +1 -1
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-element.d.ts +5 -5
- package/build/helpers/format-element.js +9 -9
- package/build/helpers/format-element.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +13 -13
- package/build/helpers/host-component-names.js +18 -18
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-state.d.ts +2 -2
- package/build/helpers/matchers/match-accessibility-state.js +6 -6
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.d.ts +2 -2
- package/build/helpers/matchers/match-accessibility-value.js +2 -2
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +2 -2
- package/build/helpers/matchers/match-label-text.js +2 -2
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-text-content.d.ts +5 -5
- package/build/helpers/matchers/match-text-content.js +5 -5
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/pointer-events.d.ts +2 -2
- package/build/helpers/pointer-events.js +4 -4
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/text-content.d.ts +2 -2
- package/build/helpers/text-content.js +5 -5
- package/build/helpers/text-content.js.map +1 -1
- package/build/helpers/text-input.d.ts +3 -3
- package/build/helpers/text-input.js +6 -6
- package/build/helpers/text-input.js.map +1 -1
- package/build/helpers/validate-options.d.ts +9 -0
- package/build/helpers/validate-options.js +32 -0
- package/build/helpers/validate-options.js.map +1 -0
- package/build/matchers/to-be-busy.d.ts +2 -2
- package/build/matchers/to-be-busy.js +5 -5
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.d.ts +2 -2
- package/build/matchers/to-be-checked.js +9 -9
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.d.ts +3 -3
- package/build/matchers/to-be-disabled.js +10 -10
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.d.ts +2 -2
- package/build/matchers/to-be-empty-element.js +4 -4
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.d.ts +3 -3
- package/build/matchers/to-be-expanded.js +10 -10
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.d.ts +2 -2
- package/build/matchers/to-be-on-the-screen.js +7 -7
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.d.ts +2 -2
- package/build/matchers/to-be-partially-checked.js +8 -8
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.d.ts +2 -2
- package/build/matchers/to-be-selected.js +4 -4
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.d.ts +2 -2
- package/build/matchers/to-be-visible.js +12 -12
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.d.ts +2 -2
- package/build/matchers/to-contain-element.js +6 -6
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.d.ts +2 -2
- package/build/matchers/to-have-accessibility-value.js +6 -6
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.d.ts +2 -2
- package/build/matchers/to-have-accessible-name.js +5 -10
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.d.ts +2 -2
- package/build/matchers/to-have-display-value.js +6 -6
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-prop.d.ts +2 -2
- package/build/matchers/to-have-prop.js +6 -6
- package/build/matchers/to-have-prop.js.map +1 -1
- package/build/matchers/to-have-style.d.ts +2 -2
- package/build/matchers/to-have-style.js +5 -5
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.d.ts +2 -2
- package/build/matchers/to-have-text-content.js +4 -4
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.d.ts +20 -20
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.d.ts +4 -4
- package/build/matchers/utils.js +6 -6
- package/build/matchers/utils.js.map +1 -1
- package/build/native-state.d.ts +3 -3
- package/build/native-state.js +2 -2
- package/build/native-state.js.map +1 -1
- package/build/queries/display-value.d.ts +2 -2
- package/build/queries/display-value.js +12 -12
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +2 -2
- package/build/queries/hint-text.js +11 -11
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +2 -2
- package/build/queries/label-text.js +9 -9
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.d.ts +8 -8
- package/build/queries/make-queries.js +11 -11
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +2 -2
- package/build/queries/placeholder-text.js +11 -11
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +2 -2
- package/build/queries/role.js +17 -27
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +2 -2
- package/build/queries/test-id.js +11 -11
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +2 -2
- package/build/queries/text.js +9 -9
- package/build/queries/text.js.map +1 -1
- package/build/render-hook.js +7 -1
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +4 -5
- package/build/render.js +22 -6
- package/build/render.js.map +1 -1
- package/build/screen.js.map +1 -1
- package/build/test-utils/react-version-gates.d.ts +1 -0
- package/build/test-utils/react-version-gates.js +28 -0
- package/build/test-utils/react-version-gates.js.map +1 -0
- package/build/test-utils/timers.d.ts +2 -0
- package/build/test-utils/timers.js +20 -0
- package/build/test-utils/timers.js.map +1 -0
- package/build/types.d.ts +7 -0
- package/build/types.js.map +1 -1
- package/build/user-event/clear.d.ts +2 -2
- package/build/user-event/clear.js +13 -13
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/index.d.ts +7 -7
- package/build/user-event/index.js +6 -6
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/paste.d.ts +2 -2
- package/build/user-event/paste.js +18 -18
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/press.d.ts +3 -3
- package/build/user-event/press/press.js +35 -35
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.d.ts +2 -2
- package/build/user-event/scroll/scroll-to.js +20 -20
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +11 -11
- package/build/user-event/setup/setup.js +17 -3
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.d.ts +3 -3
- package/build/user-event/type/type.js +27 -28
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/dispatch-event.d.ts +3 -3
- package/build/user-event/utils/dispatch-event.js +4 -4
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/index.d.ts +0 -1
- package/build/user-event/utils/index.js +0 -11
- package/build/user-event/utils/index.js.map +1 -1
- package/build/wait-for.js +8 -13
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +3 -3
- package/build/within.js +10 -10
- package/build/within.js.map +1 -1
- package/package.json +38 -27
- package/build/react-versions.d.ts +0 -1
- package/build/react-versions.js +0 -14
- package/build/react-versions.js.map +0 -1
- package/build/tsconfig.release.tsbuildinfo +0 -1
- package/build/user-event/event-builder/base.d.ts +0 -3
- package/build/user-event/event-builder/base.js.map +0 -1
- package/build/user-event/event-builder/common.d.ts +0 -150
- package/build/user-event/event-builder/common.js +0 -77
- package/build/user-event/event-builder/common.js.map +0 -1
- package/build/user-event/event-builder/index.d.ts +0 -306
- package/build/user-event/event-builder/index.js +0 -15
- package/build/user-event/event-builder/index.js.map +0 -1
- package/build/user-event/event-builder/scroll-view.d.ts +0 -57
- package/build/user-event/event-builder/scroll-view.js +0 -53
- package/build/user-event/event-builder/scroll-view.js.map +0 -1
- package/build/user-event/event-builder/text-input.d.ts +0 -159
- package/build/user-event/event-builder/text-input.js +0 -105
- package/build/user-event/event-builder/text-input.js.map +0 -1
- package/build/user-event/utils/text-range.d.ts +0 -4
- package/build/user-event/utils/text-range.js +0 -6
- package/build/user-event/utils/text-range.js.map +0 -1
package/build/queries/role.js
CHANGED
|
@@ -10,33 +10,23 @@ var _matchAccessibilityState = require("../helpers/matchers/match-accessibility-
|
|
|
10
10
|
var _matchAccessibilityValue = require("../helpers/matchers/match-accessibility-value");
|
|
11
11
|
var _matchStringProp = require("../helpers/matchers/match-string-prop");
|
|
12
12
|
var _matches = require("../matches");
|
|
13
|
-
var _within = require("../within");
|
|
14
13
|
var _makeQueries = require("./make-queries");
|
|
15
|
-
const matchAccessibleNameIfNeeded = (
|
|
14
|
+
const matchAccessibleNameIfNeeded = (instance, name) => {
|
|
16
15
|
if (name == null) return true;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const accessibleName = (0, _accessibility.computeAccessibleName)(node);
|
|
20
|
-
if ((0, _matches.matches)(name, accessibleName)) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
const {
|
|
24
|
-
queryAllByText,
|
|
25
|
-
queryAllByLabelText
|
|
26
|
-
} = (0, _within.getQueriesForElement)(node);
|
|
27
|
-
return queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0;
|
|
16
|
+
const accessibleName = (0, _accessibility.computeAccessibleName)(instance);
|
|
17
|
+
return (0, _matches.matches)(name, accessibleName);
|
|
28
18
|
};
|
|
29
|
-
const matchAccessibleStateIfNeeded = (
|
|
30
|
-
return options != null ? (0, _matchAccessibilityState.matchAccessibilityState)(
|
|
19
|
+
const matchAccessibleStateIfNeeded = (instance, options) => {
|
|
20
|
+
return options != null ? (0, _matchAccessibilityState.matchAccessibilityState)(instance, options) : true;
|
|
31
21
|
};
|
|
32
|
-
const matchAccessibilityValueIfNeeded = (
|
|
33
|
-
return value != null ? (0, _matchAccessibilityValue.matchAccessibilityValue)(
|
|
22
|
+
const matchAccessibilityValueIfNeeded = (instance, value) => {
|
|
23
|
+
return value != null ? (0, _matchAccessibilityValue.matchAccessibilityValue)(instance, value) : true;
|
|
34
24
|
};
|
|
35
|
-
const queryAllByRole =
|
|
25
|
+
const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
|
|
36
26
|
const normalizedRole = typeof role === 'string' ? (0, _accessibility.normalizeRole)(role) : role;
|
|
37
|
-
return (0, _findAll.findAll)(
|
|
27
|
+
return (0, _findAll.findAll)(instance, item =>
|
|
38
28
|
// run the cheapest checks first, and early exit to avoid unneeded computations
|
|
39
|
-
(0, _accessibility.isAccessibilityElement)(
|
|
29
|
+
(0, _accessibility.isAccessibilityElement)(item) && (0, _matchStringProp.matchStringProp)((0, _accessibility.getRole)(item), normalizedRole) && matchAccessibleStateIfNeeded(item, options) && matchAccessibilityValueIfNeeded(item, options?.value) && matchAccessibleNameIfNeeded(item, options?.name), options);
|
|
40
30
|
};
|
|
41
31
|
const formatQueryParams = (role, options = {}) => {
|
|
42
32
|
const params = [`role: ${String(role)}`];
|
|
@@ -65,13 +55,13 @@ const {
|
|
|
65
55
|
findBy,
|
|
66
56
|
findAllBy
|
|
67
57
|
} = (0, _makeQueries.makeQueries)(queryAllByRole, getMissingError, getMultipleError);
|
|
68
|
-
const bindByRoleQueries =
|
|
69
|
-
getByRole: getBy(
|
|
70
|
-
getAllByRole: getAllBy(
|
|
71
|
-
queryByRole: queryBy(
|
|
72
|
-
queryAllByRole: queryAllBy(
|
|
73
|
-
findByRole: findBy(
|
|
74
|
-
findAllByRole: findAllBy(
|
|
58
|
+
const bindByRoleQueries = instance => ({
|
|
59
|
+
getByRole: getBy(instance),
|
|
60
|
+
getAllByRole: getAllBy(instance),
|
|
61
|
+
queryByRole: queryBy(instance),
|
|
62
|
+
queryAllByRole: queryAllBy(instance),
|
|
63
|
+
findByRole: findBy(instance),
|
|
64
|
+
findAllByRole: findAllBy(instance)
|
|
75
65
|
});
|
|
76
66
|
exports.bindByRoleQueries = bindByRoleQueries;
|
|
77
67
|
//# sourceMappingURL=role.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_matches","
|
|
1
|
+
{"version":3,"file":"role.js","names":["_accessibility","require","_findAll","_matchAccessibilityState","_matchAccessibilityValue","_matchStringProp","_matches","_makeQueries","matchAccessibleNameIfNeeded","instance","name","accessibleName","computeAccessibleName","matches","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","queryAllByRoleFn","role","normalizedRole","normalizeRole","findAll","item","isAccessibilityElement","matchStringProp","getRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessibilityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole","exports"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { AccessibilityRole, Role } from 'react-native';\nimport type { TestInstance } from 'test-renderer';\n\nimport {\n accessibilityStateKeys,\n accessibilityValueKeys,\n computeAccessibleName,\n getRole,\n isAccessibilityElement,\n normalizeRole,\n} from '../helpers/accessibility';\nimport { findAll } from '../helpers/find-all';\nimport type { AccessibilityStateMatcher } from '../helpers/matchers/match-accessibility-state';\nimport { matchAccessibilityState } from '../helpers/matchers/match-accessibility-state';\nimport type { AccessibilityValueMatcher } from '../helpers/matchers/match-accessibility-value';\nimport { matchAccessibilityValue } from '../helpers/matchers/match-accessibility-value';\nimport { matchStringProp } from '../helpers/matchers/match-string-prop';\nimport { matches, type TextMatch } from '../matches';\nimport type { StringWithAutocomplete } from '../types';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\nexport type ByRoleMatcher = StringWithAutocomplete<AccessibilityRole | Role> | RegExp;\n\nexport type ByRoleOptions = CommonQueryOptions &\n AccessibilityStateMatcher & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (instance: TestInstance, name?: TextMatch) => {\n if (name == null) return true;\n\n const accessibleName = computeAccessibleName(instance);\n return matches(name, accessibleName);\n};\n\nconst matchAccessibleStateIfNeeded = (instance: TestInstance, options?: ByRoleOptions) => {\n return options != null ? matchAccessibilityState(instance, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n instance: TestInstance,\n value?: AccessibilityValueMatcher,\n) => {\n return value != null ? matchAccessibilityValue(instance, value) : true;\n};\n\nconst queryAllByRole = (instance: TestInstance): QueryAllByQuery<ByRoleMatcher, ByRoleOptions> =>\n function queryAllByRoleFn(role, options) {\n const normalizedRole = typeof role === 'string' ? normalizeRole(role) : role;\n return findAll(\n instance,\n (item) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n isAccessibilityElement(item) &&\n matchStringProp(getRole(item), normalizedRole) &&\n matchAccessibleStateIfNeeded(item, options) &&\n matchAccessibilityValueIfNeeded(item, options?.value) &&\n matchAccessibleNameIfNeeded(item, options?.name),\n options,\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: ${String(role)}`];\n\n if (options.name) {\n params.push(`name: ${String(options.name)}`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessibilityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<ByRoleMatcher, ByRoleOptions>;\n getAllByRole: GetAllByQuery<ByRoleMatcher, ByRoleOptions>;\n queryByRole: QueryByQuery<ByRoleMatcher, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<ByRoleMatcher, ByRoleOptions>;\n findByRole: FindByQuery<ByRoleMatcher, ByRoleOptions>;\n findAllByRole: FindAllByQuery<ByRoleMatcher, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (instance: TestInstance): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AAQA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,wBAAA,GAAAF,OAAA;AAEA,IAAAG,wBAAA,GAAAH,OAAA;AACA,IAAAI,gBAAA,GAAAJ,OAAA;AACA,IAAAK,QAAA,GAAAL,OAAA;AAUA,IAAAM,YAAA,GAAAN,OAAA;AAWA,MAAMO,2BAA2B,GAAGA,CAACC,QAAsB,EAAEC,IAAgB,KAAK;EAChF,IAAIA,IAAI,IAAI,IAAI,EAAE,OAAO,IAAI;EAE7B,MAAMC,cAAc,GAAG,IAAAC,oCAAqB,EAACH,QAAQ,CAAC;EACtD,OAAO,IAAAI,gBAAO,EAACH,IAAI,EAAEC,cAAc,CAAC;AACtC,CAAC;AAED,MAAMG,4BAA4B,GAAGA,CAACL,QAAsB,EAAEM,OAAuB,KAAK;EACxF,OAAOA,OAAO,IAAI,IAAI,GAAG,IAAAC,gDAAuB,EAACP,QAAQ,EAAEM,OAAO,CAAC,GAAG,IAAI;AAC5E,CAAC;AAED,MAAME,+BAA+B,GAAGA,CACtCR,QAAsB,EACtBS,KAAiC,KAC9B;EACH,OAAOA,KAAK,IAAI,IAAI,GAAG,IAAAC,gDAAuB,EAACV,QAAQ,EAAES,KAAK,CAAC,GAAG,IAAI;AACxE,CAAC;AAED,MAAME,cAAc,GAAIX,QAAsB,IAC5C,SAASY,gBAAgBA,CAACC,IAAI,EAAEP,OAAO,EAAE;EACvC,MAAMQ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CAAC;EAEF,OAAOR,MAAM,CAACS,IAAI,CAAC,IAAI,CAAC;AAC1B,CAAC;AAED,MAAMC,gBAAgB,GAAGA,CAACnB,IAAe,EAAEP,OAAuB,KAChE,gCAAgCe,iBAAiB,CAACR,IAAI,EAAEP,OAAO,CAAC,EAAE;AAEpE,MAAM2B,eAAe,GAAGA,CAACpB,IAAe,EAAEP,OAAuB,KAC/D,kCAAkCe,iBAAiB,CAACR,IAAI,EAAEP,OAAO,CAAC,EAAE;AAEtE,MAAM;EAAE4B,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7E7B,cAAc,EACdsB,eAAe,EACfD,gBACF,CAAC;AAWM,MAAMS,iBAAiB,GAAIzC,QAAsB,KAAqB;EAC3E0C,SAAS,EAAER,KAAK,CAAClC,QAAQ,CAAC;EAC1B2C,YAAY,EAAER,QAAQ,CAACnC,QAAQ,CAAC;EAChC4C,WAAW,EAAER,OAAO,CAACpC,QAAQ,CAAC;EAC9BW,cAAc,EAAE0B,UAAU,CAACrC,QAAQ,CAAC;EACpC6C,UAAU,EAAEP,MAAM,CAACtC,QAAQ,CAAC;EAC5B8C,aAAa,EAAEP,SAAS,CAACvC,QAAQ;AACnC,CAAC,CAAC;AAAC+C,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TestInstance } from 'test-renderer';
|
|
2
2
|
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
4
|
import type { CommonQueryOptions } from './options';
|
|
@@ -11,5 +11,5 @@ export type ByTestIdQueries = {
|
|
|
11
11
|
findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;
|
|
12
12
|
findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;
|
|
13
13
|
};
|
|
14
|
-
export declare const bindByTestIdQueries: (
|
|
14
|
+
export declare const bindByTestIdQueries: (instance: TestInstance) => ByTestIdQueries;
|
|
15
15
|
export {};
|
package/build/queries/test-id.js
CHANGED
|
@@ -7,15 +7,15 @@ exports.bindByTestIdQueries = void 0;
|
|
|
7
7
|
var _findAll = require("../helpers/find-all");
|
|
8
8
|
var _matches = require("../matches");
|
|
9
9
|
var _makeQueries = require("./make-queries");
|
|
10
|
-
const matchTestId = (
|
|
10
|
+
const matchTestId = (instance, testId, options = {}) => {
|
|
11
11
|
const {
|
|
12
12
|
exact,
|
|
13
13
|
normalizer
|
|
14
14
|
} = options;
|
|
15
|
-
return (0, _matches.matches)(testId,
|
|
15
|
+
return (0, _matches.matches)(testId, instance.props.testID, normalizer, exact);
|
|
16
16
|
};
|
|
17
|
-
const queryAllByTestId =
|
|
18
|
-
return (0, _findAll.findAll)(
|
|
17
|
+
const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
|
|
18
|
+
return (0, _findAll.findAll)(instance, item => matchTestId(item, testId, queryOptions), queryOptions);
|
|
19
19
|
};
|
|
20
20
|
const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
|
|
21
21
|
const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
|
|
@@ -27,13 +27,13 @@ const {
|
|
|
27
27
|
findBy,
|
|
28
28
|
findAllBy
|
|
29
29
|
} = (0, _makeQueries.makeQueries)(queryAllByTestId, getMissingError, getMultipleError);
|
|
30
|
-
const bindByTestIdQueries =
|
|
31
|
-
getByTestId: getBy(
|
|
32
|
-
getAllByTestId: getAllBy(
|
|
33
|
-
queryByTestId: queryBy(
|
|
34
|
-
queryAllByTestId: queryAllBy(
|
|
35
|
-
findByTestId: findBy(
|
|
36
|
-
findAllByTestId: findAllBy(
|
|
30
|
+
const bindByTestIdQueries = instance => ({
|
|
31
|
+
getByTestId: getBy(instance),
|
|
32
|
+
getAllByTestId: getAllBy(instance),
|
|
33
|
+
queryByTestId: queryBy(instance),
|
|
34
|
+
queryAllByTestId: queryAllBy(instance),
|
|
35
|
+
findByTestId: findBy(instance),
|
|
36
|
+
findAllByTestId: findAllBy(instance)
|
|
37
37
|
});
|
|
38
38
|
exports.bindByTestIdQueries = bindByTestIdQueries;
|
|
39
39
|
//# sourceMappingURL=test-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","
|
|
1
|
+
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","instance","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","queryAllByTestIdFn","queryOptions","findAll","item","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTestIdQueries","getByTestId","getAllByTestId","queryByTestId","findByTestId","findAllByTestId","exports"],"sources":["../../src/queries/test-id.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport { matches } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTestIdOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchTestId = (instance: TestInstance, testId: TextMatch, options: TextMatchOptions = {}) => {\n const { exact, normalizer } = options;\n return matches(testId, instance.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (instance: TestInstance): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(instance, (item) => matchTestId(item, testId, queryOptions), queryOptions);\n };\n\nconst getMultipleError = (testId: TextMatch) =>\n `Found multiple elements with testID: ${String(testId)}`;\nconst getMissingError = (testId: TextMatch) =>\n `Unable to find an element with testID: ${String(testId)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByTestId,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTestIdQueries = {\n getByTestId: GetByQuery<TextMatch, ByTestIdOptions>;\n getAllByTestId: GetAllByQuery<TextMatch, ByTestIdOptions>;\n queryByTestId: QueryByQuery<TextMatch, ByTestIdOptions>;\n queryAllByTestId: QueryAllByQuery<TextMatch, ByTestIdOptions>;\n findByTestId: FindByQuery<TextMatch, ByTestIdOptions>;\n findAllByTestId: FindAllByQuery<TextMatch, ByTestIdOptions>;\n};\n\nexport const bindByTestIdQueries = (instance: TestInstance): ByTestIdQueries => ({\n getByTestId: getBy(instance),\n getAllByTestId: getAllBy(instance),\n queryByTestId: queryBy(instance),\n queryAllByTestId: queryAllBy(instance),\n findByTestId: findBy(instance),\n findAllByTestId: findAllBy(instance),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,WAAW,GAAGA,CAACC,QAAsB,EAAEC,MAAiB,EAAEC,OAAyB,GAAG,CAAC,CAAC,KAAK;EACjG,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,MAAM,EAAED,QAAQ,CAACM,KAAK,CAACC,MAAM,EAAEH,UAAU,EAAED,KAAK,CAAC;AAClE,CAAC;AAED,MAAMK,gBAAgB,GAAIR,QAAsB,IAC9C,SAASS,kBAAkBA,CAACR,MAAM,EAAES,YAAY,EAAE;EAChD,OAAO,IAAAC,gBAAO,EAACX,QAAQ,EAAGY,IAAI,IAAKb,WAAW,CAACa,IAAI,EAAEX,MAAM,EAAES,YAAY,CAAC,EAAEA,YAAY,CAAC;AAC3F,CAAC;AAEH,MAAMG,gBAAgB,GAAIZ,MAAiB,IACzC,wCAAwCa,MAAM,CAACb,MAAM,CAAC,EAAE;AAC1D,MAAMc,eAAe,GAAId,MAAiB,IACxC,0CAA0Ca,MAAM,CAACb,MAAM,CAAC,EAAE;AAE5D,MAAM;EAAEe,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7Ed,gBAAgB,EAChBO,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,mBAAmB,GAAIvB,QAAsB,KAAuB;EAC/EwB,WAAW,EAAER,KAAK,CAAChB,QAAQ,CAAC;EAC5ByB,cAAc,EAAER,QAAQ,CAACjB,QAAQ,CAAC;EAClC0B,aAAa,EAAER,OAAO,CAAClB,QAAQ,CAAC;EAChCQ,gBAAgB,EAAEW,UAAU,CAACnB,QAAQ,CAAC;EACtC2B,YAAY,EAAEP,MAAM,CAACpB,QAAQ,CAAC;EAC9B4B,eAAe,EAAEP,SAAS,CAACrB,QAAQ;AACrC,CAAC,CAAC;AAAC6B,OAAA,CAAAN,mBAAA,GAAAA,mBAAA","ignoreList":[]}
|
package/build/queries/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TestInstance } from 'test-renderer';
|
|
2
2
|
import type { TextMatch, TextMatchOptions } from '../matches';
|
|
3
3
|
import type { FindAllByQuery, FindByQuery, GetAllByQuery, GetByQuery, QueryAllByQuery, QueryByQuery } from './make-queries';
|
|
4
4
|
import type { CommonQueryOptions } from './options';
|
|
@@ -11,5 +11,5 @@ export type ByTextQueries = {
|
|
|
11
11
|
findByText: FindByQuery<TextMatch, ByTextOptions>;
|
|
12
12
|
findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;
|
|
13
13
|
};
|
|
14
|
-
export declare const bindByTextQueries: (
|
|
14
|
+
export declare const bindByTextQueries: (instance: TestInstance) => ByTextQueries;
|
|
15
15
|
export {};
|
package/build/queries/text.js
CHANGED
|
@@ -8,8 +8,8 @@ var _findAll = require("../helpers/find-all");
|
|
|
8
8
|
var _hostComponentNames = require("../helpers/host-component-names");
|
|
9
9
|
var _matchTextContent = require("../helpers/matchers/match-text-content");
|
|
10
10
|
var _makeQueries = require("./make-queries");
|
|
11
|
-
const queryAllByText =
|
|
12
|
-
return (0, _findAll.findAll)(
|
|
11
|
+
const queryAllByText = instance => function queryAllByTextFn(text, options = {}) {
|
|
12
|
+
return (0, _findAll.findAll)(instance, item => (0, _hostComponentNames.isHostText)(item) && (0, _matchTextContent.matchTextContent)(item, text, options), {
|
|
13
13
|
...options,
|
|
14
14
|
matchDeepestOnly: true
|
|
15
15
|
});
|
|
@@ -24,13 +24,13 @@ const {
|
|
|
24
24
|
findBy,
|
|
25
25
|
findAllBy
|
|
26
26
|
} = (0, _makeQueries.makeQueries)(queryAllByText, getMissingError, getMultipleError);
|
|
27
|
-
const bindByTextQueries =
|
|
28
|
-
getByText: getBy(
|
|
29
|
-
getAllByText: getAllBy(
|
|
30
|
-
queryByText: queryBy(
|
|
31
|
-
queryAllByText: queryAllBy(
|
|
32
|
-
findByText: findBy(
|
|
33
|
-
findAllByText: findAllBy(
|
|
27
|
+
const bindByTextQueries = instance => ({
|
|
28
|
+
getByText: getBy(instance),
|
|
29
|
+
getAllByText: getAllBy(instance),
|
|
30
|
+
queryByText: queryBy(instance),
|
|
31
|
+
queryAllByText: queryAllBy(instance),
|
|
32
|
+
findByText: findBy(instance),
|
|
33
|
+
findAllByText: findAllBy(instance)
|
|
34
34
|
});
|
|
35
35
|
exports.bindByTextQueries = bindByTextQueries;
|
|
36
36
|
//# sourceMappingURL=text.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","
|
|
1
|
+
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","instance","queryAllByTextFn","text","options","findAll","item","isHostText","matchTextContent","matchDeepestOnly","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByTextQueries","getByText","getAllByText","queryByText","findByText","findAllByText","exports"],"sources":["../../src/queries/text.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport { findAll } from '../helpers/find-all';\nimport { isHostText } from '../helpers/host-component-names';\nimport { matchTextContent } from '../helpers/matchers/match-text-content';\nimport type { TextMatch, TextMatchOptions } from '../matches';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './make-queries';\nimport { makeQueries } from './make-queries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst queryAllByText = (instance: TestInstance): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(instance, (item) => isHostText(item) && matchTextContent(item, text, options), {\n ...options,\n matchDeepestOnly: true,\n });\n };\n\nconst getMultipleError = (text: TextMatch) => `Found multiple elements with text: ${String(text)}`;\n\nconst getMissingError = (text: TextMatch) => `Unable to find an element with text: ${String(text)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByText,\n getMissingError,\n getMultipleError,\n);\n\nexport type ByTextQueries = {\n getByText: GetByQuery<TextMatch, ByTextOptions>;\n getAllByText: GetAllByQuery<TextMatch, ByTextOptions>;\n queryByText: QueryByQuery<TextMatch, ByTextOptions>;\n queryAllByText: QueryAllByQuery<TextMatch, ByTextOptions>;\n findByText: FindByQuery<TextMatch, ByTextOptions>;\n findAllByText: FindAllByQuery<TextMatch, ByTextOptions>;\n};\n\nexport const bindByTextQueries = (instance: TestInstance): ByTextQueries => ({\n getByText: getBy(instance),\n getAllByText: getAllBy(instance),\n queryByText: queryBy(instance),\n queryAllByText: queryAllBy(instance),\n findByText: findBy(instance),\n find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]}
|
package/build/render-hook.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.renderHook = renderHook;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _validateOptions = require("./helpers/validate-options");
|
|
8
9
|
var _render = require("./render");
|
|
9
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
10
11
|
async function renderHook(hookToRender, options) {
|
|
@@ -20,8 +21,13 @@ async function renderHook(hookToRender, options) {
|
|
|
20
21
|
}
|
|
21
22
|
const {
|
|
22
23
|
initialProps,
|
|
23
|
-
|
|
24
|
+
wrapper,
|
|
25
|
+
...rest
|
|
24
26
|
} = options ?? {};
|
|
27
|
+
(0, _validateOptions.validateOptions)('renderHook', rest, renderHook);
|
|
28
|
+
const renderOptions = wrapper ? {
|
|
29
|
+
wrapper
|
|
30
|
+
} : {};
|
|
25
31
|
const {
|
|
26
32
|
rerender: rerenderComponent,
|
|
27
33
|
unmount
|
package/build/render-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_render","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderHook","hookToRender","options","result","createRef","HookContainer","hookProps","renderResult","useEffect","current","initialProps","renderOptions","rerender","rerenderComponent","unmount","render","createElement"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { render } from './render';\nimport type { RefObject } from './types';\n\nexport type RenderHookResult<Result, Props> = {\n result: RefObject<Result>;\n rerender: (props: Props) => Promise<void>;\n unmount: () => Promise<void>;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n};\n\nexport async function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): Promise<RenderHookResult<Result, Props>> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function HookContainer({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, ...
|
|
1
|
+
{"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_validateOptions","_render","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderHook","hookToRender","options","result","createRef","HookContainer","hookProps","renderResult","useEffect","current","initialProps","wrapper","rest","validateOptions","renderOptions","rerender","rerenderComponent","unmount","render","createElement"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { validateOptions } from './helpers/validate-options';\nimport { render } from './render';\nimport type { RefObject } from './types';\n\nexport type RenderHookResult<Result, Props> = {\n result: RefObject<Result>;\n rerender: (props: Props) => Promise<void>;\n unmount: () => Promise<void>;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n};\n\nexport async function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): Promise<RenderHookResult<Result, Props>> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function HookContainer({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, wrapper, ...rest } = options ?? {};\n validateOptions('renderHook', rest, renderHook);\n const renderOptions = wrapper ? { wrapper } : {};\n const { rerender: rerenderComponent, unmount } = await render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it shouldn't be\n <HookContainer hookProps={initialProps} />,\n renderOptions,\n );\n\n return {\n result: result,\n rerender: (hookProps: Props) => rerenderComponent(<HookContainer hookProps={hookProps} />),\n unmount,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAAkC,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,g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,EAAGT,SAAgB,IAAKU,iBAAiB,cAACxC,KAAA,CAAA2C,aAAA,CAACd,aAAa;MAACC,SAAS,EAAEA;IAAU,CAAE,CAAC,CAAC;IAC1FW;EACF,CAAC;AACH","ignoreList":[]}
|
package/build/render.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type
|
|
2
|
+
import { type JsonElement, type TestInstance } from 'test-renderer';
|
|
3
3
|
import type { DebugOptions } from './helpers/debug';
|
|
4
4
|
export interface RenderOptions {
|
|
5
5
|
/**
|
|
@@ -7,11 +7,10 @@ export interface RenderOptions {
|
|
|
7
7
|
* reusable custom render functions for common data providers.
|
|
8
8
|
*/
|
|
9
9
|
wrapper?: React.ComponentType<any>;
|
|
10
|
-
createNodeMock?: (element: React.ReactElement) => object;
|
|
11
10
|
}
|
|
12
11
|
export type RenderResult = Awaited<ReturnType<typeof render>>;
|
|
13
12
|
/**
|
|
14
|
-
* Renders test component deeply using
|
|
13
|
+
* Renders test component deeply using Test Renderer and exposes helpers
|
|
15
14
|
* to assert on the output.
|
|
16
15
|
*/
|
|
17
16
|
export declare function render<T>(element: React.ReactElement<T>, options?: RenderOptions): Promise<{
|
|
@@ -19,8 +18,8 @@ export declare function render<T>(element: React.ReactElement<T>, options?: Rend
|
|
|
19
18
|
unmount: () => Promise<void>;
|
|
20
19
|
toJSON: () => JsonElement | null;
|
|
21
20
|
debug: DebugFunction;
|
|
22
|
-
container:
|
|
23
|
-
root:
|
|
21
|
+
container: TestInstance;
|
|
22
|
+
root: TestInstance | null;
|
|
24
23
|
getByRole: import("./queries/make-queries").GetByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
|
|
25
24
|
getAllByRole: import("./queries/make-queries").GetAllByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
|
|
26
25
|
queryByRole: import("./queries/make-queries").QueryByQuery<import("./queries/role").ByRoleMatcher, import("./queries/role").ByRoleOptions>;
|
package/build/render.js
CHANGED
|
@@ -11,22 +11,29 @@ var _cleanup = require("./cleanup");
|
|
|
11
11
|
var _config = require("./config");
|
|
12
12
|
var _debug = require("./helpers/debug");
|
|
13
13
|
var _hostComponentNames = require("./helpers/host-component-names");
|
|
14
|
+
var _validateOptions = require("./helpers/validate-options");
|
|
14
15
|
var _screen = require("./screen");
|
|
15
16
|
var _within = require("./within");
|
|
16
17
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
18
|
/**
|
|
18
|
-
* Renders test component deeply using
|
|
19
|
+
* Renders test component deeply using Test Renderer and exposes helpers
|
|
19
20
|
* to assert on the output.
|
|
20
21
|
*/
|
|
21
22
|
async function render(element, options = {}) {
|
|
22
23
|
const {
|
|
23
24
|
wrapper: Wrapper,
|
|
24
|
-
|
|
25
|
+
...rest
|
|
25
26
|
} = options || {};
|
|
27
|
+
(0, _validateOptions.validateOptions)('render', rest, render);
|
|
26
28
|
const rendererOptions = {
|
|
27
29
|
textComponentTypes: _hostComponentNames.HOST_TEXT_NAMES,
|
|
28
30
|
publicTextComponentTypes: ['Text'],
|
|
29
|
-
|
|
31
|
+
transformHiddenInstanceProps: ({
|
|
32
|
+
props
|
|
33
|
+
}) => ({
|
|
34
|
+
...props,
|
|
35
|
+
style: withHiddenStyle(props.style)
|
|
36
|
+
})
|
|
30
37
|
};
|
|
31
38
|
const wrap = element => Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element;
|
|
32
39
|
const renderer = (0, _testRenderer.createRoot)(rendererOptions);
|
|
@@ -46,18 +53,17 @@ async function render(element, options = {}) {
|
|
|
46
53
|
};
|
|
47
54
|
const toJSON = () => {
|
|
48
55
|
const json = renderer.container.toJSON();
|
|
49
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
50
56
|
if (json?.children.length === 0) {
|
|
51
57
|
return null;
|
|
52
58
|
}
|
|
53
|
-
if (json?.children
|
|
59
|
+
if (json?.children.length === 1 && typeof json.children[0] !== 'string') {
|
|
54
60
|
return json.children[0];
|
|
55
61
|
}
|
|
56
62
|
return json;
|
|
57
63
|
};
|
|
58
64
|
(0, _cleanup.addToCleanupQueue)(unmount);
|
|
59
65
|
const result = {
|
|
60
|
-
...(0, _within.
|
|
66
|
+
...(0, _within.getQueriesForInstance)(renderer.container),
|
|
61
67
|
rerender,
|
|
62
68
|
unmount,
|
|
63
69
|
toJSON,
|
|
@@ -93,4 +99,14 @@ function makeDebug(renderer) {
|
|
|
93
99
|
}
|
|
94
100
|
return debugImpl;
|
|
95
101
|
}
|
|
102
|
+
function withHiddenStyle(style) {
|
|
103
|
+
if (style == null) {
|
|
104
|
+
return {
|
|
105
|
+
display: 'none'
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return [style, {
|
|
109
|
+
display: 'none'
|
|
110
|
+
}];
|
|
111
|
+
}
|
|
96
112
|
//# sourceMappingURL=render.js.map
|
package/build/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","
|
|
1
|
+
{"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_validateOptions","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","rest","validateOptions","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","transformHiddenInstanceProps","props","style","withHiddenStyle","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForInstance","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions","display"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport type { StyleProp } from 'react-native';\nimport {\n createRoot,\n type JsonElement,\n type Root,\n type RootOptions,\n type TestInstance,\n} from 'test-renderer';\n\nimport { act } from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { HOST_TEXT_NAMES } from './helpers/host-component-names';\nimport { validateOptions } from './helpers/validate-options';\nimport { setRenderResult } from './screen';\nimport { getQueriesForInstance } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n}\n\nexport type RenderResult = Awaited<ReturnType<typeof render>>;\n\n/**\n * Renders test component deeply using Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {\n const { wrapper: Wrapper, ...rest } = options || {};\n validateOptions('render', rest, render);\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n transformHiddenInstanceProps: ({ props }) => ({\n ...props,\n style: withHiddenStyle(props.style as StyleProp<StyleLike>),\n }),\n };\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = createRoot(rendererOptions);\n\n await act(() => {\n renderer.render(wrap(element));\n });\n\n const container = renderer.container;\n\n const rerender = async (component: React.ReactElement) => {\n await act(() => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = async () => {\n await act(() => {\n renderer.unmount();\n });\n };\n\n const toJSON = (): JsonElement | null => {\n const json = renderer.container.toJSON();\n if (json?.children.length === 0) {\n return null;\n }\n\n if (json?.children.length === 1 && typeof json.children[0] !== 'string') {\n return json.children[0];\n }\n\n return json;\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForInstance(renderer.container),\n rerender,\n unmount,\n toJSON,\n debug: makeDebug(renderer),\n get container(): TestInstance {\n return renderer.container;\n },\n get root(): TestInstance | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n /* istanbul ignore next */\n throw new Error(\n 'Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.',\n );\n }\n\n return firstChild;\n },\n };\n\n setRenderResult(result);\n\n return result;\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: Root): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...defaultDebugOptions, ...options };\n const json = renderer.container.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n\ntype StyleLike = Record<string, unknown>;\n\nfunction withHiddenStyle(style: StyleProp<StyleLike>): StyleProp<StyleLike> {\n if (style == null) {\n return { display: 'none' };\n }\n\n return [style, { display: 'none' }];\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,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IACjB,OAAO;MAAE4B,OAAO,EAAE;IAAO,CAAC;EAC5B;EAEA,OAAO,CAAC5B,KAAK,EAAE;IAAE4B,OAAO,EAAE;EAAO,CAAC,CAAC;AACrC","ignoreList":[]}
|
package/build/screen.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","defaultScreen","isDetached","container","root","debug","rerender","unmount","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"screen.js","names":["SCREEN_ERROR","notImplemented","Error","defaultScreen","isDetached","container","root","debug","rerender","unmount","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","exports","setRenderResult","renderResult","clearRenderResult"],"sources":["../src/screen.ts"],"sourcesContent":["import type { TestInstance } from 'test-renderer';\n\nimport type { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` function has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\ninterface Screen extends RenderResult {\n isDetached?: boolean;\n}\n\nconst defaultScreen: Screen = {\n isDetached: true,\n get container(): TestInstance {\n throw new Error(SCREEN_ERROR);\n },\n get root(): TestInstance | null {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplemented,\n rerender: notImplemented,\n unmount: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: Screen = defaultScreen;\n\nexport function setRenderResult(renderResult: RenderResult) {\n screen = renderResult;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"mappings":";;;;;;;;AAIA,MAAMA,YAAY,GAAG,uCAAuC;AAE5D,MAAMC,cAAc,GAAGA,CAAA,KAAM;EAC3B,MAAM,IAAIC,KAAK,CAACF,YAAY,CAAC;AAC/B,CAAC;AAMD,MAAMG,aAAqB,GAAG;EAC5BC,UAAU,EAAE,IAAI;EAChB,IAAIC,SAASA,CAAA,EAAiB;IAC5B,MAAM,IAAIH,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACD,IAAIM,IAAIA,CAAA,EAAwB;IAC9B,MAAM,IAAIJ,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACDO,KAAK,EAAEN,cAAc;EACrBO,QAAQ,EAAEP,cAAc;EACxBQ,OAAO,EAAER,cAAc;EACvBS,MAAM,EAAET,cAAc;EACtBU,cAAc,EAAEV,cAAc;EAC9BW,iBAAiB,EA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ACrCoD,WAAW,EAAEpD,cAAc;EAC3BqD,cAAc,EAAErD,cAAc;EAC9BsD,aAAa,EAAEtD,cAAc;EAC7BuD,gBAAgB,EAAEvD,cAAc;EAChCwD,YAAY,EAAExD,cAAc;EAC5ByD,eAAe,EAAEzD,cAAc;EAC/B0D,SAAS,EAAE1D,cAAc;EACzB2D,YAAY,EAAE3D,cAAc;EAC5B4D,WAAW,EAAE5D,cAAc;EAC3B6D,cAAc,EAAE7D,cAAc;EAC9B8D,UAAU,EAAE9D,cAAc;EAC1B+D,aAAa,EAAE/D;AACjB,CAAC;AAEM,IAAIgE,MAAc,GAAAC,OAAA,CAAAD,MAAA,GAAG9D,aAAa;AAElC,SAASgE,eAAeA,CAACC,YAA0B,EAAE;EAC1DF,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAGG,YAAY;AACvB;AAEO,SAASC,iBAAiBA,CAAA,EAAG;EAClCH,OAAA,CAAAD,MAAA,GAAAA,MAAM,GAAG9D,aAAa;AACxB","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const testGateReact19_2: jest.It;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.testGateReact19_2 = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
10
|
+
const testRendererVersion = require('test-renderer/package.json').version;
|
|
11
|
+
function isVersionAtLeast(versionString, targetMajor, targetMinor, targetPatch) {
|
|
12
|
+
const match = /^(\d+)\.(\d+)\.(\d+)/.exec(versionString);
|
|
13
|
+
if (!match) {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
const major = Number(match[1]);
|
|
17
|
+
const minor = Number(match[2]);
|
|
18
|
+
const patch = Number(match[3]);
|
|
19
|
+
if (major !== targetMajor) {
|
|
20
|
+
return major > targetMajor;
|
|
21
|
+
}
|
|
22
|
+
if (minor !== targetMinor) {
|
|
23
|
+
return minor > targetMinor;
|
|
24
|
+
}
|
|
25
|
+
return patch >= targetPatch;
|
|
26
|
+
}
|
|
27
|
+
const testGateReact19_2 = exports.testGateReact19_2 = isVersionAtLeast(_react.default.version, 19, 2, 0) && isVersionAtLeast(testRendererVersion, 1, 2, 0) ? test : test.skip;
|
|
28
|
+
//# sourceMappingURL=react-version-gates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react-version-gates.js","names":["_react","_interopRequireDefault","require","e","__esModule","default","testRendererVersion","version","isVersionAtLeast","versionString","targetMajor","targetMinor","targetPatch","match","exec","major","Number","minor","patch","testGateReact19_2","exports","React","test","skip"],"sources":["../../src/test-utils/react-version-gates.ts"],"sourcesContent":["import React from 'react';\n// eslint-disable-next-line @typescript-eslint/no-require-imports\nconst testRendererVersion = require('test-renderer/package.json').version;\n\nfunction isVersionAtLeast(\n versionString: string,\n targetMajor: number,\n targetMinor: number,\n targetPatch: number,\n): boolean {\n const match = /^(\\d+)\\.(\\d+)\\.(\\d+)/.exec(versionString);\n\n if (!match) {\n return false;\n }\n\n const major = Number(match[1]);\n const minor = Number(match[2]);\n const patch = Number(match[3]);\n\n if (major !== targetMajor) {\n return major > targetMajor;\n }\n\n if (minor !== targetMinor) {\n return minor > targetMinor;\n }\n\n return patch >= targetPatch;\n}\n\nexport const testGateReact19_2 =\n isVersionAtLeast(React.version, 19, 2, 0) && isVersionAtLeast(testRendererVersion, 1, 2, 0)\n ? test\n : test.skip;\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAC1B;AACA,MAAMG,mBAAmB,GAAGJ,OAAO,CAAC,4BAA4B,CAAC,CAACK,OAAO;AAEzE,SAASC,gBAAgBA,CACvBC,aAAqB,EACrBC,WAAmB,EACnBC,WAAmB,EACnBC,WAAmB,EACV;EACT,MAAMC,KAAK,GAAG,sBAAsB,CAACC,IAAI,CAACL,aAAa,CAAC;EAExD,IAAI,CAACI,KAAK,EAAE;IACV,OAAO,KAAK;EACd;EAEA,MAAME,KAAK,GAAGC,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9B,MAAMI,KAAK,GAAGD,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAC9B,MAAMK,KAAK,GAAGF,MAAM,CAACH,KAAK,CAAC,CAAC,CAAC,CAAC;EAE9B,IAAIE,KAAK,KAAKL,WAAW,EAAE;IACzB,OAAOK,KAAK,GAAGL,WAAW;EAC5B;EAEA,IAAIO,KAAK,KAAKN,WAAW,EAAE;IACzB,OAAOM,KAAK,GAAGN,WAAW;EAC5B;EAEA,OAAOO,KAAK,IAAIN,WAAW;AAC7B;AAEO,MAAMO,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAC5BX,gBAAgB,CAACa,cAAK,CAACd,OAAO,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAIC,gBAAgB,CAACF,mBAAmB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GACvFgB,IAAI,GACJA,IAAI,CAACC,IAAI","ignoreList":[]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.setupTimeType = setupTimeType;
|
|
7
|
+
function setupTimeType(type) {
|
|
8
|
+
if (type === 'fake-legacy') {
|
|
9
|
+
jest.useFakeTimers({
|
|
10
|
+
legacyFakeTimers: true
|
|
11
|
+
});
|
|
12
|
+
} else if (type === 'fake') {
|
|
13
|
+
jest.useFakeTimers({
|
|
14
|
+
legacyFakeTimers: false
|
|
15
|
+
});
|
|
16
|
+
} else {
|
|
17
|
+
jest.useRealTimers();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=timers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timers.js","names":["setupTimeType","type","jest","useFakeTimers","legacyFakeTimers","useRealTimers"],"sources":["../../src/test-utils/timers.ts"],"sourcesContent":["export type TimerType = 'real' | 'fake' | 'fake-legacy';\n\nexport function setupTimeType(type: TimerType): void {\n if (type === 'fake-legacy') {\n jest.useFakeTimers({ legacyFakeTimers: true });\n } else if (type === 'fake') {\n jest.useFakeTimers({ legacyFakeTimers: false });\n } else {\n jest.useRealTimers();\n }\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CAACC,IAAe,EAAQ;EACnD,IAAIA,IAAI,KAAK,aAAa,EAAE;IAC1BC,IAAI,CAACC,aAAa,CAAC;MAAEC,gBAAgB,EAAE;IAAK,CAAC,CAAC;EAChD,CAAC,MAAM,IAAIH,IAAI,KAAK,MAAM,EAAE;IAC1BC,IAAI,CAACC,aAAa,CAAC;MAAEC,gBAAgB,EAAE;IAAM,CAAC,CAAC;EACjD,CAAC,MAAM;IACLF,IAAI,CAACG,aAAa,CAAC,CAAC;EACtB;AACF","ignoreList":[]}
|
package/build/types.d.ts
CHANGED
package/build/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** `RefObject` type from React 19. */\nexport type RefObject<T> = {\n current: T;\n};\n\n/**\n * Location of an element.\n */\nexport interface Point {\n y: number;\n x: number;\n}\n\n/**\n * Size of an element.\n */\nexport interface Size {\n height: number;\n width: number;\n}\n\n// TS autocomplete trick\n// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939\nexport type StringWithAutocomplete<T> = T | (string & {});\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["/** `RefObject` type from React 19. */\nexport type RefObject<T> = {\n current: T;\n};\n\n/**\n * Location of an element.\n */\nexport interface Point {\n y: number;\n x: number;\n}\n\n/**\n * Size of an element.\n */\nexport interface Size {\n height: number;\n width: number;\n}\n\n/**\n * Range of text in a text input.\n */\nexport interface TextRange {\n start: number;\n end: number;\n}\n\n// TS autocomplete trick\n// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939\nexport type StringWithAutocomplete<T> = T | (string & {});\n"],"mappings":"","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { TestInstance } from 'test-renderer';
|
|
2
2
|
import type { UserEventInstance } from './setup';
|
|
3
|
-
export declare function clear(this: UserEventInstance,
|
|
3
|
+
export declare function clear(this: UserEventInstance, instance: TestInstance): Promise<void>;
|