@testing-library/react-native 14.0.0-alpha.5 → 14.0.0-beta.0
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 +18 -7
- package/build/act.d.ts +0 -3
- package/build/act.js +2 -3
- package/build/act.js.map +1 -1
- package/build/config.js +10 -4
- package/build/config.js.map +1 -1
- 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 +2 -11
- package/build/fire-event.js +0 -32
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +1 -1
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +1 -1
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug.d.ts +1 -1
- package/build/helpers/debug.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 +1 -1
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-element.d.ts +1 -1
- package/build/helpers/format-element.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +1 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-state.d.ts +1 -1
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.d.ts +1 -1
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +1 -1
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-text-content.d.ts +1 -1
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/pointer-events.d.ts +1 -1
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/text-content.d.ts +1 -1
- package/build/helpers/text-content.js.map +1 -1
- package/build/helpers/text-input.d.ts +1 -1
- 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 +1 -1
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.d.ts +1 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-disabled.d.ts +1 -1
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.d.ts +1 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.d.ts +1 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.d.ts +1 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.d.ts +1 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.d.ts +1 -1
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.d.ts +1 -1
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.d.ts +1 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.d.ts +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.d.ts +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.d.ts +1 -1
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-prop.d.ts +1 -1
- package/build/matchers/to-have-prop.js.map +1 -1
- package/build/matchers/to-have-style.d.ts +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.d.ts +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.d.ts +1 -1
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.d.ts +1 -1
- package/build/matchers/utils.js.map +1 -1
- package/build/native-state.d.ts +1 -1
- package/build/native-state.js.map +1 -1
- package/build/pure.d.ts +5 -7
- package/build/pure.js +0 -31
- package/build/pure.js.map +1 -1
- package/build/queries/display-value.d.ts +1 -1
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +1 -1
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +1 -1
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.d.ts +1 -1
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +1 -1
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +1 -1
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +1 -1
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +1 -1
- package/build/queries/text.js.map +1 -1
- package/build/render-hook.d.ts +0 -8
- package/build/render-hook.js +7 -39
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +2 -3
- package/build/render.js +12 -9
- package/build/render.js.map +1 -1
- package/build/screen.js +0 -1
- package/build/screen.js.map +1 -1
- package/build/test-utils/json.d.ts +1 -1
- package/build/test-utils/json.js.map +1 -1
- 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/tsconfig.release.tsbuildinfo +1 -1
- package/build/user-event/clear.d.ts +1 -1
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/base.d.ts +5 -1
- package/build/user-event/event-builder/base.js +1 -1
- package/build/user-event/event-builder/base.js.map +1 -1
- package/build/user-event/event-builder/common.d.ts +5 -0
- package/build/user-event/event-builder/index.d.ts +12 -0
- package/build/user-event/event-builder/scroll-view.d.ts +1 -0
- package/build/user-event/event-builder/text-input.d.ts +6 -0
- package/build/user-event/index.d.ts +1 -1
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/paste.d.ts +1 -1
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/press.d.ts +1 -1
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.d.ts +1 -1
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +1 -1
- 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 +1 -1
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/dispatch-event.d.ts +1 -1
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/wait-for.js +8 -13
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +1 -1
- package/build/within.js.map +1 -1
- package/package.json +11 -10
- 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/unsafe-render-sync.d.ts +0 -144
- package/build/unsafe-render-sync.js +0 -114
- package/build/unsafe-render-sync.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","element","queryAllByTestIdFn","queryOptions","findAll","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 { HostElement } from '
|
|
1
|
+
{"version":3,"file":"test-id.js","names":["_findAll","require","_matches","_makeQueries","matchTestId","node","testId","options","exact","normalizer","matches","props","testID","queryAllByTestId","element","queryAllByTestIdFn","queryOptions","findAll","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 { HostElement } 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 = (node: HostElement, testId: TextMatch, options: TextMatchOptions = {}) => {\n const { exact, normalizer } = options;\n return matches(testId, node.props.testID, normalizer, exact);\n};\n\nconst queryAllByTestId = (element: HostElement): QueryAllByQuery<TextMatch, ByTestIdOptions> =>\n function queryAllByTestIdFn(testId, queryOptions) {\n return findAll(element, (node) => matchTestId(node, 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 = (element: HostElement): ByTestIdQueries => ({\n getByTestId: getBy(element),\n getAllByTestId: getAllBy(element),\n queryByTestId: queryBy(element),\n queryAllByTestId: queryAllBy(element),\n findByTestId: findBy(element),\n findAllByTestId: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AASA,IAAAE,YAAA,GAAAF,OAAA;AAKA,MAAMG,WAAW,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@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { HostElement } from '
|
|
1
|
+
import type { HostElement } 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';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","element","queryAllByTextFn","text","options","findAll","node","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 { HostElement } from '
|
|
1
|
+
{"version":3,"file":"text.js","names":["_findAll","require","_hostComponentNames","_matchTextContent","_makeQueries","queryAllByText","element","queryAllByTextFn","text","options","findAll","node","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 { HostElement } 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 = (element: HostElement): QueryAllByQuery<TextMatch, ByTextOptions> =>\n function queryAllByTextFn(text, options = {}) {\n return findAll(element, (node) => isHostText(node) && matchTextContent(node, 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 = (element: HostElement): ByTextQueries => ({\n getByText: getBy(element),\n getAllByText: getAllBy(element),\n queryByText: queryBy(element),\n queryAllByText: queryAllBy(element),\n findByText: findBy(element),\n findAllByText: findAllBy(element),\n});\n"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAUA,IAAAG,YAAA,GAAAH,OAAA;AAKA,MAAMI,cAAc,GAAIC,OAAoB,IAC1C,SAASC,gBAAgBA,CAACC,IAAI,EAAEC,OAAO,GAAG,CAAC,CAAC,EAAE;EAC5C,OAAO,IAAAC,gBAAO,EAACJ,OAAO,EAAGK,IAAI,IAAK,IAAAC,8BAAU,EAACD,IAAI,CAAC,IAAI,IAAAE,kCAAgB,EAACF,IAAI,EAAEH,IAAI,EAAEC,OAAO,CAAC,EAAE;IAC3F,GAAGA,OAAO;IACVK,gBAAgB,EAAE;EACpB,CAAC,CAAC;AACJ,CAAC;AAEH,MAAMC,gBAAgB,GAAIP,IAAe,IAAK,sCAAsCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAElG,MAAMS,eAAe,GAAIT,IAAe,IAAK,wCAAwCQ,MAAM,CAACR,IAAI,CAAC,EAAE;AAEnG,MAAM;EAAEU,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EnB,cAAc,EACdY,eAAe,EACfF,gBACF,CAAC;AAWM,MAAMU,iBAAiB,GAAInB,OAAoB,KAAqB;EACzEoB,SAAS,EAAER,KAAK,CAACZ,OAAO,CAAC;EACzBqB,YAAY,EAAER,QAAQ,CAACb,OAAO,CAAC;EAC/BsB,WAAW,EAAER,OAAO,CAACd,OAAO,CAAC;EAC7BD,cAAc,EAAEgB,UAAU,CAACf,OAAO,CAAC;EACnCuB,UAAU,EAAEP,MAAM,CAAChB,OAAO,CAAC;EAC3BwB,aAAa,EAAEP,SAAS,CAACjB,OAAO;AAClC,CAAC,CAAC;AAACyB,OAAA,CAAAN,iBAAA,GAAAA,iBAAA","ignoreList":[]}
|
package/build/render-hook.d.ts
CHANGED
|
@@ -5,12 +5,6 @@ export type RenderHookResult<Result, Props> = {
|
|
|
5
5
|
rerender: (props: Props) => Promise<void>;
|
|
6
6
|
unmount: () => Promise<void>;
|
|
7
7
|
};
|
|
8
|
-
/** @deprecated - Use `renderHook` and `RenderHookResult` instead. */
|
|
9
|
-
export type RenderHookSyncResult<Result, Props> = {
|
|
10
|
-
result: RefObject<Result>;
|
|
11
|
-
rerender: (props: Props) => void;
|
|
12
|
-
unmount: () => void;
|
|
13
|
-
};
|
|
14
8
|
export type RenderHookOptions<Props> = {
|
|
15
9
|
/**
|
|
16
10
|
* The initial props to pass to the hook.
|
|
@@ -23,5 +17,3 @@ export type RenderHookOptions<Props> = {
|
|
|
23
17
|
wrapper?: React.ComponentType<any>;
|
|
24
18
|
};
|
|
25
19
|
export declare function renderHook<Result, Props>(hookToRender: (props: Props) => Result, options?: RenderHookOptions<NoInfer<Props>>): Promise<RenderHookResult<Result, Props>>;
|
|
26
|
-
/** @deprecated - Use async `renderHook` instead. */
|
|
27
|
-
export declare function unsafe_renderHookSync<Result, Props>(hookToRender: (props: Props) => Result, options?: RenderHookOptions<NoInfer<Props>>): RenderHookSyncResult<Result, Props>;
|
package/build/render-hook.js
CHANGED
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.renderHook = renderHook;
|
|
7
|
-
exports.unsafe_renderHookSync = unsafe_renderHookSync;
|
|
8
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _validateOptions = require("./helpers/validate-options");
|
|
9
9
|
var _render = require("./render");
|
|
10
|
-
var _unsafeRenderSync = require("./unsafe-render-sync");
|
|
11
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); }
|
|
12
|
-
/** @deprecated - Use `renderHook` and `RenderHookResult` instead. */
|
|
13
|
-
|
|
14
11
|
async function renderHook(hookToRender, options) {
|
|
15
12
|
const result = /*#__PURE__*/React.createRef();
|
|
16
13
|
function HookContainer({
|
|
@@ -24,8 +21,13 @@ async function renderHook(hookToRender, options) {
|
|
|
24
21
|
}
|
|
25
22
|
const {
|
|
26
23
|
initialProps,
|
|
27
|
-
|
|
24
|
+
wrapper,
|
|
25
|
+
...rest
|
|
28
26
|
} = options ?? {};
|
|
27
|
+
(0, _validateOptions.validateOptions)('renderHook', rest, renderHook);
|
|
28
|
+
const renderOptions = wrapper ? {
|
|
29
|
+
wrapper
|
|
30
|
+
} : {};
|
|
29
31
|
const {
|
|
30
32
|
rerender: rerenderComponent,
|
|
31
33
|
unmount
|
|
@@ -43,38 +45,4 @@ async function renderHook(hookToRender, options) {
|
|
|
43
45
|
unmount
|
|
44
46
|
};
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
/** @deprecated - Use async `renderHook` instead. */
|
|
48
|
-
function unsafe_renderHookSync(hookToRender, options) {
|
|
49
|
-
const result = /*#__PURE__*/React.createRef();
|
|
50
|
-
function HookContainer({
|
|
51
|
-
hookProps
|
|
52
|
-
}) {
|
|
53
|
-
const renderResult = hookToRender(hookProps);
|
|
54
|
-
React.useEffect(() => {
|
|
55
|
-
result.current = renderResult;
|
|
56
|
-
});
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
const {
|
|
60
|
-
initialProps,
|
|
61
|
-
...renderOptions
|
|
62
|
-
} = options ?? {};
|
|
63
|
-
const {
|
|
64
|
-
rerender: rerenderComponent,
|
|
65
|
-
unmount
|
|
66
|
-
} = (0, _unsafeRenderSync.unsafe_renderSync)(
|
|
67
|
-
/*#__PURE__*/
|
|
68
|
-
// @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt
|
|
69
|
-
React.createElement(HookContainer, {
|
|
70
|
-
hookProps: initialProps
|
|
71
|
-
}), renderOptions);
|
|
72
|
-
return {
|
|
73
|
-
result: result,
|
|
74
|
-
rerender: hookProps => rerenderComponent(/*#__PURE__*/React.createElement(HookContainer, {
|
|
75
|
-
hookProps: hookProps
|
|
76
|
-
})),
|
|
77
|
-
unmount
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
48
|
//# sourceMappingURL=render-hook.js.map
|
package/build/render-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","
|
|
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,wBAA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AAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,YAAY;IAAEC,OAAO;IAAE,GAAGC;EAAK,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACxD,IAAAW,gCAAe,EAAC,YAAY,EAAED,IAAI,EAAEZ,UAAU,CAAC;EAC/C,MAAMc,aAAa,GAAGH,OAAO,GAAG;IAAEA;EAAQ,CAAC,GAAG,CAAC,CAAC;EAChD,MAAM;IAAEI,QAAQ,EAAEC,iBAAiB;IAAEC;EAAQ,CAAC,GAAG,MAAM,IAAAC,cAAM;EAAA;EAC3D;EACA1C,KAAA,CAAA2C,aAAA,CAACd,aAAa;IAACC,SAAS,EAAEI;EAAa,CAAE,CAAC,EAC1CI,aACF,CAAC;EAED,OAAO;IACLX,MAAM,EAAEA,MAAM;IACdY,QAAQ,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 HostElement, type JsonElement } from '
|
|
2
|
+
import { type HostElement, type JsonElement } from 'test-renderer';
|
|
3
3
|
import type { DebugOptions } from './helpers/debug';
|
|
4
4
|
export interface RenderOptions {
|
|
5
5
|
/**
|
|
@@ -11,12 +11,11 @@ export interface RenderOptions {
|
|
|
11
11
|
}
|
|
12
12
|
export type RenderResult = Awaited<ReturnType<typeof render>>;
|
|
13
13
|
/**
|
|
14
|
-
* Renders test component deeply using
|
|
14
|
+
* Renders test component deeply using Test Renderer and exposes helpers
|
|
15
15
|
* to assert on the output.
|
|
16
16
|
*/
|
|
17
17
|
export declare function render<T>(element: React.ReactElement<T>, options?: RenderOptions): Promise<{
|
|
18
18
|
rerender: (component: React.ReactElement) => Promise<void>;
|
|
19
|
-
update: (component: React.ReactElement) => Promise<void>;
|
|
20
19
|
unmount: () => Promise<void>;
|
|
21
20
|
toJSON: () => JsonElement | null;
|
|
22
21
|
debug: DebugFunction;
|
package/build/render.js
CHANGED
|
@@ -5,30 +5,34 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.render = render;
|
|
7
7
|
var React = _interopRequireWildcard(require("react"));
|
|
8
|
-
var
|
|
8
|
+
var _testRenderer = require("test-renderer");
|
|
9
9
|
var _act = require("./act");
|
|
10
10
|
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
|
-
createNodeMock
|
|
25
|
+
createNodeMock,
|
|
26
|
+
...rest
|
|
25
27
|
} = options || {};
|
|
28
|
+
(0, _validateOptions.validateOptions)('render', rest, render);
|
|
26
29
|
const rendererOptions = {
|
|
27
|
-
|
|
30
|
+
textComponentTypes: _hostComponentNames.HOST_TEXT_NAMES,
|
|
31
|
+
publicTextComponentTypes: ['Text'],
|
|
28
32
|
createNodeMock
|
|
29
33
|
};
|
|
30
34
|
const wrap = element => Wrapper ? /*#__PURE__*/React.createElement(Wrapper, null, element) : element;
|
|
31
|
-
const renderer = (0,
|
|
35
|
+
const renderer = (0, _testRenderer.createRoot)(rendererOptions);
|
|
32
36
|
await (0, _act.act)(() => {
|
|
33
37
|
renderer.render(wrap(element));
|
|
34
38
|
});
|
|
@@ -45,10 +49,10 @@ async function render(element, options = {}) {
|
|
|
45
49
|
};
|
|
46
50
|
const toJSON = () => {
|
|
47
51
|
const json = renderer.container.toJSON();
|
|
48
|
-
if (json?.children
|
|
52
|
+
if (json?.children.length === 0) {
|
|
49
53
|
return null;
|
|
50
54
|
}
|
|
51
|
-
if (json?.children
|
|
55
|
+
if (json?.children.length === 1 && typeof json.children[0] !== 'string') {
|
|
52
56
|
return json.children[0];
|
|
53
57
|
}
|
|
54
58
|
return json;
|
|
@@ -57,8 +61,6 @@ async function render(element, options = {}) {
|
|
|
57
61
|
const result = {
|
|
58
62
|
...(0, _within.getQueriesForElement)(renderer.container),
|
|
59
63
|
rerender,
|
|
60
|
-
update: rerender,
|
|
61
|
-
// alias for `rerender`
|
|
62
64
|
unmount,
|
|
63
65
|
toJSON,
|
|
64
66
|
debug: makeDebug(renderer),
|
|
@@ -68,6 +70,7 @@ async function render(element, options = {}) {
|
|
|
68
70
|
get root() {
|
|
69
71
|
const firstChild = container.children[0];
|
|
70
72
|
if (typeof firstChild === 'string') {
|
|
73
|
+
/* istanbul ignore next */
|
|
71
74
|
throw new Error('Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.');
|
|
72
75
|
}
|
|
73
76
|
return firstChild;
|
package/build/render.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","
|
|
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","createNodeMock","rest","validateOptions","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForElement","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n createRoot,\n type HostElement,\n type JsonElement,\n type Root,\n type RootOptions,\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 { getQueriesForElement } 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 createNodeMock?: (element: React.ReactElement) => object;\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, createNodeMock, ...rest } = options || {};\n validateOptions('render', rest, render);\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n createNodeMock,\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 ...getQueriesForElement(renderer.container),\n rerender,\n unmount,\n toJSON,\n debug: makeDebug(renderer),\n get container(): HostElement {\n return renderer.container;\n },\n get root(): HostElement | 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"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,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,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAgD,SAAAD,wBAAAW,CAAA,EAAAC,C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C,4BAAoB,EAACb,QAAQ,CAACG,SAAS,CAAC;IAC3CC,QAAQ;IACRE,OAAO;IACPC,MAAM;IACNO,KAAK,EAAEC,SAAS,CAACf,QAAQ,CAAC;IAC1B,IAAIG,SAASA,CAAA,EAAgB;MAC3B,OAAOH,QAAQ,CAACG,SAAS;IAC3B,CAAC;IACD,IAAIa,IAAIA,CAAA,EAAuB;MAC7B,MAAMC,UAAU,GAAGd,SAAS,CAACM,QAAQ,CAAC,CAAC,CAAC;MACxC,IAAI,OAAOQ,UAAU,KAAK,QAAQ,EAAE;QAClC;QACA,MAAM,IAAIC,KAAK,CACb,wHACF,CAAC;MACH;MAEA,OAAOD,UAAU;IACnB;EACF,CAAC;EAED,IAAAE,uBAAe,EAACP,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAIA,SAASG,SAASA,CAACf,QAAc,EAAiB;EAChD,SAASoB,SAASA,CAAChC,OAAsB,EAAE;IACzC,MAAM;MAAEiC;IAAoB,CAAC,GAAG,IAAAC,iBAAS,EAAC,CAAC;IAC3C,MAAMC,YAAY,GAAG;MAAE,GAAGF,mBAAmB;MAAE,GAAGjC;IAAQ,CAAC;IAC3D,MAAMoB,IAAI,GAAGR,QAAQ,CAACG,SAAS,CAACI,MAAM,CAAC,CAAC;IACxC,IAAIC,IAAI,EAAE;MACR,OAAO,IAAAM,YAAK,EAACN,IAAI,EAAEe,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
|
package/build/screen.js
CHANGED
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","
|
|
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 { HostElement } 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(): HostElement {\n throw new Error(SCREEN_ERROR);\n },\n get root(): HostElement | 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,EAAgB;IAC3B,MAAM,IAAIH,KAAK,CAACF,YAAY,CAAC;EAC/B,CAAC;EACD,IAAIM,IAAIA,CAAA,EAAuB;IAC7B,MAAM,IAAIJ,KAAK,CAACF,YAAY,CAAC;EAC/B,CA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jC+C,oBAAoB,EAAE/C,cAAc;EACpCgD,mBAAmB,EAAEhD,cAAc;EACnCiD,sBAAsB,EAAEjD,cAAc;EACtCkD,kBAAkB,EAAElD,cAAc;EAClCmD,qBAAqB,EAAEnD,cAAc;EACrCoD,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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.js","names":["mapJsonProps","node","mapper","Array","isArray","map","e","resultProps","props","Object","keys","forEach","key","resultElement","defineProperty","value","Symbol","for"],"sources":["../../src/test-utils/json.ts"],"sourcesContent":["import type { JsonNode } from '
|
|
1
|
+
{"version":3,"file":"json.js","names":["mapJsonProps","node","mapper","Array","isArray","map","e","resultProps","props","Object","keys","forEach","key","resultElement","defineProperty","value","Symbol","for"],"sources":["../../src/test-utils/json.ts"],"sourcesContent":["import type { JsonNode } from 'test-renderer';\n\ntype JsonPropsMapper = {\n [key: string]: unknown;\n};\n\nexport function mapJsonProps<T extends JsonNode | JsonNode[] | null>(\n node: T,\n mapper: JsonPropsMapper,\n): T {\n if (Array.isArray(node)) {\n return node.map((e) => mapJsonProps(e, mapper)) as T;\n }\n\n if (!node || typeof node === 'string') {\n return node;\n }\n\n const resultProps: Record<string, unknown> = { ...node.props };\n Object.keys(mapper).forEach((key) => {\n if (key in node.props) {\n resultProps[key] = mapper[key];\n }\n });\n\n // @ts-expect-error: TODO fix type\n const resultElement = { ...node, props: resultProps };\n Object.defineProperty(resultElement, '$$typeof', {\n value: Symbol.for('react.test.json'),\n });\n\n return resultElement;\n}\n"],"mappings":";;;;;;AAMO,SAASA,YAAYA,CAC1BC,IAAO,EACPC,MAAuB,EACpB;EACH,IAAIC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,EAAE;IACvB,OAAOA,IAAI,CAACI,GAAG,CAAEC,CAAC,IAAKN,YAAY,CAACM,CAAC,EAAEJ,MAAM,CAAC,CAAC;EACjD;EAEA,IAAI,CAACD,IAAI,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IACrC,OAAOA,IAAI;EACb;EAEA,MAAMM,WAAoC,GAAG;IAAE,GAAGN,IAAI,CAACO;EAAM,CAAC;EAC9DC,MAAM,CAACC,IAAI,CAACR,MAAM,CAAC,CAACS,OAAO,CAAEC,GAAG,IAAK;IACnC,IAAIA,GAAG,IAAIX,IAAI,CAACO,KAAK,EAAE;MACrBD,WAAW,CAACK,GAAG,CAAC,GAAGV,MAAM,CAACU,GAAG,CAAC;IAChC;EACF,CAAC,CAAC;;EAEF;EACA,MAAMC,aAAa,GAAG;IAAE,GAAGZ,IAAI;IAAEO,KAAK,EAAED;EAAY,CAAC;EACrDE,MAAM,CAACK,cAAc,CAACD,aAAa,EAAE,UAAU,EAAE;IAC/CE,KAAK,EAAEC,MAAM,CAACC,GAAG,CAAC,iBAAiB;EACrC,CAAC,CAAC;EAEF,OAAOJ,aAAa;AACtB","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":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"root":["../src/act.ts","../src/cleanup.ts","../src/config.ts","../src/event-handler.ts","../src/fire-event.ts","../src/flush-micro-tasks.ts","../src/index.ts","../src/matches.ts","../src/native-state.ts","../src/pure.ts","../src/
|
|
1
|
+
{"root":["../src/act.ts","../src/cleanup.ts","../src/config.ts","../src/event-handler.ts","../src/fire-event.ts","../src/flush-micro-tasks.ts","../src/index.ts","../src/matches.ts","../src/native-state.ts","../src/pure.ts","../src/render-hook.tsx","../src/render.tsx","../src/screen.ts","../src/types.ts","../src/wait-for-element-to-be-removed.ts","../src/wait-for.ts","../src/within.ts","../src/helpers/accessibility.ts","../src/helpers/component-tree.ts","../src/helpers/debug.ts","../src/helpers/errors.ts","../src/helpers/find-all.ts","../src/helpers/format-element.ts","../src/helpers/host-component-names.ts","../src/helpers/logger.ts","../src/helpers/map-props.ts","../src/helpers/object.ts","../src/helpers/pointer-events.ts","../src/helpers/text-content.ts","../src/helpers/text-input.ts","../src/helpers/timers.ts","../src/helpers/validate-options.ts","../src/helpers/wrap-async.ts","../src/helpers/matchers/match-accessibility-state.ts","../src/helpers/matchers/match-accessibility-value.ts","../src/helpers/matchers/match-array-prop.ts","../src/helpers/matchers/match-label-text.ts","../src/helpers/matchers/match-object-prop.ts","../src/helpers/matchers/match-string-prop.ts","../src/helpers/matchers/match-text-content.ts","../src/matchers/extend-expect.ts","../src/matchers/index.ts","../src/matchers/to-be-busy.ts","../src/matchers/to-be-checked.ts","../src/matchers/to-be-disabled.ts","../src/matchers/to-be-empty-element.ts","../src/matchers/to-be-expanded.ts","../src/matchers/to-be-on-the-screen.ts","../src/matchers/to-be-partially-checked.ts","../src/matchers/to-be-selected.ts","../src/matchers/to-be-visible.ts","../src/matchers/to-contain-element.ts","../src/matchers/to-have-accessibility-value.ts","../src/matchers/to-have-accessible-name.ts","../src/matchers/to-have-display-value.ts","../src/matchers/to-have-prop.ts","../src/matchers/to-have-style.ts","../src/matchers/to-have-text-content.ts","../src/matchers/types.ts","../src/matchers/utils.ts","../src/queries/display-value.ts","../src/queries/hint-text.ts","../src/queries/label-text.ts","../src/queries/make-queries.ts","../src/queries/options.ts","../src/queries/placeholder-text.ts","../src/queries/role.ts","../src/queries/test-id.ts","../src/queries/text.ts","../src/test-utils/console.ts","../src/test-utils/events.ts","../src/test-utils/json.ts","../src/test-utils/timers.ts","../src/test-utils/version.ts","../src/user-event/clear.ts","../src/user-event/index.ts","../src/user-event/paste.ts","../src/user-event/event-builder/base.ts","../src/user-event/event-builder/common.ts","../src/user-event/event-builder/index.ts","../src/user-event/event-builder/scroll-view.ts","../src/user-event/event-builder/text-input.ts","../src/user-event/press/index.ts","../src/user-event/press/press.ts","../src/user-event/scroll/index.ts","../src/user-event/scroll/scroll-to.ts","../src/user-event/scroll/utils.ts","../src/user-event/setup/index.ts","../src/user-event/setup/setup.ts","../src/user-event/type/index.ts","../src/user-event/type/parse-keys.ts","../src/user-event/type/type.ts","../src/user-event/utils/content-size.ts","../src/user-event/utils/dispatch-event.ts","../src/user-event/utils/index.ts","../src/user-event/utils/text-range.ts","../src/user-event/utils/wait.ts"],"version":"5.9.3"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clear.js","names":["_errors","require","_hostComponentNames","_pointerEvents","_textInput","_eventBuilder","_type","_utils","clear","element","isHostTextInput","ErrorWithStack","type","isEditableTextInput","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","getTextInputValue","selectionRange","start","end","length","TextInput","selectionChange","emptyText","emitTypingEvents","config","key","text","wait","endEditing","blur"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import type { HostElement } from '
|
|
1
|
+
{"version":3,"file":"clear.js","names":["_errors","require","_hostComponentNames","_pointerEvents","_textInput","_eventBuilder","_type","_utils","clear","element","isHostTextInput","ErrorWithStack","type","isEditableTextInput","isPointerEventEnabled","dispatchEvent","EventBuilder","Common","focus","textToClear","getTextInputValue","selectionRange","start","end","length","TextInput","selectionChange","emptyText","emitTypingEvents","config","key","text","wait","endEditing","blur"],"sources":["../../src/user-event/clear.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport { ErrorWithStack } from '../helpers/errors';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { isPointerEventEnabled } from '../helpers/pointer-events';\nimport { getTextInputValue, isEditableTextInput } from '../helpers/text-input';\nimport { EventBuilder } from './event-builder';\nimport type { UserEventInstance } from './setup';\nimport { emitTypingEvents } from './type/type';\nimport { dispatchEvent, wait } from './utils';\n\nexport async function clear(this: UserEventInstance, element: HostElement): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `clear() only supports host \"TextInput\" elements. Passed element has type: \"${element.type}\".`,\n clear,\n );\n }\n\n if (!isEditableTextInput(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n // 1. Enter element\n await dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n // 2. Select all\n const textToClear = getTextInputValue(element);\n const selectionRange = {\n start: 0,\n end: textToClear.length,\n };\n await dispatchEvent(\n element,\n 'selectionChange',\n EventBuilder.TextInput.selectionChange(selectionRange),\n );\n\n // 3. Press backspace with selected text\n const emptyText = '';\n await emitTypingEvents(element, {\n config: this.config,\n key: 'Backspace',\n text: emptyText,\n });\n\n // 4. Exit element\n await wait(this.config);\n await dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(emptyText));\n await dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEO,eAAeO,KAAKA,CAA0BC,OAAoB,EAAiB;EACxF,IAAI,CAAC,IAAAC,mCAAe,EAACD,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAIE,sBAAc,CACtB,8EAA8EF,OAAO,CAACG,IAAI,IAAI,EAC9FJ,KACF,CAAC;EACH;EAEA,IAAI,CAAC,IAAAK,8BAAmB,EAACJ,OAAO,CAAC,IAAI,CAAC,IAAAK,oCAAqB,EAACL,OAAO,CAAC,EAAE;IACpE;EACF;;EAEA;EACA,MAAM,IAAAM,oBAAa,EAACN,OAAO,EAAE,OAAO,EAAEO,0BAAY,CAACC,MAAM,CAACC,KAAK,CAAC,CAAC,CAAC;;EAElE;EACA,MAAMC,WAAW,GAAG,IAAAC,4BAAiB,EAACX,OAAO,CAAC;EAC9C,MAAMY,cAAc,GAAG;IACrBC,KAAK,EAAE,CAAC;IACRC,GAAG,EAAEJ,WAAW,CAACK;EACnB,CAAC;EACD,MAAM,IAAAT,oBAAa,EACjBN,OAAO,EACP,iBAAiB,EACjBO,0BAAY,CAACS,SAAS,CAACC,eAAe,CAACL,cAAc,CACvD,CAAC;;EAED;EACA,MAAMM,SAAS,GAAG,EAAE;EACpB,MAAM,IAAAC,sBAAgB,EAACnB,OAAO,EAAE;IAC9BoB,MAAM,EAAE,IAAI,CAACA,MAAM;IACnBC,GAAG,EAAE,WAAW;IAChBC,IAAI,EAAEJ;EACR,CAAC,CAAC;;EAEF;EACA,MAAM,IAAAK,WAAI,EAAC,IAAI,CAACH,MAAM,CAAC;EACvB,MAAM,IAAAd,oBAAa,EAACN,OAAO,EAAE,YAAY,EAAEO,0BAAY,CAACS,SAAS,CAACQ,UAAU,CAACN,SAAS,CAAC,CAAC;EACxF,MAAM,IAAAZ,oBAAa,EAACN,OAAO,EAAE,MAAM,EAAEO,0BAAY,CAACC,MAAM,CAACiB,IAAI,CAAC,CAAC,CAAC;AAClE","ignoreList":[]}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
import type { BaseSyntheticEvent } from 'react';
|
|
2
2
|
/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */
|
|
3
|
-
|
|
3
|
+
type BaseEvent = Partial<BaseSyntheticEvent<object, unknown, unknown>> & {
|
|
4
|
+
isPersistent: () => boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare function baseSyntheticEvent(): BaseEvent;
|
|
7
|
+
export {};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.baseSyntheticEvent = baseSyntheticEvent;
|
|
7
7
|
/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */
|
|
8
|
+
|
|
8
9
|
function baseSyntheticEvent() {
|
|
9
10
|
return {
|
|
10
11
|
currentTarget: {},
|
|
@@ -14,7 +15,6 @@ function baseSyntheticEvent() {
|
|
|
14
15
|
stopPropagation: () => {},
|
|
15
16
|
isPropagationStopped: () => false,
|
|
16
17
|
persist: () => {},
|
|
17
|
-
// @ts-expect-error: `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods
|
|
18
18
|
isPersistent: () => false,
|
|
19
19
|
timeStamp: 0
|
|
20
20
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":["baseSyntheticEvent","currentTarget","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","persist","isPersistent","timeStamp"],"sources":["../../../src/user-event/event-builder/base.ts"],"sourcesContent":["import type { BaseSyntheticEvent } from 'react';\n\n/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */\
|
|
1
|
+
{"version":3,"file":"base.js","names":["baseSyntheticEvent","currentTarget","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","persist","isPersistent","timeStamp"],"sources":["../../../src/user-event/event-builder/base.ts"],"sourcesContent":["import type { BaseSyntheticEvent } from 'react';\n\n/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */\ntype BaseEvent = Partial<BaseSyntheticEvent<object, unknown, unknown>> & {\n // `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods\n isPersistent: () => boolean;\n};\n\nexport function baseSyntheticEvent(): BaseEvent {\n return {\n currentTarget: {},\n target: {},\n preventDefault: () => {},\n isDefaultPrevented: () => false,\n stopPropagation: () => {},\n isPropagationStopped: () => false,\n persist: () => {},\n isPersistent: () => false,\n timeStamp: 0,\n };\n}\n"],"mappings":";;;;;;AAEA;;AAMO,SAASA,kBAAkBA,CAAA,EAAc;EAC9C,OAAO;IACLC,aAAa,EAAE,CAAC,CAAC;IACjBC,MAAM,EAAE,CAAC,CAAC;IACVC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;IACxBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;IAC/BC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;IACzBC,oBAAoB,EAAEA,CAAA,KAAM,KAAK;IACjCC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;IACjBC,YAAY,EAAEA,CAAA,KAAM,KAAK;IACzBC,SAAS,EAAE;EACb,CAAC;AACH","ignoreList":[]}
|
|
@@ -31,6 +31,7 @@ declare function touch(): {
|
|
|
31
31
|
persist?: (() => void) | undefined;
|
|
32
32
|
timeStamp?: number | undefined;
|
|
33
33
|
type?: string | undefined;
|
|
34
|
+
isPersistent: () => boolean;
|
|
34
35
|
};
|
|
35
36
|
export declare const CommonEventBuilder: {
|
|
36
37
|
touch: typeof touch;
|
|
@@ -65,6 +66,7 @@ export declare const CommonEventBuilder: {
|
|
|
65
66
|
persist?: (() => void) | undefined;
|
|
66
67
|
timeStamp?: number | undefined;
|
|
67
68
|
type?: string | undefined;
|
|
69
|
+
isPersistent: () => boolean;
|
|
68
70
|
};
|
|
69
71
|
responderRelease: () => {
|
|
70
72
|
dispatchConfig: {
|
|
@@ -97,6 +99,7 @@ export declare const CommonEventBuilder: {
|
|
|
97
99
|
persist?: (() => void) | undefined;
|
|
98
100
|
timeStamp?: number | undefined;
|
|
99
101
|
type?: string | undefined;
|
|
102
|
+
isPersistent: () => boolean;
|
|
100
103
|
};
|
|
101
104
|
/**
|
|
102
105
|
* Experimental values:
|
|
@@ -121,6 +124,7 @@ export declare const CommonEventBuilder: {
|
|
|
121
124
|
persist?: (() => void) | undefined;
|
|
122
125
|
timeStamp?: number | undefined;
|
|
123
126
|
type?: string | undefined;
|
|
127
|
+
isPersistent: () => boolean;
|
|
124
128
|
};
|
|
125
129
|
/**
|
|
126
130
|
* Experimental values:
|
|
@@ -145,6 +149,7 @@ export declare const CommonEventBuilder: {
|
|
|
145
149
|
persist?: (() => void) | undefined;
|
|
146
150
|
timeStamp?: number | undefined;
|
|
147
151
|
type?: string | undefined;
|
|
152
|
+
isPersistent: () => boolean;
|
|
148
153
|
};
|
|
149
154
|
};
|
|
150
155
|
export {};
|