@testing-library/react-native 14.0.0-alpha.0 → 14.0.0-alpha.2
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 +8 -12
- 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 +7 -0
- package/build/event-handler.js +30 -0
- package/build/event-handler.js.map +1 -0
- package/build/fire-event.d.ts +11 -4
- package/build/fire-event.js +43 -37
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessibility.d.ts +2 -2
- 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 +3 -3
- package/build/helpers/debug.js +8 -11
- package/build/helpers/debug.js.map +1 -1
- package/build/helpers/errors.js +4 -4
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/find-all.d.ts +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 +18 -0
- package/build/helpers/format-element.js +80 -0
- package/build/helpers/format-element.js.map +1 -0
- package/build/helpers/host-component-names.d.ts +1 -1
- package/build/helpers/host-component-names.js +6 -7
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/logger.d.ts +28 -0
- package/build/helpers/logger.js +42 -0
- package/build/helpers/logger.js.map +1 -0
- package/build/helpers/{format-default.d.ts → map-props.d.ts} +1 -0
- package/build/helpers/{format-default.js → map-props.js} +2 -2
- package/build/helpers/map-props.js.map +1 -0
- 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 +2 -2
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-label-text.d.ts +2 -2
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-string-prop.d.ts +1 -1
- package/build/helpers/matchers/match-string-prop.js.map +1 -1
- package/build/helpers/matchers/match-text-content.d.ts +2 -2
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/object.d.ts +1 -1
- package/build/helpers/object.js.map +1 -1
- package/build/helpers/pointer-events.d.ts +1 -1
- package/build/helpers/pointer-events.js +9 -5
- 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/timers.d.ts +1 -1
- package/build/helpers/timers.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 +33 -36
- package/build/index.js +4 -16
- package/build/index.js.map +1 -1
- package/build/matchers/extend-expect.js +2 -2
- package/build/matchers/extend-expect.js.map +1 -1
- package/build/matchers/index.d.ts +1 -1
- package/build/matchers/index.js.map +1 -1
- package/build/matchers/to-be-busy.d.ts +1 -1
- package/build/matchers/to-be-busy.js +4 -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 +4 -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 +5 -2
- 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 +9 -3
- 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 +5 -2
- 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 +4 -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 +4 -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 +4 -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 +8 -5
- 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 +5 -3
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.d.ts +2 -2
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.d.ts +2 -2
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.d.ts +2 -2
- package/build/matchers/to-have-display-value.js +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 +2 -2
- package/build/matchers/to-have-style.js +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.d.ts +2 -2
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.d.ts +4 -4
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.d.ts +1 -8
- package/build/matchers/utils.js +3 -48
- package/build/matchers/utils.js.map +1 -1
- package/build/native-state.d.ts +3 -3
- package/build/native-state.js +1 -1
- package/build/native-state.js.map +1 -1
- package/build/pure.d.ts +6 -4
- package/build/pure.js +28 -2
- package/build/pure.js.map +1 -1
- package/build/queries/display-value.d.ts +3 -3
- package/build/queries/display-value.js +9 -9
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.d.ts +4 -4
- package/build/queries/hint-text.js +9 -9
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.d.ts +4 -4
- package/build/queries/label-text.js +9 -9
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.d.ts +3 -3
- package/build/queries/make-queries.js +15 -18
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/options.d.ts +1 -1
- package/build/queries/options.js.map +1 -1
- package/build/queries/placeholder-text.d.ts +3 -3
- package/build/queries/placeholder-text.js +10 -10
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.d.ts +7 -7
- package/build/queries/role.js +16 -9
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.d.ts +3 -3
- package/build/queries/test-id.js +9 -9
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.d.ts +3 -3
- 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 +18 -6
- package/build/render-hook.js +56 -26
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +54 -48
- package/build/render.js +42 -30
- package/build/render.js.map +1 -1
- package/build/screen.d.ts +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.d.ts +2 -2
- package/build/user-event/clear.js +6 -6
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/base.d.ts +2 -2
- package/build/user-event/event-builder/base.js.map +1 -1
- package/build/user-event/event-builder/scroll-view.d.ts +1 -1
- package/build/user-event/event-builder/scroll-view.js.map +1 -1
- package/build/user-event/event-builder/text-input.d.ts +2 -2
- package/build/user-event/event-builder/text-input.js.map +1 -1
- package/build/user-event/index.d.ts +4 -4
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/paste.d.ts +2 -2
- package/build/user-event/paste.js +8 -8
- package/build/user-event/paste.js.map +1 -1
- package/build/user-event/press/index.d.ts +1 -1
- package/build/user-event/press/index.js.map +1 -1
- package/build/user-event/press/press.d.ts +2 -2
- package/build/user-event/press/press.js +48 -49
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/index.d.ts +1 -1
- package/build/user-event/scroll/index.js.map +1 -1
- package/build/user-event/scroll/scroll-to.d.ts +3 -3
- package/build/user-event/scroll/scroll-to.js +8 -8
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/scroll/utils.d.ts +1 -1
- package/build/user-event/scroll/utils.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +4 -4
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.d.ts +3 -2
- package/build/user-event/type/type.js +16 -14
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/content-size.d.ts +1 -1
- package/build/user-event/utils/content-size.js.map +1 -1
- package/build/user-event/utils/dispatch-event.d.ts +2 -2
- package/build/user-event/utils/dispatch-event.js +5 -15
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/wait.d.ts +6 -2
- package/build/user-event/utils/wait.js +1 -1
- package/build/user-event/utils/wait.js.map +1 -1
- package/build/wait-for-element-to-be-removed.js +1 -1
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/wait-for.js +4 -5
- package/build/wait-for.js.map +1 -1
- package/build/within.d.ts +20 -20
- package/build/within.js +8 -8
- package/build/within.js.map +1 -1
- package/package.json +38 -32
- package/typings/index.flow.js +33 -36
- package/build/helpers/format-default.js.map +0 -1
- package/build/helpers/format.d.ts +0 -7
- package/build/helpers/format.js +0 -31
- package/build/helpers/format.js.map +0 -1
- 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
|
@@ -6,40 +6,43 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getContainerElement = getContainerElement;
|
|
7
7
|
exports.getHostSiblings = getHostSiblings;
|
|
8
8
|
exports.isElementMounted = isElementMounted;
|
|
9
|
-
exports.
|
|
10
|
-
var _universalTestRenderer = require("universal-test-renderer");
|
|
9
|
+
exports.isHostElement = isHostElement;
|
|
11
10
|
var _screen = require("../screen");
|
|
12
11
|
/**
|
|
13
12
|
* Checks if the given element is a host element.
|
|
14
13
|
* @param element The element to check.
|
|
15
14
|
*/
|
|
16
|
-
function
|
|
17
|
-
return typeof element
|
|
15
|
+
function isHostElement(element) {
|
|
16
|
+
return typeof element !== 'string' && typeof element?.type === 'string';
|
|
18
17
|
}
|
|
19
18
|
function isElementMounted(element) {
|
|
20
19
|
return getContainerElement(element) === _screen.screen.container;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
/**
|
|
24
|
-
* Returns
|
|
25
|
-
*
|
|
23
|
+
* Returns host siblings for given element.
|
|
26
24
|
* @param element The element start traversing from.
|
|
27
|
-
* @returns The root element of the tree (host or composite).
|
|
28
25
|
*/
|
|
29
|
-
function
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
function getHostSiblings(element) {
|
|
27
|
+
// Should not happen
|
|
28
|
+
const parent = element.parent;
|
|
29
|
+
if (!parent) {
|
|
30
|
+
return [];
|
|
33
31
|
}
|
|
34
|
-
return
|
|
32
|
+
return parent.children.filter(sibling => typeof sibling !== 'string' && sibling !== element);
|
|
35
33
|
}
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
|
-
* Returns
|
|
36
|
+
* Returns the containerelement of the tree.
|
|
37
|
+
*
|
|
39
38
|
* @param element The element start traversing from.
|
|
39
|
+
* @returns The container element of the tree.
|
|
40
40
|
*/
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
function getContainerElement(element) {
|
|
42
|
+
let current = element;
|
|
43
|
+
while (current.parent) {
|
|
44
|
+
current = current.parent;
|
|
45
|
+
}
|
|
46
|
+
return current;
|
|
44
47
|
}
|
|
45
48
|
//# sourceMappingURL=component-tree.js.map
|
|
@@ -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
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { JsonNode } from 'universal-test-renderer';
|
|
2
|
-
import {
|
|
2
|
+
import type { FormatElementOptions } from './format-element';
|
|
3
3
|
export type DebugOptions = {
|
|
4
4
|
message?: string;
|
|
5
|
-
} &
|
|
5
|
+
} & FormatElementOptions;
|
|
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
|
@@ -4,22 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.debug = debug;
|
|
7
|
-
var
|
|
8
|
-
|
|
7
|
+
var _formatElement = require("./format-element");
|
|
8
|
+
var _logger = require("./logger");
|
|
9
9
|
/**
|
|
10
10
|
* Log pretty-printed deep test component instance
|
|
11
11
|
*/
|
|
12
|
-
function debug(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
} : undefined;
|
|
12
|
+
function debug(node, {
|
|
13
|
+
message,
|
|
14
|
+
...formatOptions
|
|
15
|
+
} = {}) {
|
|
17
16
|
if (message) {
|
|
18
|
-
|
|
19
|
-
console.log(`${message}\n\n`, (0, _format.default)(instance, formatOptions));
|
|
17
|
+
_logger.logger.info(`${message}\n\n`, (0, _formatElement.formatJson)(node, formatOptions));
|
|
20
18
|
} else {
|
|
21
|
-
|
|
22
|
-
console.log((0, _format.default)(instance, formatOptions));
|
|
19
|
+
_logger.logger.info((0, _formatElement.formatJson)(node, formatOptions));
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
22
|
//# sourceMappingURL=debug.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","names":["
|
|
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":[]}
|
package/build/helpers/errors.js
CHANGED
|
@@ -9,6 +9,7 @@ exports.prepareErrorMessage = exports.createQueryByError = void 0;
|
|
|
9
9
|
var _prettyFormat = _interopRequireDefault(require("pretty-format"));
|
|
10
10
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
11
|
class ErrorWithStack extends Error {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
12
13
|
constructor(message, callsite) {
|
|
13
14
|
super(message);
|
|
14
15
|
if (Error.captureStackTrace) {
|
|
@@ -34,6 +35,8 @@ const prepareErrorMessage = (error, name, value) => {
|
|
|
34
35
|
}
|
|
35
36
|
return errorMessage;
|
|
36
37
|
};
|
|
38
|
+
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
37
40
|
exports.prepareErrorMessage = prepareErrorMessage;
|
|
38
41
|
const createQueryByError = (error, callsite) => {
|
|
39
42
|
if (error instanceof Error) {
|
|
@@ -42,10 +45,7 @@ const createQueryByError = (error, callsite) => {
|
|
|
42
45
|
}
|
|
43
46
|
throw new ErrorWithStack(error.message, callsite);
|
|
44
47
|
}
|
|
45
|
-
throw new ErrorWithStack(
|
|
46
|
-
// generic refining of `unknown` is very hard, you cannot do `'toString' in error` or anything like that
|
|
47
|
-
// Converting as any with extra safe optional chaining will do the job just as well
|
|
48
|
-
`Query: caught unknown error type: ${typeof error}, value: ${error?.toString?.()}`, callsite);
|
|
48
|
+
throw new ErrorWithStack(`Query: caught unknown error type: ${typeof error}, value: ${error}`, callsite);
|
|
49
49
|
};
|
|
50
50
|
exports.createQueryByError = createQueryByError;
|
|
51
51
|
function copyStackTrace(target, stackTraceSource) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","names":["_prettyFormat","_interopRequireDefault","require","e","__esModule","default","ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","prepareErrorMessage","error","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown,\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(/ matching custom predicate[^]*/gm, '');\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\nexport const createQueryByError = (error: unknown, callsite: Function): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n
|
|
1
|
+
{"version":3,"file":"errors.js","names":["_prettyFormat","_interopRequireDefault","require","e","__esModule","default","ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","prepareErrorMessage","error","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown,\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(/ matching custom predicate[^]*/gm, '');\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const createQueryByError = (error: unknown, callsite: Function): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n `Query: caught unknown error type: ${typeof error}, value: ${error}`,\n callsite,\n );\n};\n\nexport function copyStackTrace(target: unknown, stackTraceSource: Error) {\n if (target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElC,MAAMG,cAAc,SAASC,KAAK,CAAC;EACxC;EACAC,WAAWA,CAACC,OAA2B,EAAEC,QAAkB,EAAE;IAC3D,KAAK,CAACD,OAAO,CAAC;IACd,IAAIF,KAAK,CAACI,iBAAiB,EAAE;MAC3BJ,KAAK,CAACI,iBAAiB,CAAC,IAAI,EAAED,QAAQ,CAAC;IACzC;EACF;AACF;AAACE,OAAA,CAAAN,cAAA,GAAAA,cAAA;AA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,CAACQ,gBAAgB,CAACjB,OAAO,EAAEgB,MAAM,CAAChB,OAAO,CAAC;EACzF;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":[]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { HostElement, JsonNode } from 'universal-test-renderer';
|
|
2
|
+
import type { MapPropsFunction } from './map-props';
|
|
3
|
+
export type FormatElementOptions = {
|
|
4
|
+
/** Minimize used space. */
|
|
5
|
+
compact?: boolean;
|
|
6
|
+
/** Highlight the output. */
|
|
7
|
+
highlight?: boolean;
|
|
8
|
+
/** Filter or map props to display. */
|
|
9
|
+
mapProps?: MapPropsFunction | null;
|
|
10
|
+
};
|
|
11
|
+
/***
|
|
12
|
+
* Format given element as a pretty-printed string.
|
|
13
|
+
*
|
|
14
|
+
* @param element Element to format.
|
|
15
|
+
*/
|
|
16
|
+
export declare function formatElement(element: HostElement | null, { compact, highlight, mapProps }?: FormatElementOptions): string;
|
|
17
|
+
export declare function formatElementList(elements: HostElement[], options?: FormatElementOptions): string;
|
|
18
|
+
export declare function formatJson(json: JsonNode | JsonNode[], { compact, highlight, mapProps }?: FormatElementOptions): string;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatElement = formatElement;
|
|
7
|
+
exports.formatElementList = formatElementList;
|
|
8
|
+
exports.formatJson = formatJson;
|
|
9
|
+
var _prettyFormat = _interopRequireWildcard(require("pretty-format"));
|
|
10
|
+
var _mapProps = require("./map-props");
|
|
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); }
|
|
12
|
+
/***
|
|
13
|
+
* Format given element as a pretty-printed string.
|
|
14
|
+
*
|
|
15
|
+
* @param element Element to format.
|
|
16
|
+
*/
|
|
17
|
+
function formatElement(element, {
|
|
18
|
+
compact,
|
|
19
|
+
highlight = true,
|
|
20
|
+
mapProps = _mapProps.defaultMapProps
|
|
21
|
+
} = {}) {
|
|
22
|
+
if (element == null) {
|
|
23
|
+
return '(null)';
|
|
24
|
+
}
|
|
25
|
+
const {
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
} = element.props;
|
|
29
|
+
const childrenToDisplay = typeof children === 'string' ? [children] : undefined;
|
|
30
|
+
return (0, _prettyFormat.default)({
|
|
31
|
+
// This prop is needed persuade the prettyFormat that the element is
|
|
32
|
+
// a JsonNode instance, so it is formatted as JSX.
|
|
33
|
+
$$typeof: Symbol.for('react.test.json'),
|
|
34
|
+
type: `${element.type}`,
|
|
35
|
+
props: mapProps ? mapProps(props) : props,
|
|
36
|
+
children: childrenToDisplay
|
|
37
|
+
},
|
|
38
|
+
// See: https://www.npmjs.com/package/pretty-format#usage-with-options
|
|
39
|
+
{
|
|
40
|
+
plugins: [_prettyFormat.plugins.ReactTestComponent, _prettyFormat.plugins.ReactElement],
|
|
41
|
+
printFunctionName: false,
|
|
42
|
+
printBasicPrototype: false,
|
|
43
|
+
highlight: highlight,
|
|
44
|
+
min: compact
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function formatElementList(elements, options) {
|
|
48
|
+
if (elements.length === 0) {
|
|
49
|
+
return '(no elements)';
|
|
50
|
+
}
|
|
51
|
+
return elements.map(element => formatElement(element, options)).join('\n');
|
|
52
|
+
}
|
|
53
|
+
function formatJson(json, {
|
|
54
|
+
compact,
|
|
55
|
+
highlight = true,
|
|
56
|
+
mapProps = _mapProps.defaultMapProps
|
|
57
|
+
} = {}) {
|
|
58
|
+
return (0, _prettyFormat.default)(json, {
|
|
59
|
+
plugins: [getElementJsonPlugin(mapProps), _prettyFormat.plugins.ReactElement],
|
|
60
|
+
highlight: highlight,
|
|
61
|
+
printBasicPrototype: false,
|
|
62
|
+
min: compact
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function getElementJsonPlugin(mapProps) {
|
|
66
|
+
return {
|
|
67
|
+
test: val => _prettyFormat.plugins.ReactTestComponent.test(val),
|
|
68
|
+
serialize: (val, config, indentation, depth, refs, printer) => {
|
|
69
|
+
let newVal = val;
|
|
70
|
+
if (mapProps && val.props) {
|
|
71
|
+
newVal = {
|
|
72
|
+
...val,
|
|
73
|
+
props: mapProps(val.props)
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return _prettyFormat.plugins.ReactTestComponent.serialize(newVal, config, indentation, depth, refs, printer);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=format-element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EAAAM,CAAA,IAAAC,CAAA,CAAAP,CAAA,IAAAD,CAAA,CAAAC,CAAA,WAAAO,CAAA,KAA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AAG,IAAI;EAAEC,QAAQ,GAAGC;AAAsC,CAAC,GAAG,CAAC,CAAC,EACpF;EACA,OAAO,IAAAK,qBAAY,EAACkB,IAAI,EAAE;IACxBb,OAAO,EAAE,CAACc,oBAAoB,CAACzB,QAAQ,CAAC,EAAEW,qBAAO,CAACE,YAAY,CAAC;IAC/Dd,SAAS,EAAEA,SAAS;IACpBgB,mBAAmB,EAAE,KAAK;IAC1BC,GAAG,EAAElB;EACP,CAAC,CAAC;AACJ;AAEA,SAAS2B,oBAAoBA,CAACzB,QAAkC,EAAa;EAC3E,OAAO;IACL0B,IAAI,EAAGC,GAAG,IAAKhB,qBAAO,CAACC,kBAAkB,CAACc,IAAI,CAACC,GAAG,CAAC;IACnDC,SAAS,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":[]}
|
|
@@ -9,7 +9,6 @@ exports.isHostScrollView = isHostScrollView;
|
|
|
9
9
|
exports.isHostSwitch = isHostSwitch;
|
|
10
10
|
exports.isHostText = isHostText;
|
|
11
11
|
exports.isHostTextInput = isHostTextInput;
|
|
12
|
-
var _componentTree = require("./component-tree");
|
|
13
12
|
const HOST_TEXT_NAMES = ['Text', 'RCTText'];
|
|
14
13
|
const HOST_TEXT_INPUT_NAMES = ['TextInput'];
|
|
15
14
|
const HOST_IMAGE_NAMES = ['Image'];
|
|
@@ -22,7 +21,7 @@ const HOST_MODAL_NAMES = ['Modal'];
|
|
|
22
21
|
* @param element The element to check.
|
|
23
22
|
*/
|
|
24
23
|
function isHostText(element) {
|
|
25
|
-
return
|
|
24
|
+
return typeof element?.type === 'string' && HOST_TEXT_NAMES.includes(element.type);
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
/**
|
|
@@ -30,7 +29,7 @@ function isHostText(element) {
|
|
|
30
29
|
* @param element The element to check.
|
|
31
30
|
*/
|
|
32
31
|
function isHostTextInput(element) {
|
|
33
|
-
return
|
|
32
|
+
return typeof element?.type === 'string' && HOST_TEXT_INPUT_NAMES.includes(element.type);
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
/**
|
|
@@ -38,7 +37,7 @@ function isHostTextInput(element) {
|
|
|
38
37
|
* @param element The element to check.
|
|
39
38
|
*/
|
|
40
39
|
function isHostImage(element) {
|
|
41
|
-
return
|
|
40
|
+
return typeof element?.type === 'string' && HOST_IMAGE_NAMES.includes(element.type);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
/**
|
|
@@ -46,7 +45,7 @@ function isHostImage(element) {
|
|
|
46
45
|
* @param element The element to check.
|
|
47
46
|
*/
|
|
48
47
|
function isHostSwitch(element) {
|
|
49
|
-
return
|
|
48
|
+
return typeof element?.type === 'string' && HOST_SWITCH_NAMES.includes(element.type);
|
|
50
49
|
}
|
|
51
50
|
|
|
52
51
|
/**
|
|
@@ -54,7 +53,7 @@ function isHostSwitch(element) {
|
|
|
54
53
|
* @param element The element to check.
|
|
55
54
|
*/
|
|
56
55
|
function isHostScrollView(element) {
|
|
57
|
-
return
|
|
56
|
+
return typeof element?.type === 'string' && HOST_SCROLL_VIEW_NAMES.includes(element.type);
|
|
58
57
|
}
|
|
59
58
|
|
|
60
59
|
/**
|
|
@@ -62,6 +61,6 @@ function isHostScrollView(element) {
|
|
|
62
61
|
* @param element The element to check.
|
|
63
62
|
*/
|
|
64
63
|
function isHostModal(element) {
|
|
65
|
-
return
|
|
64
|
+
return typeof element?.type === 'string' && HOST_MODAL_NAMES.includes(element.type);
|
|
66
65
|
}
|
|
67
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":";;;;;;;;;;;AAEA,MAAMA,eAAe,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC;AAC3C,MAAMC,qBAAqB,GAAG,CAAC,WAAW,CAAC;AAC3C,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;AAClC,MAAMC,iBAAiB,GAAG,CAAC,WAAW,CAAC;AACvC,MAAMC,sBAAsB,GAAG,CAAC,eAAe,CAAC;AAChD,MAAMC,gBAAgB,GAAG,CAAC,OAAO,CAAC;;AAElC;AACA;AACA;AACA;AACO,SAASC,UAAUA,CAACC,OAA2B,EAAE;EACtD,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIR,eAAe,CAACS,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACpF;;AAEA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAACH,OAA2B,EAAE;EAC3D,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIP,qBAAqB,CAACQ,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC1F;;AAEA;AACA;AACA;AACA;AACO,SAASG,WAAWA,CAACJ,OAA2B,EAAE;EACvD,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIN,gBAAgB,CAACO,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACO,SAASI,YAAYA,CAACL,OAA2B,EAAE;EACxD,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIL,iBAAiB,CAACM,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACtF;;AAEA;AACA;AACA;AACA;AACO,SAASK,gBAAgBA,CAACN,OAA2B,EAAE;EAC5D,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIJ,sBAAsB,CAACK,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AAC3F;;AAEA;AACA;AACA;AACA;AACO,SAASM,WAAWA,CAACP,OAA2B,EAAE;EACvD,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ,IAAIH,gBAAgB,CAACI,QAAQ,CAACF,OAAO,CAACC,IAAI,CAAC;AACrF","ignoreList":[]}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
};
|
|
23
|
+
export declare const logger: {
|
|
24
|
+
debug(message: unknown, ...args: unknown[]): void;
|
|
25
|
+
info(message: unknown, ...args: unknown[]): void;
|
|
26
|
+
warn(message: unknown, ...args: unknown[]): void;
|
|
27
|
+
error(message: unknown, ...args: unknown[]): void;
|
|
28
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.logger = exports._console = void 0;
|
|
7
|
+
var nodeConsole = _interopRequireWildcard(require("console"));
|
|
8
|
+
var _picocolors = _interopRequireDefault(require("picocolors"));
|
|
9
|
+
var _redent = _interopRequireDefault(require("redent"));
|
|
10
|
+
var nodeUtil = _interopRequireWildcard(require("util"));
|
|
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
|
+
};
|
|
19
|
+
const logger = exports.logger = {
|
|
20
|
+
debug(message, ...args) {
|
|
21
|
+
const output = formatMessage('●', message, ...args);
|
|
22
|
+
_console.debug(_picocolors.default.dim(output));
|
|
23
|
+
},
|
|
24
|
+
info(message, ...args) {
|
|
25
|
+
const output = formatMessage('●', message, ...args);
|
|
26
|
+
_console.info(output);
|
|
27
|
+
},
|
|
28
|
+
warn(message, ...args) {
|
|
29
|
+
const output = formatMessage('▲', message, ...args);
|
|
30
|
+
_console.warn(_picocolors.default.yellow(output));
|
|
31
|
+
},
|
|
32
|
+
error(message, ...args) {
|
|
33
|
+
const output = formatMessage('■', message, ...args);
|
|
34
|
+
_console.error(_picocolors.default.red(output));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
function formatMessage(symbol, message, ...args) {
|
|
38
|
+
const formatted = nodeUtil.format(message, ...args);
|
|
39
|
+
const indented = (0, _redent.default)(formatted, 4);
|
|
40
|
+
return ` ${symbol} ${indented.trimStart()}\n`;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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}\n"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,WAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,OAAA,GAAAD,sBAAA,CAAAF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AACH,SAAS,EAAE,CAAC,CAAC;EACrC,OAAO,KAAKD,MAAM,IAAIG,QAAQ,CAACE,SAAS,CAAC,CAAC,IAAI;AAChD","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.defaultMapProps = defaultMapProps;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _object = require("./object");
|
|
9
|
-
const propsToDisplay = ['accessible', 'accessibilityElementsHidden', 'accessibilityHint', 'accessibilityLabel', 'accessibilityLabelledBy', 'accessibilityRole', 'accessibilityViewIsModal', 'alt', 'aria-busy', 'aria-checked', 'aria-disabled', 'aria-expanded', 'aria-hidden', 'aria-label', 'aria-labelledby', 'aria-modal', 'aria-selected', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'defaultValue', 'importantForAccessibility', 'nativeID', 'placeholder', 'role', 'testID', 'title', 'value'];
|
|
9
|
+
const propsToDisplay = ['accessible', 'accessibilityElementsHidden', 'accessibilityHint', 'accessibilityLabel', 'accessibilityLabelledBy', 'accessibilityRole', 'accessibilityViewIsModal', 'alt', 'aria-busy', 'aria-checked', 'aria-disabled', 'aria-expanded', 'aria-hidden', 'aria-label', 'aria-labelledby', 'aria-modal', 'aria-selected', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext', 'defaultValue', 'editable', 'importantForAccessibility', 'nativeID', 'placeholder', 'pointerEvents', 'role', 'testID', 'title', 'value'];
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Preserve props that are helpful in diagnosing test failures, while stripping rest
|
|
@@ -47,4 +47,4 @@ function extractStyle(style) {
|
|
|
47
47
|
const hasAnyKeys = Object.keys(result).length > 0;
|
|
48
48
|
return hasAnyKeys ? result : undefined;
|
|
49
49
|
}
|
|
50
|
-
//# sourceMappingURL=
|
|
50
|
+
//# sourceMappingURL=map-props.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-props.js","names":["_reactNative","require","_object","propsToDisplay","defaultMapProps","props","result","styles","StyleSheet","flatten","style","styleToDisplay","extractStyle","undefined","accessibilityState","removeUndefinedKeys","accessibilityValue","forEach","propName","display","opacity","hasAnyKeys","Object","keys","length"],"sources":["../../src/helpers/map-props.ts"],"sourcesContent":["import type { ViewStyle } from 'react-native';\nimport { StyleSheet } from 'react-native';\n\nimport { removeUndefinedKeys } from './object';\n\nexport type MapPropsFunction = (props: Record<string, unknown>) => Record<string, unknown>;\n\nconst propsToDisplay = [\n 'accessible',\n 'accessibilityElementsHidden',\n 'accessibilityHint',\n 'accessibilityLabel',\n 'accessibilityLabelledBy',\n 'accessibilityRole',\n 'accessibilityViewIsModal',\n 'alt',\n 'aria-busy',\n 'aria-checked',\n 'aria-disabled',\n 'aria-expanded',\n 'aria-hidden',\n 'aria-label',\n 'aria-labelledby',\n 'aria-modal',\n 'aria-selected',\n 'aria-valuemax',\n 'aria-valuemin',\n 'aria-valuenow',\n 'aria-valuetext',\n 'defaultValue',\n 'editable',\n 'importantForAccessibility',\n 'nativeID',\n 'placeholder',\n 'pointerEvents',\n 'role',\n 'testID',\n 'title',\n 'value',\n] as const;\n\n/**\n * Preserve props that are helpful in diagnosing test failures, while stripping rest\n */\nexport function defaultMapProps(props: Record<string, unknown>): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n\n const styles = StyleSheet.flatten(props.style as ViewStyle);\n const styleToDisplay = extractStyle(styles);\n if (styleToDisplay !== undefined) {\n result.style = styleToDisplay;\n }\n\n const accessibilityState = removeUndefinedKeys(props.accessibilityState);\n if (accessibilityState !== undefined) {\n result.accessibilityState = accessibilityState;\n }\n\n const accessibilityValue = removeUndefinedKeys(props.accessibilityValue);\n if (accessibilityValue !== undefined) {\n result.accessibilityValue = accessibilityValue;\n }\n\n propsToDisplay.forEach((propName) => {\n if (propName in props) {\n result[propName] = props[propName];\n }\n });\n\n return result;\n}\n\nfunction extractStyle(style: ViewStyle | undefined) {\n if (style == null) {\n return undefined;\n }\n\n const result: Record<string, unknown> = {};\n if (style.display === 'none') {\n result.display = 'none';\n }\n\n if (style.opacity === 0) {\n result.opacity = 0;\n }\n\n const hasAnyKeys = Object.keys(result).length > 0;\n return hasAnyKeys ? result : undefined;\n}\n"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAIA,MAAME,cAAc,GAAG,CACrB,YAAY,EACZ,6BAA6B,EAC7B,mBAAmB,EACnB,oBAAoB,EACpB,yBAAyB,EACzB,mBAAmB,EACnB,0BAA0B,EAC1B,KAAK,EACL,WAAW,EACX,cAAc,EACd,eAAe,EACf,eAAe,EACf,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,UAAU,EACV,2BAA2B,EAC3B,UAAU,EACV,aAAa,EACb,eAAe,EACf,MAAM,EACN,QAAQ,EACR,OAAO,EACP,OAAO,CACC;;AAEV;AACA;AACA;AACO,SAASC,eAAeA,CAACC,KAA8B,EAA2B;EACvF,MAAMC,MAA+B,GAAG,CAAC,CAAC;EAE1C,MAAMC,MAAM,GAAGC,uBAAU,CAACC,OAAO,CAACJ,KAAK,CAACK,KAAkB,CAAC;EAC3D,MAAMC,cAAc,GAAGC,YAAY,CAACL,MAAM,CAAC;EAC3C,IAAII,cAAc,KAAKE,SAAS,EAAE;IAChCP,MAAM,CAACI,KAAK,GAAGC,cAAc;EAC/B;EAEA,MAAMG,kBAAkB,GAAG,IAAAC,2BAAmB,EAACV,KAAK,CAACS,kBAAkB,CAAC;EACxE,IAAIA,kBAAkB,KAAKD,SAAS,EAAE;IACpCP,MAAM,CAACQ,kBAAkB,GAAGA,kBAAkB;EAChD;EAEA,MAAME,kBAAkB,GAAG,IAAAD,2BAAmB,EAACV,KAAK,CAACW,kBAAkB,CAAC;EACxE,IAAIA,kBAAkB,KAAKH,SAAS,EAAE;IACpCP,MAAM,CAACU,kBAAkB,GAAGA,kBAAkB;EAChD;EAEAb,cAAc,CAACc,OAAO,CAAEC,QAAQ,IAAK;IACnC,IAAIA,QAAQ,IAAIb,KAAK,EAAE;MACrBC,MAAM,CAACY,QAAQ,CAAC,GAAGb,KAAK,CAACa,QAAQ,CAAC;IACpC;EACF,CAAC,CAAC;EAEF,OAAOZ,MAAM;AACf;AAEA,SAASM,YAAYA,CAACF,KAA4B,EAAE;EAClD,IAAIA,KAAK,IAAI,IAAI,EAAE;IACjB,OAAOG,SAAS;EAClB;EAEA,MAAMP,MAA+B,GAAG,CAAC,CAAC;EAC1C,IAAII,KAAK,CAACS,OAAO,KAAK,MAAM,EAAE;IAC5Bb,MAAM,CAACa,OAAO,GAAG,MAAM;EACzB;EAEA,IAAIT,KAAK,CAACU,OAAO,KAAK,CAAC,EAAE;IACvBd,MAAM,CAACc,OAAO,GAAG,CAAC;EACpB;EAEA,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACjB,MAAM,CAAC,CAACkB,MAAM,GAAG,CAAC;EACjD,OAAOH,UAAU,GAAGf,MAAM,GAAGO,SAAS;AACxC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","matchAccessibilityState","node","matcher","busy","undefined","computeAriaBusy","checked","computeAriaChecked","disabled","computeAriaDisabled","expanded","computeAriaExpanded","selected","computeAriaSelected"],"sources":["../../../src/helpers/matchers/match-accessibility-state.ts"],"sourcesContent":["import { HostElement } from 'universal-test-renderer';\nimport {\n computeAriaBusy,\n computeAriaChecked,\n computeAriaDisabled,\n computeAriaExpanded,\n computeAriaSelected,\n} from '../accessibility';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\nexport function matchAccessibilityState(node: HostElement, matcher: AccessibilityStateMatcher) {\n if (matcher.busy !== undefined && matcher.busy !== computeAriaBusy(node)) {\n return false;\n }\n if (matcher.checked !== undefined && matcher.checked !== computeAriaChecked(node)) {\n return false;\n }\n if (matcher.disabled !== undefined && matcher.disabled !== computeAriaDisabled(node)) {\n return false;\n }\n if (matcher.expanded !== undefined && matcher.expanded !== computeAriaExpanded(node)) {\n return false;\n }\n if (matcher.selected !== undefined && matcher.selected !== computeAriaSelected(node)) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"match-accessibility-state.js","names":["_accessibility","require","matchAccessibilityState","node","matcher","busy","undefined","computeAriaBusy","checked","computeAriaChecked","disabled","computeAriaDisabled","expanded","computeAriaExpanded","selected","computeAriaSelected"],"sources":["../../../src/helpers/matchers/match-accessibility-state.ts"],"sourcesContent":["import type { HostElement } from 'universal-test-renderer';\n\nimport {\n computeAriaBusy,\n computeAriaChecked,\n computeAriaDisabled,\n computeAriaExpanded,\n computeAriaSelected,\n} from '../accessibility';\n\n// This type is the same as AccessibilityState from `react-native` package\n// It is re-declared here due to issues with migration from `@types/react-native` to\n// built in `react-native` types.\n// See: https://github.com/callstack/react-native-testing-library/issues/1351\nexport interface AccessibilityStateMatcher {\n disabled?: boolean;\n selected?: boolean;\n checked?: boolean | 'mixed';\n busy?: boolean;\n expanded?: boolean;\n}\n\nexport function matchAccessibilityState(node: HostElement, matcher: AccessibilityStateMatcher) {\n if (matcher.busy !== undefined && matcher.busy !== computeAriaBusy(node)) {\n return false;\n }\n if (matcher.checked !== undefined && matcher.checked !== computeAriaChecked(node)) {\n return false;\n }\n if (matcher.disabled !== undefined && matcher.disabled !== computeAriaDisabled(node)) {\n return false;\n }\n if (matcher.expanded !== undefined && matcher.expanded !== computeAriaExpanded(node)) {\n return false;\n }\n if (matcher.selected !== undefined && matcher.selected !== computeAriaSelected(node)) {\n return false;\n }\n\n return true;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,cAAA,GAAAC,OAAA;AAQA;AACA;AACA;AACA;;AASO,SAASC,uBAAuBA,CAACC,IAAiB,EAAEC,OAAkC,EAAE;EAC7F,IAAIA,OAAO,CAACC,IAAI,KAAKC,SAAS,IAAIF,OAAO,CAACC,IAAI,KAAK,IAAAE,8BAAe,EAACJ,IAAI,CAAC,EAAE;IACxE,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACI,OAAO,KAAKF,SAAS,IAAIF,OAAO,CAACI,OAAO,KAAK,IAAAC,iCAAkB,EAACN,IAAI,CAAC,EAAE;IACjF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACM,QAAQ,KAAKJ,SAAS,IAAIF,OAAO,CAACM,QAAQ,KAAK,IAAAC,kCAAmB,EAACR,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACQ,QAAQ,KAAKN,SAAS,IAAIF,OAAO,CAACQ,QAAQ,KAAK,IAAAC,kCAAmB,EAACV,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EACA,IAAIC,OAAO,CAACU,QAAQ,KAAKR,SAAS,IAAIF,OAAO,CAACU,QAAQ,KAAK,IAAAC,kCAAmB,EAACZ,IAAI,CAAC,EAAE;IACpF,OAAO,KAAK;EACd;EAEA,OAAO,IAAI;AACb","ignoreList":[]}
|