@testing-library/react-native 14.0.0-alpha.1 → 14.0.0-alpha.3
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 +7 -11
- package/build/act.d.ts +2 -4
- package/build/act.js +4 -5
- package/build/act.js.map +1 -1
- package/build/cleanup.d.ts +3 -1
- package/build/cleanup.js +8 -0
- package/build/cleanup.js.map +1 -1
- package/build/event-handler.d.ts +2 -2
- package/build/event-handler.js +10 -10
- package/build/event-handler.js.map +1 -1
- package/build/fire-event.d.ts +8 -1
- package/build/fire-event.js +44 -28
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.js +5 -2
- package/build/helpers/accessibility.js.map +1 -1
- package/build/helpers/component-tree.d.ts +8 -8
- package/build/helpers/component-tree.js +19 -16
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug.d.ts +1 -1
- package/build/helpers/debug.js +6 -7
- package/build/helpers/debug.js.map +1 -1
- package/build/helpers/find-all.js +7 -27
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-element.d.ts +3 -3
- 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 +0 -1
- package/build/helpers/host-component-names.js +7 -9
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/logger.d.ts +22 -0
- package/build/helpers/logger.js +13 -8
- package/build/helpers/logger.js.map +1 -1
- package/build/helpers/pointer-events.js +9 -5
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/wrap-async.d.ts +0 -1
- package/build/helpers/wrap-async.js +0 -1
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.d.ts +0 -1
- package/build/index.flow.js +5 -4
- package/build/index.js +1 -12
- package/build/index.js.map +1 -1
- package/build/matchers/to-be-empty-element.js +6 -3
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-visible.js +3 -3
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js +1 -2
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-style.js +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/utils.js +3 -2
- package/build/matchers/utils.js.map +1 -1
- package/build/pure.d.ts +7 -5
- package/build/pure.js +30 -4
- package/build/pure.js.map +1 -1
- package/build/queries/display-value.d.ts +1 -1
- package/build/queries/display-value.js +9 -9
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +1 -1
- package/build/queries/hint-text.js +9 -9
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +1 -1
- package/build/queries/label-text.js +9 -9
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.d.ts +2 -2
- package/build/queries/make-queries.js +11 -11
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +1 -1
- package/build/queries/placeholder-text.js +9 -9
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +2 -2
- package/build/queries/role.js +16 -9
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +1 -1
- package/build/queries/test-id.js +9 -9
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +1 -1
- package/build/queries/text.js +9 -9
- package/build/queries/text.js.map +1 -1
- package/build/react-versions.js +1 -2
- package/build/react-versions.js.map +1 -1
- package/build/render-act.d.ts +3 -0
- package/build/render-act.js +29 -0
- package/build/render-act.js.map +1 -0
- package/build/render-async.d.ts +83 -0
- package/build/render-async.js +96 -0
- package/build/render-async.js.map +1 -0
- package/build/render-hook.d.ts +9 -7
- package/build/render-hook.js +44 -14
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +87 -18
- package/build/render.js +54 -27
- package/build/render.js.map +1 -1
- package/build/screen.js +7 -7
- package/build/screen.js.map +1 -1
- package/build/test-utils/console.d.ts +1 -0
- package/build/test-utils/console.js +17 -0
- package/build/test-utils/console.js.map +1 -0
- package/build/test-utils/json.d.ts +6 -0
- package/build/test-utils/json.js +33 -0
- package/build/test-utils/json.js.map +1 -0
- package/build/tsconfig.release.tsbuildinfo +1 -1
- package/build/types.d.ts +4 -0
- package/build/types.js.map +1 -1
- package/build/user-event/clear.js +4 -4
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/paste.js +8 -8
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/press.js +17 -10
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.js +7 -7
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/type/type.js +11 -11
- 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 +4 -4
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/wait-for.js +3 -1
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +19 -19
- package/build/within.js +8 -8
- package/build/within.js.map +1 -1
- package/package.json +37 -35
- package/typings/index.flow.js +5 -4
- package/build/test-utils/index.d.ts +0 -1
- package/build/test-utils/index.js +0 -17
- package/build/test-utils/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-tree.js","names":["
|
|
1
|
+
{"version":3,"file":"component-tree.js","names":["_screen","require","isHostElement","element","type","isElementMounted","getContainerElement","screen","container","getHostSiblings","parent","children","filter","sibling","current"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import type { HostElement, HostNode } from 'universal-test-renderer';\n\nimport { screen } from '../screen';\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(element?: HostNode | null): element is HostElement {\n return typeof element !== 'string' && typeof element?.type === 'string';\n}\n\nexport function isElementMounted(element: HostElement) {\n return getContainerElement(element) === screen.container;\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(element: HostElement): HostElement[] {\n // Should not happen\n const parent = element.parent;\n if (!parent) {\n return [];\n }\n\n return parent.children.filter(\n (sibling) => typeof sibling !== 'string' && sibling !== element,\n ) as HostElement[];\n}\n\n/**\n * Returns the containerelement of the tree.\n *\n * @param element The element start traversing from.\n * @returns The container element of the tree.\n */\nexport function getContainerElement(element: HostElement) {\n let current = element;\n while (current.parent) {\n current = current.parent;\n }\n\n return current;\n}\n"],"mappings":";;;;;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAACC,OAAyB,EAA0B;EAC/E,OAAO,OAAOA,OAAO,KAAK,QAAQ,IAAI,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ;AACzE;AAEO,SAASC,gBAAgBA,CAACF,OAAoB,EAAE;EACrD,OAAOG,mBAAmB,CAACH,OAAO,CAAC,KAAKI,cAAM,CAACC,SAAS;AAC1D;;AAEA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAACN,OAAoB,EAAiB;EACnE;EACA,MAAMO,MAAM,GAAGP,OAAO,CAACO,MAAM;EAC7B,IAAI,CAACA,MAAM,EAAE;IACX,OAAO,EAAE;EACX;EAEA,OAAOA,MAAM,CAACC,QAAQ,CAACC,MAAM,CAC1BC,OAAO,IAAK,OAAOA,OAAO,KAAK,QAAQ,IAAIA,OAAO,KAAKV,OAC1D,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,mBAAmBA,CAACH,OAAoB,EAAE;EACxD,IAAIW,OAAO,GAAGX,OAAO;EACrB,OAAOW,OAAO,CAACJ,MAAM,EAAE;IACrBI,OAAO,GAAGA,OAAO,CAACJ,MAAM;EAC1B;EAEA,OAAOI,OAAO;AAChB","ignoreList":[]}
|
package/build/helpers/debug.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export type DebugOptions = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Log pretty-printed deep test component instance
|
|
8
8
|
*/
|
|
9
|
-
export declare function debug(
|
|
9
|
+
export declare function debug(node: JsonNode | JsonNode[], { message, ...formatOptions }?: DebugOptions): void;
|
package/build/helpers/debug.js
CHANGED
|
@@ -9,15 +9,14 @@ var _logger = require("./logger");
|
|
|
9
9
|
/**
|
|
10
10
|
* Log pretty-printed deep test component instance
|
|
11
11
|
*/
|
|
12
|
-
function debug(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
12
|
+
function debug(node, {
|
|
13
|
+
message,
|
|
14
|
+
...formatOptions
|
|
15
|
+
} = {}) {
|
|
17
16
|
if (message) {
|
|
18
|
-
_logger.logger.info(`${message}\n\n`, (0, _formatElement.formatJson)(
|
|
17
|
+
_logger.logger.info(`${message}\n\n`, (0, _formatElement.formatJson)(node, formatOptions));
|
|
19
18
|
} else {
|
|
20
|
-
_logger.logger.info((0, _formatElement.formatJson)(
|
|
19
|
+
_logger.logger.info((0, _formatElement.formatJson)(node, formatOptions));
|
|
21
20
|
}
|
|
22
21
|
}
|
|
23
22
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","names":["_formatElement","require","_logger","debug","
|
|
1
|
+
{"version":3,"file":"debug.js","names":["_formatElement","require","_logger","debug","node","message","formatOptions","logger","info","formatJson"],"sources":["../../src/helpers/debug.ts"],"sourcesContent":["import type { JsonNode } from 'universal-test-renderer';\n\nimport type { FormatElementOptions } from './format-element';\nimport { formatJson } from './format-element';\nimport { logger } from './logger';\n\nexport type DebugOptions = {\n message?: string;\n} & FormatElementOptions;\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport function debug(\n node: JsonNode | JsonNode[],\n { message, ...formatOptions }: DebugOptions = {},\n) {\n if (message) {\n logger.info(`${message}\\n\\n`, formatJson(node, formatOptions));\n } else {\n logger.info(formatJson(node, formatOptions));\n }\n}\n"],"mappings":";;;;;;AAGA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAMA;AACA;AACA;AACO,SAASE,KAAKA,CACnBC,IAA2B,EAC3B;EAAEC,OAAO;EAAE,GAAGC;AAA4B,CAAC,GAAG,CAAC,CAAC,EAChD;EACA,IAAID,OAAO,EAAE;IACXE,cAAM,CAACC,IAAI,CAAC,GAAGH,OAAO,MAAM,EAAE,IAAAI,yBAAU,EAACL,IAAI,EAAEE,aAAa,CAAC,CAAC;EAChE,CAAC,MAAM;IACLC,cAAM,CAACC,IAAI,CAAC,IAAAC,yBAAU,EAACL,IAAI,EAAEE,aAAa,CAAC,CAAC;EAC9C;AACF","ignoreList":[]}
|
|
@@ -6,9 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findAll = findAll;
|
|
7
7
|
var _config = require("../config");
|
|
8
8
|
var _accessibility = require("./accessibility");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function findAll(root, predicate, options = {}) {
|
|
10
|
+
const {
|
|
11
|
+
matchDeepestOnly
|
|
12
|
+
} = options;
|
|
13
|
+
const results = root.queryAll(predicate, {
|
|
14
|
+
matchDeepestOnly
|
|
15
|
+
});
|
|
12
16
|
const includeHiddenElements = options?.includeHiddenElements ?? options?.hidden ?? (0, _config.getConfig)()?.defaultIncludeHiddenElements;
|
|
13
17
|
if (includeHiddenElements) {
|
|
14
18
|
return results;
|
|
@@ -18,28 +22,4 @@ function findAll(root, predicate, options) {
|
|
|
18
22
|
cache
|
|
19
23
|
}));
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
// Extracted from React Test Renderer
|
|
23
|
-
// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402
|
|
24
|
-
function findAllInternal(node, predicate, options, indent = '') {
|
|
25
|
-
const results = [];
|
|
26
|
-
|
|
27
|
-
// Match descendants first but do not add them to results yet.
|
|
28
|
-
const matchingDescendants = [];
|
|
29
|
-
node.children.forEach(child => {
|
|
30
|
-
if (typeof child === 'string') {
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
matchingDescendants.push(...findAllInternal(child, predicate, options, indent + ' '));
|
|
34
|
-
});
|
|
35
|
-
if (
|
|
36
|
-
// When matchDeepestOnly = true: add current element only if no descendants match
|
|
37
|
-
(!options?.matchDeepestOnly || matchingDescendants.length === 0) && (0, _componentTree.isValidElement)(node) && predicate(node)) {
|
|
38
|
-
results.push(node);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Add matching descendants after element to preserve original tree walk order.
|
|
42
|
-
results.push(...matchingDescendants);
|
|
43
|
-
return results;
|
|
44
|
-
}
|
|
45
25
|
//# sourceMappingURL=find-all.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"find-all.js","names":["_config","require","_accessibility","
|
|
1
|
+
{"version":3,"file":"find-all.js","names":["_config","require","_accessibility","findAll","root","predicate","options","matchDeepestOnly","results","queryAll","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility"],"sources":["../../src/helpers/find-all.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessibility';\n\ninterface FindAllOptions {\n /** Match elements hidden from accessibility */\n includeHiddenElements?: boolean;\n\n /** RTL-compatible alias to `includeHiddenElements` */\n hidden?: boolean;\n\n /* Exclude any ancestors of deepest matched elements even if they match the predicate */\n matchDeepestOnly?: boolean;\n}\n\nexport function findAll(\n root: HostElement,\n predicate: (element: HostElement) => boolean,\n options: FindAllOptions = {},\n): HostElement[] {\n const { matchDeepestOnly } = options;\n const results = root.queryAll(predicate, { matchDeepestOnly });\n\n const includeHiddenElements =\n options?.includeHiddenElements ?? options?.hidden ?? getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<HostElement>();\n return results.filter((element) => !isHiddenFromAccessibility(element, { cache }));\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAaO,SAASE,OAAOA,CACrBC,IAAiB,EACjBC,SAA4C,EAC5CC,OAAuB,GAAG,CAAC,CAAC,EACb;EACf,MAAM;IAAEC;EAAiB,CAAC,GAAGD,OAAO;EACpC,MAAME,OAAO,GAAGJ,IAAI,CAACK,QAAQ,CAACJ,SAAS,EAAE;IAAEE;EAAiB,CAAC,CAAC;EAE9D,MAAMG,qBAAqB,GACzBJ,OAAO,EAAEI,qBAAqB,IAAIJ,OAAO,EAAEK,MAAM,IAAI,IAAAC,iBAAS,EAAC,CAAC,EAAEC,4BAA4B;EAEhG,IAAIH,qBAAqB,EAAE;IACzB,OAAOF,OAAO;EAChB;EAEA,MAAMM,KAAK,GAAG,IAAIC,OAAO,CAAc,CAAC;EACxC,OAAOP,OAAO,CAACQ,MAAM,CAAEC,OAAO,IAAK,CAAC,IAAAC,wCAAyB,EAACD,OAAO,EAAE;IAAEH;EAAM,CAAC,CAAC,CAAC;AACpF","ignoreList":[]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostElement, JsonNode } from 'universal-test-renderer';
|
|
2
2
|
import type { MapPropsFunction } from './map-props';
|
|
3
3
|
export type FormatElementOptions = {
|
|
4
4
|
/** Minimize used space. */
|
|
@@ -13,6 +13,6 @@ export type FormatElementOptions = {
|
|
|
13
13
|
*
|
|
14
14
|
* @param element Element to format.
|
|
15
15
|
*/
|
|
16
|
-
export declare function formatElement(element:
|
|
17
|
-
export declare function formatElementList(elements:
|
|
16
|
+
export declare function formatElement(element: HostElement | null, { compact, highlight, mapProps }?: FormatElementOptions): string;
|
|
17
|
+
export declare function formatElementList(elements: HostElement[], options?: FormatElementOptions): string;
|
|
18
18
|
export declare function formatJson(json: JsonNode | JsonNode[], { compact, highlight, mapProps }?: FormatElementOptions): string;
|
|
@@ -8,8 +8,7 @@ exports.formatElementList = formatElementList;
|
|
|
8
8
|
exports.formatJson = formatJson;
|
|
9
9
|
var _prettyFormat = _interopRequireWildcard(require("pretty-format"));
|
|
10
10
|
var _mapProps = require("./map-props");
|
|
11
|
-
function
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
|
+
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); }
|
|
13
12
|
/***
|
|
14
13
|
* Format given element as a pretty-printed string.
|
|
15
14
|
*
|
|
@@ -23,21 +22,22 @@ function formatElement(element, {
|
|
|
23
22
|
if (element == null) {
|
|
24
23
|
return '(null)';
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
} = element.props;
|
|
29
|
+
const childrenToDisplay = typeof children === 'string' ? [children] : undefined;
|
|
30
30
|
return (0, _prettyFormat.default)({
|
|
31
31
|
// This prop is needed persuade the prettyFormat that the element is
|
|
32
|
-
// a
|
|
32
|
+
// a JsonNode instance, so it is formatted as JSX.
|
|
33
33
|
$$typeof: Symbol.for('react.test.json'),
|
|
34
34
|
type: `${element.type}`,
|
|
35
|
-
props: mapProps ? mapProps(
|
|
35
|
+
props: mapProps ? mapProps(props) : props,
|
|
36
36
|
children: childrenToDisplay
|
|
37
37
|
},
|
|
38
38
|
// See: https://www.npmjs.com/package/pretty-format#usage-with-options
|
|
39
39
|
{
|
|
40
|
-
plugins: [_prettyFormat.plugins.ReactTestComponent],
|
|
40
|
+
plugins: [_prettyFormat.plugins.ReactTestComponent, _prettyFormat.plugins.ReactElement],
|
|
41
41
|
printFunctionName: false,
|
|
42
42
|
printBasicPrototype: false,
|
|
43
43
|
highlight: highlight,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format-element.js","names":["_prettyFormat","_interopRequireWildcard","require","_mapProps","
|
|
1
|
+
{"version":3,"file":"format-element.js","names":["_prettyFormat","_interopRequireWildcard","require","_mapProps","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","formatElement","element","compact","highlight","mapProps","defaultMapProps","children","props","childrenToDisplay","undefined","prettyFormat","$$typeof","Symbol","for","type","plugins","ReactTestComponent","ReactElement","printFunctionName","printBasicPrototype","min","formatElementList","elements","options","length","map","join","formatJson","json","getElementJsonPlugin","test","val","serialize","config","indentation","depth","refs","printer","newVal"],"sources":["../../src/helpers/format-element.ts"],"sourcesContent":["import type { NewPlugin } from 'pretty-format';\nimport prettyFormat, { plugins } from 'pretty-format';\nimport type { HostElement, JsonNode } from 'universal-test-renderer';\n\nimport type { MapPropsFunction } from './map-props';\nimport { defaultMapProps } from './map-props';\n\nexport type FormatElementOptions = {\n /** Minimize used space. */\n compact?: boolean;\n\n /** Highlight the output. */\n highlight?: boolean;\n\n /** Filter or map props to display. */\n mapProps?: MapPropsFunction | null;\n};\n\n/***\n * Format given element as a pretty-printed string.\n *\n * @param element Element to format.\n */\nexport function formatElement(\n element: HostElement | null,\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n if (element == null) {\n return '(null)';\n }\n\n const { children, ...props } = element.props;\n const childrenToDisplay = typeof children === 'string' ? [children] : undefined;\n\n return prettyFormat(\n {\n // This prop is needed persuade the prettyFormat that the element is\n // a JsonNode instance, so it is formatted as JSX.\n $$typeof: Symbol.for('react.test.json'),\n type: `${element.type}`,\n props: mapProps ? mapProps(props) : props,\n children: childrenToDisplay,\n },\n // See: https://www.npmjs.com/package/pretty-format#usage-with-options\n {\n plugins: [plugins.ReactTestComponent, plugins.ReactElement],\n printFunctionName: false,\n printBasicPrototype: false,\n highlight: highlight,\n min: compact,\n },\n );\n}\n\nexport function formatElementList(elements: HostElement[], options?: FormatElementOptions) {\n if (elements.length === 0) {\n return '(no elements)';\n }\n\n return elements.map((element) => formatElement(element, options)).join('\\n');\n}\n\nexport function formatJson(\n json: JsonNode | JsonNode[],\n { compact, highlight = true, mapProps = defaultMapProps }: FormatElementOptions = {},\n) {\n return prettyFormat(json, {\n plugins: [getElementJsonPlugin(mapProps), plugins.ReactElement],\n highlight: highlight,\n printBasicPrototype: false,\n min: compact,\n });\n}\n\nfunction getElementJsonPlugin(mapProps?: MapPropsFunction | null): NewPlugin {\n return {\n test: (val) => plugins.ReactTestComponent.test(val),\n serialize: (val, config, indentation, depth, refs, printer) => {\n let newVal = val;\n if (mapProps && val.props) {\n newVal = { ...val, props: mapProps(val.props) };\n }\n return plugins.ReactTestComponent.serialize(\n newVal,\n config,\n indentation,\n depth,\n refs,\n printer,\n );\n },\n };\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,aAAA,GAAAC,uBAAA,CAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AAA8C,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAA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,EAAEA,CAACD,GAAG,EAAEE,MAAM,EAAEC,WAAW,EAAEC,KAAK,EAAEC,IAAI,EAAEC,OAAO,KAAK;MAC7D,IAAIC,MAAM,GAAGP,GAAG;MAChB,IAAI3B,QAAQ,IAAI2B,GAAG,CAACxB,KAAK,EAAE;QACzB+B,MAAM,GAAG;UAAE,GAAGP,GAAG;UAAExB,KAAK,EAAEH,QAAQ,CAAC2B,GAAG,CAACxB,KAAK;QAAE,CAAC;MACjD;MACA,OAAOQ,qBAAO,CAACC,kBAAkB,CAACgB,SAAS,CACzCM,MAAM,EACNL,MAAM,EACNC,WAAW,EACXC,KAAK,EACLC,IAAI,EACJC,OACF,CAAC;IACH;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -3,15 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.HOST_TEXT_NAMES = void 0;
|
|
7
6
|
exports.isHostImage = isHostImage;
|
|
8
7
|
exports.isHostModal = isHostModal;
|
|
9
8
|
exports.isHostScrollView = isHostScrollView;
|
|
10
9
|
exports.isHostSwitch = isHostSwitch;
|
|
11
10
|
exports.isHostText = isHostText;
|
|
12
11
|
exports.isHostTextInput = isHostTextInput;
|
|
13
|
-
|
|
14
|
-
const HOST_TEXT_NAMES = exports.HOST_TEXT_NAMES = ['Text', 'RCTText'];
|
|
12
|
+
const HOST_TEXT_NAMES = ['Text', 'RCTText'];
|
|
15
13
|
const HOST_TEXT_INPUT_NAMES = ['TextInput'];
|
|
16
14
|
const HOST_IMAGE_NAMES = ['Image'];
|
|
17
15
|
const HOST_SWITCH_NAMES = ['RCTSwitch'];
|
|
@@ -23,7 +21,7 @@ const HOST_MODAL_NAMES = ['Modal'];
|
|
|
23
21
|
* @param element The element to check.
|
|
24
22
|
*/
|
|
25
23
|
function isHostText(element) {
|
|
26
|
-
return
|
|
24
|
+
return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);
|
|
27
25
|
}
|
|
28
26
|
|
|
29
27
|
/**
|
|
@@ -31,7 +29,7 @@ function isHostText(element) {
|
|
|
31
29
|
* @param element The element to check.
|
|
32
30
|
*/
|
|
33
31
|
function isHostTextInput(element) {
|
|
34
|
-
return
|
|
32
|
+
return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
/**
|
|
@@ -39,7 +37,7 @@ function isHostTextInput(element) {
|
|
|
39
37
|
* @param element The element to check.
|
|
40
38
|
*/
|
|
41
39
|
function isHostImage(element) {
|
|
42
|
-
return
|
|
40
|
+
return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
/**
|
|
@@ -47,7 +45,7 @@ function isHostImage(element) {
|
|
|
47
45
|
* @param element The element to check.
|
|
48
46
|
*/
|
|
49
47
|
function isHostSwitch(element) {
|
|
50
|
-
return
|
|
48
|
+
return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);
|
|
51
49
|
}
|
|
52
50
|
|
|
53
51
|
/**
|
|
@@ -55,7 +53,7 @@ function isHostSwitch(element) {
|
|
|
55
53
|
* @param element The element to check.
|
|
56
54
|
*/
|
|
57
55
|
function isHostScrollView(element) {
|
|
58
|
-
return
|
|
56
|
+
return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
/**
|
|
@@ -63,6 +61,6 @@ function isHostScrollView(element) {
|
|
|
63
61
|
* @param element The element to check.
|
|
64
62
|
*/
|
|
65
63
|
function isHostModal(element) {
|
|
66
|
-
return
|
|
64
|
+
return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);
|
|
67
65
|
}
|
|
68
66
|
//# sourceMappingURL=host-component-names.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-component-names.js","names":["
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["HOST_TEXT_NAMES","HOST_TEXT_INPUT_NAMES","HOST_IMAGE_NAMES","HOST_SWITCH_NAMES","HOST_SCROLL_VIEW_NAMES","HOST_MODAL_NAMES","isHostText","element","type","includes","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nconst HOST_TEXT_NAMES = ['Text', 'RCTText'];\nconst HOST_TEXT_INPUT_NAMES = ['TextInput'];\nconst HOST_IMAGE_NAMES = ['Image'];\nconst HOST_SWITCH_NAMES = ['RCTSwitch'];\nconst HOST_SCROLL_VIEW_NAMES = ['RCTScrollView'];\nconst HOST_MODAL_NAMES = ['Modal'];\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element: HostElement | null) {\n return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);\n}\n"],"mappings":";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AA2B,EAAE;EACvD,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIH,gBAAgB,CAACI,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF","ignoreList":[]}
|
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
export declare const _console: {
|
|
2
|
+
debug: {
|
|
3
|
+
(...data: any[]): void;
|
|
4
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
5
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
6
|
+
};
|
|
7
|
+
info: {
|
|
8
|
+
(...data: any[]): void;
|
|
9
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
10
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
11
|
+
};
|
|
12
|
+
warn: {
|
|
13
|
+
(...data: any[]): void;
|
|
14
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
15
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
16
|
+
};
|
|
17
|
+
error: {
|
|
18
|
+
(...data: any[]): void;
|
|
19
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
20
|
+
(message?: any, ...optionalParams: any[]): void;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
1
23
|
export declare const logger: {
|
|
2
24
|
debug(message: unknown, ...args: unknown[]): void;
|
|
3
25
|
info(message: unknown, ...args: unknown[]): void;
|
package/build/helpers/logger.js
CHANGED
|
@@ -3,30 +3,35 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.logger = void 0;
|
|
7
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
6
|
+
exports.logger = exports._console = void 0;
|
|
8
7
|
var nodeConsole = _interopRequireWildcard(require("console"));
|
|
8
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
9
9
|
var _redent = _interopRequireDefault(require("redent"));
|
|
10
10
|
var nodeUtil = _interopRequireWildcard(require("util"));
|
|
11
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
13
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
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); }
|
|
13
|
+
const _console = exports._console = {
|
|
14
|
+
debug: nodeConsole.debug,
|
|
15
|
+
info: nodeConsole.info,
|
|
16
|
+
warn: nodeConsole.warn,
|
|
17
|
+
error: nodeConsole.error
|
|
18
|
+
};
|
|
14
19
|
const logger = exports.logger = {
|
|
15
20
|
debug(message, ...args) {
|
|
16
21
|
const output = formatMessage('●', message, ...args);
|
|
17
|
-
|
|
22
|
+
_console.debug(_picocolors.default.dim(output));
|
|
18
23
|
},
|
|
19
24
|
info(message, ...args) {
|
|
20
25
|
const output = formatMessage('●', message, ...args);
|
|
21
|
-
|
|
26
|
+
_console.info(output);
|
|
22
27
|
},
|
|
23
28
|
warn(message, ...args) {
|
|
24
29
|
const output = formatMessage('▲', message, ...args);
|
|
25
|
-
|
|
30
|
+
_console.warn(_picocolors.default.yellow(output));
|
|
26
31
|
},
|
|
27
32
|
error(message, ...args) {
|
|
28
33
|
const output = formatMessage('■', message, ...args);
|
|
29
|
-
|
|
34
|
+
_console.error(_picocolors.default.red(output));
|
|
30
35
|
}
|
|
31
36
|
};
|
|
32
37
|
function formatMessage(symbol, message, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","names":["
|
|
1
|
+
{"version":3,"file":"logger.js","names":["nodeConsole","_interopRequireWildcard","require","_picocolors","_interopRequireDefault","_redent","nodeUtil","e","__esModule","default","t","WeakMap","r","n","o","i","f","__proto__","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","_console","exports","debug","info","warn","error","logger","message","args","output","formatMessage","pc","dim","yellow","red","symbol","formatted","format","indented","redent","trimStart"],"sources":["../../src/helpers/logger.ts"],"sourcesContent":["import * as nodeConsole from 'console';\nimport pc from 'picocolors';\nimport redent from 'redent';\nimport * as nodeUtil from 'util';\n\nexport const _console = {\n debug: nodeConsole.debug,\n info: nodeConsole.info,\n warn: nodeConsole.warn,\n error: nodeConsole.error,\n};\n\nexport const logger = {\n debug(message: unknown, ...args: unknown[]) {\n const output = formatMessage('●', message, ...args);\n _console.debug(pc.dim(output));\n },\n\n info(message: unknown, ...args: unknown[]) {\n const output = formatMessage('●', message, ...args);\n _console.info(output);\n },\n\n warn(message: unknown, ...args: unknown[]) {\n const output = formatMessage('▲', message, ...args);\n _console.warn(pc.yellow(output));\n },\n\n error(message: unknown, ...args: unknown[]) {\n const output = formatMessage('■', message, ...args);\n _console.error(pc.red(output));\n },\n};\n\nfunction formatMessage(symbol: string, message: unknown, ...args: unknown[]) {\n const formatted = nodeUtil.format(message, ...args);\n const indented = redent(formatted, 4);\n return ` ${symbol} ${indented.trimStart()}\\n`;\n}\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GAAGC,IAAe,EAAE;EAC3E,MAAMQ,SAAS,GAAGpC,QAAQ,CAACqC,MAAM,CAACV,OAAO,EAAE,GAAGC,IAAI,CAAC;EACnD,MAAMU,QAAQ,GAAG,IAAAC,eAAM,EAACH,SAAS,EAAE,CAAC,CAAC;EACrC,OAAO,KAAKD,MAAM,IAAIG,QAAQ,CAACE,SAAS,CAAC,CAAC,IAAI;AAChD","ignoreList":[]}
|
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isPointerEventEnabled = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
7
8
|
/**
|
|
8
9
|
* pointerEvents controls whether the View can be the target of touch events.
|
|
9
10
|
* 'auto': The View and its children can be the target of touch events.
|
|
@@ -12,13 +13,16 @@ exports.isPointerEventEnabled = void 0;
|
|
|
12
13
|
* 'box-only': The view can be the target of touch events but its subviews cannot be
|
|
13
14
|
* see the official react native doc https://reactnative.dev/docs/view#pointerevents */
|
|
14
15
|
const isPointerEventEnabled = (element, isParent) => {
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
// Check both props.pointerEvents and props.style.pointerEvents
|
|
17
|
+
const pointerEvents = element?.props.pointerEvents ?? _reactNative.StyleSheet.flatten(element?.props.style)?.pointerEvents;
|
|
18
|
+
const parentCondition = isParent ? pointerEvents === 'box-only' : pointerEvents === 'box-none';
|
|
19
|
+
if (pointerEvents === 'none' || parentCondition) {
|
|
17
20
|
return false;
|
|
18
21
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
if (!element.parent) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return isPointerEventEnabled(element.parent, true);
|
|
22
26
|
};
|
|
23
27
|
exports.isPointerEventEnabled = isPointerEventEnabled;
|
|
24
28
|
//# sourceMappingURL=pointer-events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer-events.js","names":["isPointerEventEnabled","element","isParent","
|
|
1
|
+
{"version":3,"file":"pointer-events.js","names":["_reactNative","require","isPointerEventEnabled","element","isParent","pointerEvents","props","StyleSheet","flatten","style","parentCondition","parent","exports"],"sources":["../../src/helpers/pointer-events.ts"],"sourcesContent":["import { StyleSheet } from 'react-native';\nimport type { HostElement } from 'universal-test-renderer';\n\n/**\n * pointerEvents controls whether the View can be the target of touch events.\n * 'auto': The View and its children can be the target of touch events.\n * 'none': The View is never the target of touch events.\n * 'box-none': The View is never the target of touch events but its subviews can be\n * 'box-only': The view can be the target of touch events but its subviews cannot be\n * see the official react native doc https://reactnative.dev/docs/view#pointerevents */\nexport const isPointerEventEnabled = (element: HostElement, isParent?: boolean): boolean => {\n // Check both props.pointerEvents and props.style.pointerEvents\n const pointerEvents =\n element?.props.pointerEvents ?? StyleSheet.flatten(element?.props.style)?.pointerEvents;\n\n const parentCondition = isParent ? pointerEvents === 'box-only' : pointerEvents === 'box-none';\n\n if (pointerEvents === 'none' || parentCondition) {\n return false;\n }\n\n if (!element.parent) {\n return true;\n }\n\n return isPointerEventEnabled(element.parent, true);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,qBAAqB,GAAGA,CAACC,OAAoB,EAAEC,QAAkB,KAAc;EAC1F;EACA,MAAMC,aAAa,GACjBF,OAAO,EAAEG,KAAK,CAACD,aAAa,IAAIE,uBAAU,CAACC,OAAO,CAACL,OAAO,EAAEG,KAAK,CAACG,KAAK,CAAC,EAAEJ,aAAa;EAEzF,MAAMK,eAAe,GAAGN,QAAQ,GAAGC,aAAa,KAAK,UAAU,GAAGA,aAAa,KAAK,UAAU;EAE9F,IAAIA,aAAa,KAAK,MAAM,IAAIK,eAAe,EAAE;IAC/C,OAAO,KAAK;EACd;EAEA,IAAI,CAACP,OAAO,CAACQ,MAAM,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,OAAOT,qBAAqB,CAACC,OAAO,CAACQ,MAAM,EAAE,IAAI,CAAC;AACpD,CAAC;AAACC,OAAA,CAAAV,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
|
|
3
|
-
* See: https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/src/pure.js#L37
|
|
4
3
|
*
|
|
5
4
|
* @param callback Async callback to run
|
|
6
5
|
* @returns Result of the callback
|
|
@@ -10,7 +10,6 @@ var _flushMicroTasks = require("../flush-micro-tasks");
|
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.
|
|
13
|
-
* See: https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/src/pure.js#L37
|
|
14
13
|
*
|
|
15
14
|
* @param callback Async callback to run
|
|
16
15
|
* @returns Result of the callback
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n
|
|
1
|
+
{"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasks();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,SAASA,CAASC,QAA+B,EAAmB;EACxF,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;EACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;EAE7B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAAC,CAAC;IAC/B;IACA,MAAM,IAAAK,gCAAe,EAAC,CAAC;IACvB,OAAOD,MAAM;EACf,CAAC,SAAS;IACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;EAChD;AACF","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
package/build/index.flow.js
CHANGED
|
@@ -55,10 +55,10 @@ declare type A11yRole =
|
|
|
55
55
|
|
|
56
56
|
declare type A11yState = {|
|
|
57
57
|
disabled?: boolean,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
selected?: boolean,
|
|
59
|
+
checked?: boolean | 'mixed',
|
|
60
|
+
busy?: boolean,
|
|
61
|
+
expanded?: boolean,
|
|
62
62
|
|};
|
|
63
63
|
|
|
64
64
|
declare type A11yValue = {
|
|
@@ -310,6 +310,7 @@ declare module '@testing-library/react-native' {
|
|
|
310
310
|
declare interface RenderOptions {
|
|
311
311
|
wrapper?: React.ComponentType<any>;
|
|
312
312
|
createNodeMock?: (element: React.Element<any>) => any;
|
|
313
|
+
unstable_validateStringsRenderedWithinText?: boolean;
|
|
313
314
|
unstable_isConcurrent?: boolean;
|
|
314
315
|
unstable_strictMode?: boolean;
|
|
315
316
|
unstable_concurrentUpdatesByDefault?: boolean;
|
package/build/index.js
CHANGED
|
@@ -3,23 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var _exportNames = {
|
|
7
|
-
HostElement: true
|
|
8
|
-
};
|
|
9
|
-
Object.defineProperty(exports, "HostElement", {
|
|
10
|
-
enumerable: true,
|
|
11
|
-
get: function () {
|
|
12
|
-
return _universalTestRenderer.HostElement;
|
|
13
|
-
}
|
|
14
|
-
});
|
|
15
6
|
require("./matchers/extend-expect");
|
|
16
|
-
var _universalTestRenderer = require("universal-test-renderer");
|
|
17
7
|
var _act = require("./act");
|
|
18
8
|
var _flushMicroTasks = require("./flush-micro-tasks");
|
|
19
9
|
var _pure = require("./pure");
|
|
20
10
|
Object.keys(_pure).forEach(function (key) {
|
|
21
11
|
if (key === "default" || key === "__esModule") return;
|
|
22
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
23
12
|
if (key in exports && exports[key] === _pure[key]) return;
|
|
24
13
|
Object.defineProperty(exports, key, {
|
|
25
14
|
enumerable: true,
|
|
@@ -37,7 +26,7 @@ if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
|
37
26
|
if (typeof afterEach === 'function') {
|
|
38
27
|
afterEach(async () => {
|
|
39
28
|
await (0, _flushMicroTasks.flushMicroTasks)();
|
|
40
|
-
(0, _pure.
|
|
29
|
+
await (0, _pure.cleanupAsync)();
|
|
41
30
|
});
|
|
42
31
|
}
|
|
43
32
|
if (typeof beforeAll === 'function' && typeof afterAll === 'function') {
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["require","
|
|
1
|
+
{"version":3,"file":"index.js","names":["require","_act","_flushMicroTasks","_pure","Object","keys","forEach","key","exports","defineProperty","enumerable","get","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","flushMicroTasks","cleanupAsync","beforeAll","afterAll","previousIsReactActEnvironment","getIsReactActEnvironment","setReactActEnvironment"],"sources":["../src/index.ts"],"sourcesContent":["import './matchers/extend-expect';\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from './act';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { cleanupAsync } from './pure';\n\nif (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {\n // If we're running in a test runner that supports afterEach\n // then we'll automatically run cleanup afterEach test\n // this ensures that tests run in isolation from each other\n // if you don't like this then either import the `pure` module\n // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\n if (typeof afterEach === 'function') {\n afterEach(async () => {\n await flushMicroTasks();\n await cleanupAsync();\n });\n }\n\n if (typeof beforeAll === 'function' && typeof afterAll === 'function') {\n // This matches the behavior of React < 18.\n let previousIsReactActEnvironment = getIsReactActEnvironment();\n beforeAll(() => {\n previousIsReactActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(true);\n });\n\n afterAll(() => {\n setReactActEnvironment(previousIsReactActEnvironment);\n });\n }\n}\n\nexport * from './pure';\n"],"mappings":";;;;;AAAAA,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AA6BAI,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAR,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AA3BA,IAAI,CAACK,OAAO,EAAEC,GAAG,EAAEC,sBAAsB,EAAE;EACzC;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;IACnCA,SAAS,CAAC,YAAY;MACpB,MAAM,IAAAC,gCAAe,EAAC,CAAC;MACvB,MAAM,IAAAC,kBAAY,EAAC,CAAC;IACtB,CAAC,CAAC;EACJ;EAEA,IAAI,OAAOC,SAAS,KAAK,UAAU,IAAI,OAAOC,QAAQ,KAAK,UAAU,EAAE;IACrE;IACA,IAAIC,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IAC9DH,SAAS,CAAC,MAAM;MACdE,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;MAC1D,IAAAC,2BAAsB,EAAC,IAAI,CAAC;IAC9B,CAAC,CAAC;IAEFH,QAAQ,CAAC,MAAM;MACb,IAAAG,2BAAsB,EAACF,6BAA6B,CAAC;IACvD,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|