@testing-library/react-native 12.2.0 → 12.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.DS_Store +0 -0
- package/.eslintcache +1 -1
- package/.eslintignore +1 -0
- package/build/fireEvent.js +1 -1
- package/build/fireEvent.js.map +1 -1
- package/build/helpers/component-tree.d.ts +11 -5
- package/build/helpers/component-tree.js +5 -1
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/findAll.d.ts +2 -1
- package/build/helpers/findAll.js +2 -1
- package/build/helpers/findAll.js.map +1 -1
- package/build/helpers/host-component-names.d.ts +11 -2
- package/build/helpers/host-component-names.js +10 -0
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/matchLabelText.js +1 -1
- package/build/helpers/matchers/matchLabelText.js.map +1 -1
- package/build/queries/a11yState.js +1 -1
- package/build/queries/a11yState.js.map +1 -1
- package/build/queries/a11yValue.js +1 -1
- package/build/queries/a11yValue.js.map +1 -1
- package/build/queries/displayValue.js +5 -6
- package/build/queries/displayValue.js.map +1 -1
- package/build/queries/hintText.js +1 -1
- package/build/queries/hintText.js.map +1 -1
- package/build/queries/labelText.js +1 -1
- package/build/queries/labelText.js.map +1 -1
- package/build/queries/placeholderText.js +3 -4
- package/build/queries/placeholderText.js.map +1 -1
- package/build/queries/role.js +1 -1
- package/build/queries/role.js.map +1 -1
- package/build/queries/testId.js +3 -3
- package/build/queries/testId.js.map +1 -1
- package/build/queries/text.js +1 -2
- package/build/queries/text.js.map +1 -1
- package/build/render.js.map +1 -1
- package/build/user-event/clear.d.ts +3 -0
- package/build/user-event/clear.js +41 -0
- package/build/user-event/clear.js.map +1 -0
- package/build/user-event/index.d.ts +1 -0
- package/build/user-event/index.js +2 -1
- package/build/user-event/index.js.map +1 -1
- package/build/user-event/press/press.js +1 -4
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/setup/setup.d.ts +14 -2
- package/build/user-event/setup/setup.js +3 -1
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.d.ts +2 -1
- package/build/user-event/type/type.js +8 -4
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/host-components.d.ts +2 -0
- package/build/user-event/utils/host-components.js +11 -0
- package/build/user-event/utils/host-components.js.map +1 -0
- package/build/user-event/utils/index.d.ts +1 -0
- package/build/user-event/utils/index.js +11 -0
- package/build/user-event/utils/index.js.map +1 -1
- package/build/user-event/utils/text-range.d.ts +0 -1
- package/build/user-event/utils/text-range.js +0 -11
- package/build/user-event/utils/text-range.js.map +1 -1
- package/examples/basic/.expo/README.md +4 -6
- package/examples/basic/.expo/settings.json +2 -0
- package/examples/basic/__tests__/App.test.tsx +30 -12
- package/examples/basic/package.json +1 -1
- package/examples/basic/yarn.lock +2095 -3474
- package/examples/react-navigation/yarn.lock +1657 -2249
- package/examples/redux/yarn.lock +1772 -5376
- package/experiments-app/.expo/packager-info.json +9 -0
- package/experiments-app/.expo/settings.json +1 -2
- package/experiments-app/package.json +7 -9
- package/experiments-app/src/MainScreen.tsx +1 -0
- package/experiments-app/src/experiments.ts +20 -2
- package/experiments-app/src/screens/FlatListEvents.tsx +57 -0
- package/experiments-app/src/screens/ScrollViewEvents.tsx +65 -0
- package/experiments-app/src/screens/SectionListEvents.tsx +91 -0
- package/experiments-app/src/screens/TextInputEventPropagation.tsx +5 -17
- package/experiments-app/src/screens/TextInputEvents.tsx +13 -25
- package/experiments-app/src/utils/helpers.ts +13 -3
- package/experiments-app/yarn.lock +901 -1105
- package/experiments-rtl/.babelrc +8 -0
- package/experiments-rtl/.eslintrc.json +3 -0
- package/experiments-rtl/.gitignore +35 -0
- package/experiments-rtl/README.md +34 -0
- package/experiments-rtl/jest-setup.js +1 -0
- package/experiments-rtl/jest.config.js +4 -0
- package/experiments-rtl/next.config.js +4 -0
- package/experiments-rtl/package.json +38 -0
- package/experiments-rtl/postcss.config.js +6 -0
- package/experiments-rtl/public/next.svg +1 -0
- package/experiments-rtl/public/vercel.svg +1 -0
- package/experiments-rtl/src/app/__tests__/click.test.tsx +31 -0
- package/experiments-rtl/src/app/__tests__/managed-text-input.test.tsx +51 -0
- package/experiments-rtl/src/app/globals.css +27 -0
- package/experiments-rtl/src/app/layout.tsx +22 -0
- package/experiments-rtl/src/app/page.tsx +113 -0
- package/experiments-rtl/tailwind.config.ts +20 -0
- package/experiments-rtl/tsconfig.json +28 -0
- package/experiments-rtl/yarn.lock +5418 -0
- package/package.json +4 -2
- package/src/fireEvent.ts +1 -1
- package/src/helpers/component-tree.ts +14 -9
- package/src/helpers/findAll.ts +6 -4
- package/src/helpers/host-component-names.tsx +15 -2
- package/src/helpers/matchers/matchLabelText.ts +0 -1
- package/src/queries/a11yState.ts +2 -6
- package/src/queries/a11yValue.ts +2 -6
- package/src/queries/displayValue.ts +7 -14
- package/src/queries/hintText.ts +2 -7
- package/src/queries/labelText.ts +1 -3
- package/src/queries/placeholderText.ts +6 -13
- package/src/queries/role.ts +1 -2
- package/src/queries/testId.ts +5 -10
- package/src/queries/text.ts +3 -6
- package/src/render.tsx +1 -1
- package/src/user-event/__tests__/__snapshots__/clear.test.tsx.snap +269 -0
- package/src/user-event/__tests__/clear.test.tsx +217 -0
- package/src/user-event/clear.ts +59 -0
- package/src/user-event/index.ts +1 -0
- package/src/user-event/press/press.ts +8 -14
- package/src/user-event/setup/setup.ts +17 -2
- package/src/user-event/type/__tests__/type-managed.test.tsx +0 -1
- package/src/user-event/type/__tests__/type.test.tsx +0 -1
- package/src/user-event/type/type.ts +16 -13
- package/src/user-event/utils/__tests__/wait.test.ts +0 -1
- package/src/user-event/utils/host-components.ts +6 -0
- package/src/user-event/utils/index.ts +1 -0
- package/src/user-event/utils/text-range.ts +0 -7
- package/website/docs/Queries.md +64 -59
- package/website/docs/UserEvent.md +48 -0
- package/build/helpers/filterNodeByType.d.ts +0 -3
- package/build/helpers/filterNodeByType.js +0 -9
- package/build/helpers/filterNodeByType.js.map +0 -1
- package/coverage/clover.xml +0 -1176
- package/coverage/coverage-final.json +0 -70
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -266
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/act.ts.html +0 -343
- package/coverage/lcov-report/src/cleanup.ts.html +0 -130
- package/coverage/lcov-report/src/config.ts.html +0 -301
- package/coverage/lcov-report/src/fireEvent.ts.html +0 -559
- package/coverage/lcov-report/src/flushMicroTasks.ts.html +0 -124
- package/coverage/lcov-report/src/helpers/accessiblity.ts.html +0 -412
- package/coverage/lcov-report/src/helpers/component-tree.ts.html +0 -352
- package/coverage/lcov-report/src/helpers/debugDeep.ts.html +0 -166
- package/coverage/lcov-report/src/helpers/debugShallow.ts.html +0 -151
- package/coverage/lcov-report/src/helpers/deprecation.ts.html +0 -244
- package/coverage/lcov-report/src/helpers/errors.ts.html +0 -283
- package/coverage/lcov-report/src/helpers/filterNodeByType.ts.html +0 -106
- package/coverage/lcov-report/src/helpers/findAll.ts.html +0 -289
- package/coverage/lcov-report/src/helpers/format-default.ts.html +0 -301
- package/coverage/lcov-report/src/helpers/format.ts.html +0 -226
- package/coverage/lcov-report/src/helpers/getTextContent.ts.html +0 -145
- package/coverage/lcov-report/src/helpers/host-component-names.tsx.html +0 -286
- package/coverage/lcov-report/src/helpers/index.html +0 -326
- package/coverage/lcov-report/src/helpers/matchers/accessibilityState.ts.html +0 -229
- package/coverage/lcov-report/src/helpers/matchers/accessibilityValue.ts.html +0 -157
- package/coverage/lcov-report/src/helpers/matchers/index.html +0 -206
- package/coverage/lcov-report/src/helpers/matchers/matchArrayProp.ts.html +0 -148
- package/coverage/lcov-report/src/helpers/matchers/matchLabelText.ts.html +0 -238
- package/coverage/lcov-report/src/helpers/matchers/matchObjectProp.ts.html +0 -160
- package/coverage/lcov-report/src/helpers/matchers/matchStringProp.ts.html +0 -154
- package/coverage/lcov-report/src/helpers/matchers/matchTextContent.ts.html +0 -145
- package/coverage/lcov-report/src/helpers/query-name.ts.html +0 -97
- package/coverage/lcov-report/src/helpers/stringValidation.ts.html +0 -193
- package/coverage/lcov-report/src/helpers/timers.ts.html +0 -382
- package/coverage/lcov-report/src/index.html +0 -356
- package/coverage/lcov-report/src/index.ts.html +0 -184
- package/coverage/lcov-report/src/matches.ts.html +0 -232
- package/coverage/lcov-report/src/pure.ts.html +0 -157
- package/coverage/lcov-report/src/queries/a11yState.ts.html +0 -478
- package/coverage/lcov-report/src/queries/a11yValue.ts.html +0 -478
- package/coverage/lcov-report/src/queries/displayValue.ts.html +0 -319
- package/coverage/lcov-report/src/queries/hintText.ts.html +0 -421
- package/coverage/lcov-report/src/queries/index.html +0 -281
- package/coverage/lcov-report/src/queries/labelText.ts.html +0 -262
- package/coverage/lcov-report/src/queries/makeQueries.ts.html +0 -850
- package/coverage/lcov-report/src/queries/placeholderText.ts.html +0 -322
- package/coverage/lcov-report/src/queries/role.ts.html +0 -481
- package/coverage/lcov-report/src/queries/testId.ts.html +0 -298
- package/coverage/lcov-report/src/queries/text.ts.html +0 -283
- package/coverage/lcov-report/src/queries/unsafeProps.ts.html +0 -313
- package/coverage/lcov-report/src/queries/unsafeType.ts.html +0 -304
- package/coverage/lcov-report/src/react-versions.ts.html +0 -118
- package/coverage/lcov-report/src/render-act.ts.html +0 -142
- package/coverage/lcov-report/src/render.tsx.html +0 -592
- package/coverage/lcov-report/src/renderHook.tsx.html +0 -262
- package/coverage/lcov-report/src/screen.ts.html +0 -454
- package/coverage/lcov-report/src/shallow.ts.html +0 -139
- package/coverage/lcov-report/src/test-utils/events.ts.html +0 -145
- package/coverage/lcov-report/src/test-utils/index.html +0 -131
- package/coverage/lcov-report/src/test-utils/index.ts.html +0 -88
- package/coverage/lcov-report/src/user-event/event-builder/common.ts.html +0 -229
- package/coverage/lcov-report/src/user-event/event-builder/index.html +0 -146
- package/coverage/lcov-report/src/user-event/event-builder/index.ts.html +0 -106
- package/coverage/lcov-report/src/user-event/event-builder/test-input.ts.html +0 -343
- package/coverage/lcov-report/src/user-event/event-builder/text-input.ts.html +0 -343
- package/coverage/lcov-report/src/user-event/index.html +0 -116
- package/coverage/lcov-report/src/user-event/index.ts.html +0 -121
- package/coverage/lcov-report/src/user-event/press/index.html +0 -131
- package/coverage/lcov-report/src/user-event/press/index.ts.html +0 -88
- package/coverage/lcov-report/src/user-event/press/press.ts.html +0 -133
- package/coverage/lcov-report/src/user-event/setup/index.html +0 -131
- package/coverage/lcov-report/src/user-event/setup/index.ts.html +0 -91
- package/coverage/lcov-report/src/user-event/setup/setup.ts.html +0 -358
- package/coverage/lcov-report/src/user-event/type/index.html +0 -146
- package/coverage/lcov-report/src/user-event/type/index.ts.html +0 -88
- package/coverage/lcov-report/src/user-event/type/parseKeys.ts.html +0 -208
- package/coverage/lcov-report/src/user-event/type/type.ts.html +0 -484
- package/coverage/lcov-report/src/user-event/utils/content-size.ts.html +0 -160
- package/coverage/lcov-report/src/user-event/utils/dispatch-event.ts.html +0 -367
- package/coverage/lcov-report/src/user-event/utils/events.ts.html +0 -247
- package/coverage/lcov-report/src/user-event/utils/index.html +0 -176
- package/coverage/lcov-report/src/user-event/utils/index.ts.html +0 -97
- package/coverage/lcov-report/src/user-event/utils/text-range.ts.html +0 -118
- package/coverage/lcov-report/src/user-event/utils/wait.ts.html +0 -130
- package/coverage/lcov-report/src/waitFor.ts.html +0 -772
- package/coverage/lcov-report/src/waitForElementToBeRemoved.ts.html +0 -211
- package/coverage/lcov-report/src/within.ts.html +0 -175
- package/coverage/lcov.info +0 -2614
- package/examples/.DS_Store +0 -0
- package/examples/basic/.expo/devices.json +0 -3
- package/examples/basic/yarn-error.log +0 -8083
- package/examples/redux/yarn-error.log +0 -8083
- package/src/.DS_Store +0 -0
- package/src/__tests__/.DS_Store +0 -0
- package/src/helpers/filterNodeByType.ts +0 -7
- package/website/.DS_Store +0 -0
- package/website/.docusaurus/DONT-EDIT-THIS-FOLDER +0 -5
- package/website/.docusaurus/client-modules.js +0 -6
- package/website/.docusaurus/codeTranslations.json +0 -1
- package/website/.docusaurus/docusaurus-plugin-content-blog/default/blog-post-list-prop-default.json +0 -4
- package/website/.docusaurus/docusaurus-plugin-content-blog/default/plugin-route-context-module-100.json +0 -4
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/plugin-route-context-module-100.json +0 -4
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-api-md-c82.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-eslint-p-llugin-testing-library-md-d24.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-faq-md-ad8.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-getting-started-md-8a6.json +0 -23
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-how-should-i-query-md-f2d.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-migration-v-11-md-add.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-migration-v-12-md-14f.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-migration-v-2-md-698.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-migration-v-7-md-6bb.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-migration-v-9-md-f69.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-queries-md-7ad.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-react-navigation-md-1bd.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-redux-integration-md-77b.json +0 -23
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-testing-environment-md-1c6.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-troubleshooting-md-01d.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-understanding-act-md-aa9.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/site-docs-user-event-md-501.json +0 -27
- package/website/.docusaurus/docusaurus-plugin-content-docs/default/version-current-metadata-prop-751.json +0 -268
- package/website/.docusaurus/docusaurus-plugin-content-docs/react-native-testing-library-docs-route-96e.json +0 -115
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-api-md-c82.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-eslint-p-llugin-testing-library-md-d24.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-faq-md-ad8.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-getting-started-md-8a6.json +0 -15
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-how-should-i-query-md-f2d.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-migration-v-11-md-add.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-migration-v-2-md-698.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-migration-v-7-md-6bb.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-migration-v-9-md-f69.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-queries-md-7ad.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-react-navigation-md-1bd.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-redux-integration-md-77b.json +0 -15
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-troubleshooting-md-01d.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-docs/site-docs-understanding-act-md-aa9.json +0 -19
- package/website/.docusaurus/docusaurus-plugin-content-pages/default/plugin-route-context-module-100.json +0 -4
- package/website/.docusaurus/docusaurus-plugin-debug/default/docusaurus-debug-all-content-673.json +0 -623
- package/website/.docusaurus/docusaurus-plugin-debug/default/plugin-route-context-module-100.json +0 -4
- package/website/.docusaurus/docusaurus-theme-search-algolia/default/plugin-route-context-module-100.json +0 -4
- package/website/.docusaurus/docusaurus.config.js +0 -267
- package/website/.docusaurus/docusaurus.config.mjs +0 -365
- package/website/.docusaurus/globalData.json +0 -113
- package/website/.docusaurus/i18n.json +0 -17
- package/website/.docusaurus/registry.js +0 -35
- package/website/.docusaurus/routes.js +0 -162
- package/website/.docusaurus/routesChunkNames.json +0 -133
- package/website/.docusaurus/site-metadata.json +0 -36
- package/yarn-error.log +0 -10613
|
@@ -8,6 +8,10 @@ exports.getHostParent = getHostParent;
|
|
|
8
8
|
exports.getHostSelves = getHostSelves;
|
|
9
9
|
exports.getHostSiblings = getHostSiblings;
|
|
10
10
|
exports.isHostElement = isHostElement;
|
|
11
|
+
/**
|
|
12
|
+
* ReactTestInstance referring to host element.
|
|
13
|
+
*/
|
|
14
|
+
|
|
11
15
|
/**
|
|
12
16
|
* Checks if the given element is a host element.
|
|
13
17
|
* @param element The element to check.
|
|
@@ -64,7 +68,7 @@ function getHostChildren(element) {
|
|
|
64
68
|
* if the passed element is a composite element, it will return an array containing its host children (zero, one or many).
|
|
65
69
|
*/
|
|
66
70
|
function getHostSelves(element) {
|
|
67
|
-
return
|
|
71
|
+
return isHostElement(element) ? [element] : getHostChildren(element);
|
|
68
72
|
}
|
|
69
73
|
|
|
70
74
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelves","getHostSiblings","hostParent","hostSelves","filter","sibling","includes"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(element?: ReactTestInstance | null) {\n return typeof element?.type === 'string';\n}\n\n/**\n * Returns first host ancestor for given element.\n * @param element The element start traversing from.\n */\nexport function getHostParent(\n element: ReactTestInstance | null\n):
|
|
1
|
+
{"version":3,"file":"component-tree.js","names":["isHostElement","element","type","getHostParent","current","parent","getHostChildren","hostChildren","children","forEach","child","push","getHostSelves","getHostSiblings","hostParent","hostSelves","filter","sibling","includes"],"sources":["../../src/helpers/component-tree.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\n\n/**\n * ReactTestInstance referring to host element.\n */\nexport type HostTestInstance = ReactTestInstance & { type: string };\n\n/**\n * Checks if the given element is a host element.\n * @param element The element to check.\n */\nexport function isHostElement(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return typeof element?.type === 'string';\n}\n\n/**\n * Returns first host ancestor for given element.\n * @param element The element start traversing from.\n */\nexport function getHostParent(\n element: ReactTestInstance | null\n): HostTestInstance | null {\n if (element == null) {\n return null;\n }\n\n let current = element.parent;\n while (current) {\n if (isHostElement(current)) {\n return current;\n }\n\n current = current.parent;\n }\n\n return null;\n}\n\n/**\n * Returns host children for given element.\n * @param element The element start traversing from.\n */\nexport function getHostChildren(\n element: ReactTestInstance | null\n): HostTestInstance[] {\n if (element == null) {\n return [];\n }\n\n const hostChildren: HostTestInstance[] = [];\n\n element.children.forEach((child) => {\n if (typeof child !== 'object') {\n return;\n }\n\n if (isHostElement(child)) {\n hostChildren.push(child);\n } else {\n hostChildren.push(...getHostChildren(child));\n }\n });\n\n return hostChildren;\n}\n\n/**\n * Return the array of host elements that represent the passed element.\n *\n * @param element The element start traversing from.\n * @returns If the passed element is a host element, it will return an array containing only that element,\n * if the passed element is a composite element, it will return an array containing its host children (zero, one or many).\n */\nexport function getHostSelves(\n element: ReactTestInstance | null\n): HostTestInstance[] {\n return isHostElement(element) ? [element] : getHostChildren(element);\n}\n\n/**\n * Returns host siblings for given element.\n * @param element The element start traversing from.\n */\nexport function getHostSiblings(\n element: ReactTestInstance | null\n): HostTestInstance[] {\n const hostParent = getHostParent(element);\n const hostSelves = getHostSelves(element);\n return getHostChildren(hostParent).filter(\n (sibling) => !hostSelves.includes(sibling)\n );\n}\n"],"mappings":";;;;;;;;;;AAEA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACO,SAASA,aAAaA,CAC3BC,OAAkC,EACL;EAC7B,OAAO,OAAOA,OAAO,EAAEC,IAAI,KAAK,QAAQ;AAC1C;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CAC3BF,OAAiC,EACR;EACzB,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,IAAI;EACb;EAEA,IAAIG,OAAO,GAAGH,OAAO,CAACI,MAAM;EAC5B,OAAOD,OAAO,EAAE;IACd,IAAIJ,aAAa,CAACI,OAAO,CAAC,EAAE;MAC1B,OAAOA,OAAO;IAChB;IAEAA,OAAO,GAAGA,OAAO,CAACC,MAAM;EAC1B;EAEA,OAAO,IAAI;AACb;;AAEA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAC7BL,OAAiC,EACb;EACpB,IAAIA,OAAO,IAAI,IAAI,EAAE;IACnB,OAAO,EAAE;EACX;EAEA,MAAMM,YAAgC,GAAG,EAAE;EAE3CN,OAAO,CAACO,QAAQ,CAACC,OAAO,CAAEC,KAAK,IAAK;IAClC,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC7B;IACF;IAEA,IAAIV,aAAa,CAACU,KAAK,CAAC,EAAE;MACxBH,YAAY,CAACI,IAAI,CAACD,KAAK,CAAC;IAC1B,CAAC,MAAM;MACLH,YAAY,CAACI,IAAI,CAAC,GAAGL,eAAe,CAACI,KAAK,CAAC,CAAC;IAC9C;EACF,CAAC,CAAC;EAEF,OAAOH,YAAY;AACrB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,aAAaA,CAC3BX,OAAiC,EACb;EACpB,OAAOD,aAAa,CAACC,OAAO,CAAC,GAAG,CAACA,OAAO,CAAC,GAAGK,eAAe,CAACL,OAAO,CAAC;AACtE;;AAEA;AACA;AACA;AACA;AACO,SAASY,eAAeA,CAC7BZ,OAAiC,EACb;EACpB,MAAMa,UAAU,GAAGX,aAAa,CAACF,OAAO,CAAC;EACzC,MAAMc,UAAU,GAAGH,aAAa,CAACX,OAAO,CAAC;EACzC,OAAOK,eAAe,CAACQ,UAAU,CAAC,CAACE,MAAM,CACtCC,OAAO,IAAK,CAACF,UAAU,CAACG,QAAQ,CAACD,OAAO,CAC3C,CAAC;AACH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { HostTestInstance } from './component-tree';
|
|
2
3
|
interface FindAllOptions {
|
|
3
4
|
/** Match elements hidden from accessibility */
|
|
4
5
|
includeHiddenElements?: boolean;
|
|
@@ -6,5 +7,5 @@ interface FindAllOptions {
|
|
|
6
7
|
hidden?: boolean;
|
|
7
8
|
matchDeepestOnly?: boolean;
|
|
8
9
|
}
|
|
9
|
-
export declare function findAll(root: ReactTestInstance, predicate: (element: ReactTestInstance) => boolean, options?: FindAllOptions):
|
|
10
|
+
export declare function findAll(root: ReactTestInstance, predicate: (element: ReactTestInstance) => boolean, options?: FindAllOptions): HostTestInstance[];
|
|
10
11
|
export {};
|
package/build/helpers/findAll.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.findAll = findAll;
|
|
7
7
|
var _config = require("../config");
|
|
8
8
|
var _accessiblity = require("./accessiblity");
|
|
9
|
+
var _componentTree = require("./component-tree");
|
|
9
10
|
function findAll(root, predicate, options) {
|
|
10
11
|
const results = findAllInternal(root, predicate, options);
|
|
11
12
|
const includeHiddenElements = options?.includeHiddenElements ?? options?.hidden ?? (0, _config.getConfig)()?.defaultIncludeHiddenElements;
|
|
@@ -33,7 +34,7 @@ function findAllInternal(root, predicate, options) {
|
|
|
33
34
|
});
|
|
34
35
|
if (
|
|
35
36
|
// When matchDeepestOnly = true: add current element only if no descendants match
|
|
36
|
-
(!options?.matchDeepestOnly || matchingDescendants.length === 0) && predicate(root)) {
|
|
37
|
+
(!options?.matchDeepestOnly || matchingDescendants.length === 0) && (0, _componentTree.isHostElement)(root) && predicate(root)) {
|
|
37
38
|
results.push(root);
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findAll.js","names":["_config","require","_accessiblity","findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length"],"sources":["../../src/helpers/findAll.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessiblity';\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: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n) {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ??\n options?.hidden ??\n getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<ReactTestInstance>();\n return results.filter(\n (element) => !isHiddenFromAccessibility(element, { cache })\n );\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n):
|
|
1
|
+
{"version":3,"file":"findAll.js","names":["_config","require","_accessiblity","_componentTree","findAll","root","predicate","options","results","findAllInternal","includeHiddenElements","hidden","getConfig","defaultIncludeHiddenElements","cache","WeakMap","filter","element","isHiddenFromAccessibility","matchingDescendants","children","forEach","child","push","matchDeepestOnly","length","isHostElement"],"sources":["../../src/helpers/findAll.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { getConfig } from '../config';\nimport { isHiddenFromAccessibility } from './accessiblity';\nimport { HostTestInstance, isHostElement } from './component-tree';\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: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n): HostTestInstance[] {\n const results = findAllInternal(root, predicate, options);\n\n const includeHiddenElements =\n options?.includeHiddenElements ??\n options?.hidden ??\n getConfig()?.defaultIncludeHiddenElements;\n\n if (includeHiddenElements) {\n return results;\n }\n\n const cache = new WeakMap<ReactTestInstance>();\n return results.filter(\n (element) => !isHiddenFromAccessibility(element, { cache })\n );\n}\n\n// Extracted from React Test Renderer\n// src: https://github.com/facebook/react/blob/8e2bde6f2751aa6335f3cef488c05c3ea08e074a/packages/react-test-renderer/src/ReactTestRenderer.js#L402\nfunction findAllInternal(\n root: ReactTestInstance,\n predicate: (element: ReactTestInstance) => boolean,\n options?: FindAllOptions\n): HostTestInstance[] {\n const results: HostTestInstance[] = [];\n\n // Match descendants first but do not add them to results yet.\n const matchingDescendants: HostTestInstance[] = [];\n root.children.forEach((child) => {\n if (typeof child === 'string') {\n return;\n }\n matchingDescendants.push(...findAllInternal(child, predicate, options));\n });\n\n if (\n // When matchDeepestOnly = true: add current element only if no descendants match\n (!options?.matchDeepestOnly || matchingDescendants.length === 0) &&\n isHostElement(root) &&\n predicate(root)\n ) {\n results.push(root);\n }\n\n // Add matching descendants after element to preserve original tree walk order.\n results.push(...matchingDescendants);\n\n return results;\n}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AG,OAAO,CAACe,IAAI,CAAC,GAAGJ,mBAAmB,CAAC;EAEpC,OAAOX,OAAO;AAChB"}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
2
|
import { HostComponentNames } from '../config';
|
|
3
|
+
import { HostTestInstance } from './component-tree';
|
|
3
4
|
export declare function getHostComponentNames(): HostComponentNames;
|
|
4
5
|
export declare function configureHostComponentNamesIfNeeded(): void;
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Checks if the given element is a host Text.
|
|
8
|
+
* @param element The element to check.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isHostText(element?: ReactTestInstance | null): element is HostTestInstance;
|
|
11
|
+
/**
|
|
12
|
+
* Checks if the given element is a host TextInput.
|
|
13
|
+
* @param element The element to check.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance;
|
|
@@ -61,9 +61,19 @@ function getByTestId(instance, testID) {
|
|
|
61
61
|
}
|
|
62
62
|
return nodes[0];
|
|
63
63
|
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Checks if the given element is a host Text.
|
|
67
|
+
* @param element The element to check.
|
|
68
|
+
*/
|
|
64
69
|
function isHostText(element) {
|
|
65
70
|
return element?.type === getHostComponentNames().text;
|
|
66
71
|
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Checks if the given element is a host TextInput.
|
|
75
|
+
* @param element The element to check.
|
|
76
|
+
*/
|
|
67
77
|
function isHostTextInput(element) {
|
|
68
78
|
return element?.type === getHostComponentNames().textInput;
|
|
69
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Switch","text","getByTestId","root","type","textInput","switch","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Switch testID=\"switch\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\nexport function isHostText(element?: ReactTestInstance) {\n return element?.type === getHostComponentNames().text;\n}\n\nexport function isHostTextInput(element?: ReactTestInstance) {\n return element?.type === getHostComponentNames().textInput;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GAAA,IAAAA,GAAA,CAAAC,UAAA,WAAAD,GAAA,QAAAA,GAAA,oBAAAA,GAAA,wBAAAA,GAAA,4BAAAE,OAAA,EAAAF,GAAA,UAAAG,KAAA,GAAAR,wBAAA,CAAAC,WAAA,OAAAO,KAAA,IAAAA,KAAA,CAAAC,GAAA,CAAAJ,GAAA,YAAAG,KAAA,CAAAE,GAAA,CAAAL,GAAA,SAAAM,MAAA,WAAAC,qBAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,GAAA,IAAAX,GAAA,QAAAW,GAAA,kBAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAd,GAAA,EAAAW,GAAA,SAAAI,IAAA,GAAAR,qBAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAV,GAAA,EAAAW,GAAA,cAAAI,IAAA,KAAAA,IAAA,CAAAV,GAAA,IAAAU,IAAA,CAAAC,GAAA,KAAAR,MAAA,CAAAC,cAAA,CAAAH,MAAA,EAAAK,GAAA,EAAAI,IAAA,YAAAT,MAAA,CAAAK,GAAA,IAAAX,GAAA,CAAAW,GAAA,SAAAL,MAAA,CAAAJ,OAAA,GAAAF,GAAA,MAAAG,KAAA,IAAAA,KAAA,CAAAa,GAAA,CAAAhB,GAAA,EAAAM,MAAA,YAAAA,MAAA;
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","default","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Switch","text","getByTestId","root","type","textInput","switch","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Switch testID=\"switch\" />\n </View>\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error\n ? error.message\n : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text.\n * @param element The element to check.\n */\nexport function isHostText(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput.\n * @param element The element to check.\n */\nexport function isHostTextInput(\n element?: ReactTestInstance | null\n): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n"],"mappings":";;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,WAAA,eAAAC,OAAA,kCAAAC,iBAAA,OAAAD,OAAA,QAAAE,gBAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,WAAA,WAAAA,WAAA,GAAAG,gBAAA,GAAAD,iBAAA,KAAAF,WAAA;AAAA,SAAAN,wBAAAU,GAAA,EAAAJ,WAAA,SAAAA,WAAA,IAAAI,GA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3BC,IAAI,IAAK,OAAOA,IAAI,CAACV,IAAI,KAAK,QAAQ,IAAIU,IAAI,CAACC,KAAK,CAACjB,MAAM,KAAKA,MACnE,CAAC;EAED,IAAIc,KAAK,CAACI,MAAM,KAAK,CAAC,EAAE;IACtB,MAAM,IAAIN,KAAK,CAAE,0CAAyCZ,MAAO,EAAC,CAAC;EACrE;EAEA,OAAOc,KAAK,CAAC,CAAC,CAAC;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CACxBC,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEd,IAAI,KAAKlB,qBAAqB,CAAC,CAAC,CAACe,IAAI;AACvD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,eAAeA,CAC7BD,OAAkC,EACL;EAC7B,OAAOA,OAAO,EAAEd,IAAI,KAAKlB,qBAAqB,CAAC,CAAC,CAACmB,SAAS;AAC5D"}
|
|
@@ -21,6 +21,6 @@ function matchAccessibilityLabelledBy(root, nativeId, text, options) {
|
|
|
21
21
|
if (!nativeId) {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
24
|
-
return (0, _findAll.findAll)(root, node =>
|
|
24
|
+
return (0, _findAll.findAll)(root, node => node.props.nativeID === nativeId && (0, _matchTextContent.matchTextContent)(node, text, options)).length > 0;
|
|
25
25
|
}
|
|
26
26
|
//# sourceMappingURL=matchLabelText.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"matchLabelText.js","names":["_matches","require","_findAll","_matchTextContent","matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","
|
|
1
|
+
{"version":3,"file":"matchLabelText.js","names":["_matches","require","_findAll","_matchTextContent","matchLabelText","root","element","text","options","matchAccessibilityLabel","matchAccessibilityLabelledBy","props","accessibilityLabelledBy","exact","normalizer","matches","accessibilityLabel","nativeId","findAll","node","nativeID","matchTextContent","length"],"sources":["../../../src/helpers/matchers/matchLabelText.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { matches, TextMatch, TextMatchOptions } from '../../matches';\nimport { findAll } from '../findAll';\nimport { matchTextContent } from './matchTextContent';\n\nexport function matchLabelText(\n root: ReactTestInstance,\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) {\n return (\n matchAccessibilityLabel(element, text, options) ||\n matchAccessibilityLabelledBy(\n root,\n element.props.accessibilityLabelledBy,\n text,\n options\n )\n );\n}\n\nfunction matchAccessibilityLabel(\n element: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions\n) {\n const { exact, normalizer } = options;\n return matches(text, element.props.accessibilityLabel, normalizer, exact);\n}\n\nfunction matchAccessibilityLabelledBy(\n root: ReactTestInstance,\n nativeId: string | undefined,\n text: TextMatch,\n options: TextMatchOptions\n) {\n if (!nativeId) {\n return false;\n }\n\n return (\n findAll(\n root,\n (node) =>\n node.props.nativeID === nativeId &&\n matchTextContent(node, text, options)\n ).length > 0\n );\n}\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,iBAAA,GAAAF,OAAA;AAEO,SAASG,cAAcA,CAC5BC,IAAuB,EACvBC,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,EAC9B;EACA,OACEC,uBAAuB,CAACH,OAAO,EAAEC,IAAI,EAAEC,OAAO,CAAC,IAC/CE,4BAA4B,CAC1BL,IAAI,EACJC,OAAO,CAACK,KAAK,CAACC,uBAAuB,EACrCL,IAAI,EACJC,OACF,CAAC;AAEL;AAEA,SAASC,uBAAuBA,CAC9BH,OAA0B,EAC1BC,IAAe,EACfC,OAAyB,EACzB;EACA,MAAM;IAAEK,KAAK;IAAEC;EAAW,CAAC,GAAGN,OAAO;EACrC,OAAO,IAAAO,gBAAO,EAACR,IAAI,EAAED,OAAO,CAACK,KAAK,CAACK,kBAAkB,EAAEF,UAAU,EAAED,KAAK,CAAC;AAC3E;AAEA,SAASH,4BAA4BA,CACnCL,IAAuB,EACvBY,QAA4B,EAC5BV,IAAe,EACfC,OAAyB,EACzB;EACA,IAAI,CAACS,QAAQ,EAAE;IACb,OAAO,KAAK;EACd;EAEA,OACE,IAAAC,gBAAO,EACLb,IAAI,EACHc,IAAI,IACHA,IAAI,CAACR,KAAK,CAACS,QAAQ,KAAKH,QAAQ,IAChC,IAAAI,kCAAgB,EAACF,IAAI,EAAEZ,IAAI,EAAEC,OAAO,CACxC,CAAC,CAACc,MAAM,GAAG,CAAC;AAEhB"}
|
|
@@ -10,7 +10,7 @@ var _findAll = require("../helpers/findAll");
|
|
|
10
10
|
var _accessibilityState = require("../helpers/matchers/accessibilityState");
|
|
11
11
|
var _makeQueries = require("./makeQueries");
|
|
12
12
|
const queryAllByA11yState = instance => function queryAllByA11yStateFn(matcher, queryOptions) {
|
|
13
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
13
|
+
return (0, _findAll.findAll)(instance, node => (0, _accessibilityState.matchAccessibilityState)(node, matcher), queryOptions);
|
|
14
14
|
};
|
|
15
15
|
const buildErrorMessage = (state = {}) => {
|
|
16
16
|
const errors = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11yState.js","names":["_accessiblity","require","_deprecation","_findAll","_accessibilityState","_makeQueries","queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","
|
|
1
|
+
{"version":3,"file":"a11yState.js","names":["_accessiblity","require","_deprecation","_findAll","_accessibilityState","_makeQueries","queryAllByA11yState","instance","queryAllByA11yStateFn","matcher","queryOptions","findAll","node","matchAccessibilityState","buildErrorMessage","state","errors","accessibilityStateKeys","forEach","stateKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yStateQueries","getByA11yState","getAllByA11yState","queryByA11yState","findByA11yState","findAllByA11yState","deprecateQueries","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState","exports"],"sources":["../../src/queries/a11yState.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { accessibilityStateKeys } from '../helpers/accessiblity';\nimport { deprecateQueries } from '../helpers/deprecation';\nimport { findAll } from '../helpers/findAll';\nimport {\n AccessibilityStateMatcher,\n matchAccessibilityState,\n} from '../helpers/matchers/accessibilityState';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yState = (\n instance: ReactTestInstance\n): QueryAllByQuery<AccessibilityStateMatcher, CommonQueryOptions> =>\n function queryAllByA11yStateFn(matcher, queryOptions) {\n return findAll(\n instance,\n (node) => matchAccessibilityState(node, matcher),\n queryOptions\n );\n };\n\nconst buildErrorMessage = (state: AccessibilityStateMatcher = {}) => {\n const errors: string[] = [];\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (state[stateKey] !== undefined) {\n errors.push(`${stateKey} state: ${state[stateKey]}`);\n }\n });\n\n return errors.join(', ');\n};\n\nconst getMultipleError = (state: AccessibilityStateMatcher) =>\n `Found multiple elements with ${buildErrorMessage(state)}`;\n\nconst getMissingError = (state: AccessibilityStateMatcher) =>\n `Unable to find an element with ${buildErrorMessage(state)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yState,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yStateQueries = {\n getByA11yState: GetByQuery<AccessibilityStateMatcher, CommonQueryOptions>;\n getAllByA11yState: GetAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n queryByA11yState: QueryByQuery<AccessibilityStateMatcher, CommonQueryOptions>;\n queryAllByA11yState: QueryAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n findByA11yState: FindByQuery<AccessibilityStateMatcher, CommonQueryOptions>;\n findAllByA11yState: FindAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n\n getByAccessibilityState: GetByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n getAllByAccessibilityState: GetAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n queryByAccessibilityState: QueryByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n queryAllByAccessibilityState: QueryAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n findByAccessibilityState: FindByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n findAllByAccessibilityState: FindAllByQuery<\n AccessibilityStateMatcher,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yStateQueries = (\n instance: ReactTestInstance\n): ByA11yStateQueries => {\n const getByA11yState = getBy(instance);\n const getAllByA11yState = getAllBy(instance);\n const queryByA11yState = queryBy(instance);\n const queryAllByA11yState = queryAllBy(instance);\n const findByA11yState = findBy(instance);\n const findAllByA11yState = findAllBy(instance);\n\n return {\n ...deprecateQueries(\n {\n getByA11yState,\n getAllByA11yState,\n queryByA11yState,\n queryAllByA11yState,\n findByA11yState,\n findAllByA11yState,\n getByAccessibilityState: getByA11yState,\n getAllByAccessibilityState: getAllByA11yState,\n queryByAccessibilityState: queryByA11yState,\n queryAllByAccessibilityState: queryAllByA11yState,\n findByAccessibilityState: findByA11yState,\n findAllByAccessibilityState: findAllByA11yState,\n },\n 'Use {queryPrefix}ByRole(role, { disabled, selected, checked, busy, expanded }) query or expect(...).toHaveAccessibilityState(...) matcher from \"@testing-library/jest-native\" package instead.'\n ),\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,O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AAU,CAACrB,QAAQ,CAAC;EAChD,MAAM6B,eAAe,GAAGP,MAAM,CAACtB,QAAQ,CAAC;EACxC,MAAM8B,kBAAkB,GAAGP,SAAS,CAACvB,QAAQ,CAAC;EAE9C,OAAO;IACL,GAAG,IAAA+B,6BAAgB,EACjB;MACEL,cAAc;MACdC,iBAAiB;MACjBC,gBAAgB;MAChB7B,mBAAmB;MACnB8B,eAAe;MACfC,kBAAkB;MAClBE,uBAAuB,EAAEN,cAAc;MACvCO,0BAA0B,EAAEN,iBAAiB;MAC7CO,yBAAyB,EAAEN,gBAAgB;MAC3CO,4BAA4B,EAAEpC,mBAAmB;MACjDqC,wBAAwB,EAAEP,eAAe;MACzCQ,2BAA2B,EAAEP;IAC/B,CAAC,EACD,gMACF;EACF,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAb,sBAAA,GAAAA,sBAAA"}
|
|
@@ -10,7 +10,7 @@ var _findAll = require("../helpers/findAll");
|
|
|
10
10
|
var _accessibilityValue = require("../helpers/matchers/accessibilityValue");
|
|
11
11
|
var _makeQueries = require("./makeQueries");
|
|
12
12
|
const queryAllByA11yValue = instance => function queryAllByA11yValueFn(value, queryOptions) {
|
|
13
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
13
|
+
return (0, _findAll.findAll)(instance, node => (0, _accessibilityValue.matchAccessibilityValue)(node, value), queryOptions);
|
|
14
14
|
};
|
|
15
15
|
const formatQueryParams = matcher => {
|
|
16
16
|
const params = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a11yValue.js","names":["_accessiblity","require","_deprecation","_findAll","_accessibilityValue","_makeQueries","queryAllByA11yValue","instance","queryAllByA11yValueFn","value","queryOptions","findAll","node","
|
|
1
|
+
{"version":3,"file":"a11yValue.js","names":["_accessiblity","require","_deprecation","_findAll","_accessibilityValue","_makeQueries","queryAllByA11yValue","instance","queryAllByA11yValueFn","value","queryOptions","findAll","node","matchAccessibilityValue","formatQueryParams","matcher","params","accessiblityValueKeys","forEach","valueKey","undefined","push","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByA11yValueQueries","getByA11yValue","getAllByA11yValue","queryByA11yValue","findByA11yValue","findAllByA11yValue","deprecateQueries","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue","exports"],"sources":["../../src/queries/a11yValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { accessiblityValueKeys } from '../helpers/accessiblity';\nimport { deprecateQueries } from '../helpers/deprecation';\nimport { findAll } from '../helpers/findAll';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\nconst queryAllByA11yValue = (\n instance: ReactTestInstance\n): QueryAllByQuery<AccessibilityValueMatcher, CommonQueryOptions> =>\n function queryAllByA11yValueFn(value, queryOptions) {\n return findAll(\n instance,\n (node) => matchAccessibilityValue(node, value),\n queryOptions\n );\n };\n\nconst formatQueryParams = (matcher: AccessibilityValueMatcher) => {\n const params: string[] = [];\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (matcher[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${matcher[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (matcher: AccessibilityValueMatcher) =>\n `Found multiple elements with ${formatQueryParams(matcher)}`;\n\nconst getMissingError = (matcher: AccessibilityValueMatcher) =>\n `Unable to find an element with ${formatQueryParams(matcher)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByA11yValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByA11yValueQueries = {\n getByA11yValue: GetByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n getAllByA11yValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByA11yValue: QueryByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n queryAllByA11yValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByA11yValue: FindByQuery<AccessibilityValueMatcher, CommonQueryOptions>;\n findAllByA11yValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n\n getByAccessibilityValue: GetByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n getAllByAccessibilityValue: GetAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryByAccessibilityValue: QueryByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n queryAllByAccessibilityValue: QueryAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findByAccessibilityValue: FindByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n findAllByAccessibilityValue: FindAllByQuery<\n AccessibilityValueMatcher,\n CommonQueryOptions\n >;\n};\n\nexport const bindByA11yValueQueries = (\n instance: ReactTestInstance\n): ByA11yValueQueries => {\n const getByA11yValue = getBy(instance);\n const getAllByA11yValue = getAllBy(instance);\n const queryByA11yValue = queryBy(instance);\n const queryAllByA11yValue = queryAllBy(instance);\n const findByA11yValue = findBy(instance);\n const findAllByA11yValue = findAllBy(instance);\n\n return {\n ...deprecateQueries(\n {\n getByA11yValue,\n getAllByA11yValue,\n queryByA11yValue,\n queryAllByA11yValue,\n findByA11yValue,\n findAllByA11yValue,\n getByAccessibilityValue: getByA11yValue,\n getAllByAccessibilityValue: getAllByA11yValue,\n queryByAccessibilityValue: queryByA11yValue,\n queryAllByAccessibilityValue: queryAllByA11yValue,\n findByAccessibilityValue: findByA11yValue,\n findAllByAccessibilityValue: findAllByA11yValue,\n },\n 'Use expect(...).toHaveAccessibilityValue(...) matcher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GAAGR,KAAK,CAAClB,QAAQ,CAAC;EACtC,MAAM2B,iBAAiB,GAAGR,QAAQ,CAACnB,QAAQ,CAAC;EAC5C,MAAM4B,gBAAgB,GAAGR,OAAO,CAACpB,QAAQ,CAAC;EAC1C,MAAMD,mBAAmB,GAAGsB,UAAU,CAACrB,QAAQ,CAAC;EAChD,MAAM6B,eAAe,GAAGP,MAAM,CAACtB,QAAQ,CAAC;EACxC,MAAM8B,kBAAkB,GAAGP,SAAS,CAACvB,QAAQ,CAAC;EAE9C,OAAO;IACL,GAAG,IAAA+B,6BAAgB,EACjB;MACEL,cAAc;MACdC,iBAAiB;MACjBC,gBAAgB;MAChB7B,mBAAmB;MACnB8B,eAAe;MACfC,kBAAkB;MAClBE,uBAAuB,EAAEN,cAAc;MACvCO,0BAA0B,EAAEN,iBAAiB;MAC7CO,yBAAyB,EAAEN,gBAAgB;MAC3CO,4BAA4B,EAAEpC,mBAAmB;MACjDqC,wBAAwB,EAAEP,eAAe;MACzCQ,2BAA2B,EAAEP;IAC/B,CAAC,EACD,+JACF;EACF,CAAC;AACH,CAAC;AAACQ,OAAA,CAAAb,sBAAA,GAAAA,sBAAA"}
|
|
@@ -4,21 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.bindByDisplayValueQueries = void 0;
|
|
7
|
-
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
8
7
|
var _findAll = require("../helpers/findAll");
|
|
9
|
-
var _matches = require("../matches");
|
|
10
8
|
var _hostComponentNames = require("../helpers/host-component-names");
|
|
9
|
+
var _matches = require("../matches");
|
|
11
10
|
var _makeQueries = require("./makeQueries");
|
|
12
|
-
const
|
|
11
|
+
const matchDisplayValue = (node, value, options = {}) => {
|
|
13
12
|
const {
|
|
14
13
|
exact,
|
|
15
14
|
normalizer
|
|
16
15
|
} = options;
|
|
17
|
-
const nodeValue = node.props.value
|
|
18
|
-
return (0,
|
|
16
|
+
const nodeValue = node.props.value ?? node.props.defaultValue;
|
|
17
|
+
return (0, _matches.matches)(value, nodeValue, normalizer, exact);
|
|
19
18
|
};
|
|
20
19
|
const queryAllByDisplayValue = instance => function queryAllByDisplayValueFn(displayValue, queryOptions) {
|
|
21
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
20
|
+
return (0, _findAll.findAll)(instance, node => (0, _hostComponentNames.isHostTextInput)(node) && matchDisplayValue(node, displayValue, queryOptions), queryOptions);
|
|
22
21
|
};
|
|
23
22
|
const getMultipleError = displayValue => `Found multiple elements with display value: ${String(displayValue)} `;
|
|
24
23
|
const getMissingError = displayValue => `Unable to find an element with displayValue: ${String(displayValue)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"displayValue.js","names":["
|
|
1
|
+
{"version":3,"file":"displayValue.js","names":["_findAll","require","_hostComponentNames","_matches","_makeQueries","matchDisplayValue","node","value","options","exact","normalizer","nodeValue","props","defaultValue","matches","queryAllByDisplayValue","instance","queryAllByDisplayValueFn","displayValue","queryOptions","findAll","isHostTextInput","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByDisplayValueQueries","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","findByDisplayValue","findAllByDisplayValue","exports"],"sources":["../../src/queries/displayValue.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchDisplayValue = (\n node: ReactTestInstance,\n value: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n const nodeValue = node.props.value ?? node.props.defaultValue;\n\n return matches(value, nodeValue, normalizer, exact);\n};\n\nconst queryAllByDisplayValue = (\n instance: ReactTestInstance\n): QueryAllByQuery<TextMatch, ByDisplayValueOptions> =>\n function queryAllByDisplayValueFn(displayValue, queryOptions) {\n return findAll(\n instance,\n (node) =>\n isHostTextInput(node) &&\n matchDisplayValue(node, displayValue, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (displayValue: TextMatch) =>\n `Found multiple elements with display value: ${String(displayValue)} `;\nconst getMissingError = (displayValue: TextMatch) =>\n `Unable to find an element with displayValue: ${String(displayValue)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByDisplayValue,\n getMissingError,\n getMultipleError\n);\n\nexport type ByDisplayValueQueries = {\n getByDisplayValue: GetByQuery<TextMatch, ByDisplayValueOptions>;\n getAllByDisplayValue: GetAllByQuery<TextMatch, ByDisplayValueOptions>;\n queryByDisplayValue: QueryByQuery<TextMatch, ByDisplayValueOptions>;\n queryAllByDisplayValue: QueryAllByQuery<TextMatch, ByDisplayValueOptions>;\n findByDisplayValue: FindByQuery<TextMatch, ByDisplayValueOptions>;\n findAllByDisplayValue: FindAllByQuery<TextMatch, ByDisplayValueOptions>;\n};\n\nexport const bindByDisplayValueQueries = (\n instance: ReactTestInstance\n): ByDisplayValueQueries => ({\n getByDisplayValue: getBy(instance),\n getAllByDisplayValue: getAllBy(instance),\n queryByDisplayValue: queryBy(instance),\n queryAllByDisplayValue: queryAllBy(instance),\n findByDisplayValue: findBy(instance),\n findAllByDisplayValue: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,mBAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAaA,MAAMI,iBAAiB,GAAGA,CACxBC,IAAuB,EACvBC,KAAgB,EAChBC,OAAyB,GAA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,CAAAN,yBAAA,GAAAA,yBAAA"}
|
|
@@ -15,7 +15,7 @@ const getNodeByHintText = (node, text, options = {}) => {
|
|
|
15
15
|
return (0, _matches.matches)(text, node.props.accessibilityHint, normalizer, exact);
|
|
16
16
|
};
|
|
17
17
|
const queryAllByHintText = instance => function queryAllByA11yHintFn(hint, queryOptions) {
|
|
18
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
18
|
+
return (0, _findAll.findAll)(instance, node => getNodeByHintText(node, hint, queryOptions), queryOptions);
|
|
19
19
|
};
|
|
20
20
|
const getMultipleError = hint => `Found multiple elements with accessibilityHint: ${String(hint)} `;
|
|
21
21
|
const getMissingError = hint => `Unable to find an element with accessibilityHint: ${String(hint)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hintText.js","names":["_findAll","require","_matches","_makeQueries","getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","
|
|
1
|
+
{"version":3,"file":"hintText.js","names":["_findAll","require","_matches","_makeQueries","getNodeByHintText","node","text","options","exact","normalizer","matches","props","accessibilityHint","queryAllByHintText","instance","queryAllByA11yHintFn","hint","queryOptions","findAll","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByHintTextQueries","getByHintText","getAllByHintText","queryByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","exports"],"sources":["../../src/queries/hintText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByHintTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst getNodeByHintText = (\n node: ReactTestInstance,\n text: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(text, node.props.accessibilityHint, normalizer, exact);\n};\n\nconst queryAllByHintText = (\n instance: ReactTestInstance\n): QueryAllByQuery<TextMatch, ByHintTextOptions> =>\n function queryAllByA11yHintFn(hint, queryOptions) {\n return findAll(\n instance,\n (node) => getNodeByHintText(node, hint, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (hint: TextMatch) =>\n `Found multiple elements with accessibilityHint: ${String(hint)} `;\nconst getMissingError = (hint: TextMatch) =>\n `Unable to find an element with accessibilityHint: ${String(hint)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByHintText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByHintTextQueries = {\n getByHintText: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByHintText: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByHintText: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByHintText: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByHintText: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByHintText: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // a11yHint aliases\n getByA11yHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByA11yHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByA11yHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByA11yHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByA11yHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByA11yHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n\n // accessibilityHint aliases\n getByAccessibilityHint: GetByQuery<TextMatch, ByHintTextOptions>;\n getAllByAccessibilityHint: GetAllByQuery<TextMatch, ByHintTextOptions>;\n queryByAccessibilityHint: QueryByQuery<TextMatch, ByHintTextOptions>;\n queryAllByAccessibilityHint: QueryAllByQuery<TextMatch, ByHintTextOptions>;\n findByAccessibilityHint: FindByQuery<TextMatch, ByHintTextOptions>;\n findAllByAccessibilityHint: FindAllByQuery<TextMatch, ByHintTextOptions>;\n};\n\nexport const bindByHintTextQueries = (\n instance: ReactTestInstance\n): ByHintTextQueries => {\n const getByHintText = getBy(instance);\n const getAllByHintText = getAllBy(instance);\n const queryByHintText = queryBy(instance);\n const queryAllByHintText = queryAllBy(instance);\n const findByHintText = findBy(instance);\n const findAllByHintText = findAllBy(instance);\n\n return {\n getByHintText,\n getAllByHintText,\n queryByHintText,\n queryAllByHintText,\n findByHintText,\n findAllByHintText,\n\n // a11yHint aliases\n getByA11yHint: getByHintText,\n getAllByA11yHint: getAllByHintText,\n queryByA11yHint: queryByHintText,\n queryAllByA11yHint: queryAllByHintText,\n findByA11yHint: findByHintText,\n findAllByA11yHint: findAllByHintText,\n\n // accessibilityHint aliases\n getByAccessibilityHint: getByHintText,\n getAllByAccessibilityHint: getAllByHintText,\n queryByAccessibilityHint: queryByHintText,\n queryAllByAccessibilityHint: queryAllByHintText,\n findByAccessibilityHint: findByHintText,\n findAllByAccessibilityHint: findAllByHintText,\n };\n};\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAaA,MAAMG,iBAAiB,GAAGA,CACxBC,IAAuB,EACvBC,IAAe,EACfC,OAAyB,GAAG,CAAC,CAAC,KAC3B;EACH,MAAM;IAAEC,KAAK;IAAEC;EAAW,CAAC,GAAGF,OAAO;EACrC,OAAO,IAAAG,gBAAO,EAACJ,IAAI,EAAED,IAAI,CAACM,KAAK,CAACC,iBAAiB,EAAEH,UAAU,EAAED,KAAK,CAAC;AACvE,CAA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AAsB,EAAEX,aAAa;IACrCY,yBAAyB,EAAEX,gBAAgB;IAC3CY,wBAAwB,EAAEX,eAAe;IACzCY,2BAA2B,EAAE/B,kBAAkB;IAC/CgC,uBAAuB,EAAEZ,cAAc;IACvCa,0BAA0B,EAAEZ;EAC9B,CAAC;AACH,CAAC;AAACa,OAAA,CAAAlB,qBAAA,GAAAA,qBAAA"}
|
|
@@ -9,7 +9,7 @@ var _matchLabelText = require("../helpers/matchers/matchLabelText");
|
|
|
9
9
|
var _makeQueries = require("./makeQueries");
|
|
10
10
|
function queryAllByLabelText(instance) {
|
|
11
11
|
return (text, queryOptions) => {
|
|
12
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
12
|
+
return (0, _findAll.findAll)(instance, node => (0, _matchLabelText.matchLabelText)(instance, node, text, queryOptions), queryOptions);
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
const getMultipleError = labelText => `Found multiple elements with accessibilityLabel: ${String(labelText)} `;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labelText.js","names":["_findAll","require","_matchLabelText","_makeQueries","queryAllByLabelText","instance","text","queryOptions","findAll","node","
|
|
1
|
+
{"version":3,"file":"labelText.js","names":["_findAll","require","_matchLabelText","_makeQueries","queryAllByLabelText","instance","text","queryOptions","findAll","node","matchLabelText","getMultipleError","labelText","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByLabelTextQueries","getByLabelText","getAllByLabelText","queryByLabelText","findByLabelText","findAllByLabelText","exports"],"sources":["../../src/queries/labelText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { TextMatch, TextMatchOptions } from '../matches';\nimport { matchLabelText } from '../helpers/matchers/matchLabelText';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByLabelTextOptions = CommonQueryOptions & TextMatchOptions;\n\nfunction queryAllByLabelText(instance: ReactTestInstance) {\n return (text: TextMatch, queryOptions?: ByLabelTextOptions) => {\n return findAll(\n instance,\n (node) => matchLabelText(instance, node, text, queryOptions),\n queryOptions\n );\n };\n}\n\nconst getMultipleError = (labelText: TextMatch) =>\n `Found multiple elements with accessibilityLabel: ${String(labelText)} `;\nconst getMissingError = (labelText: TextMatch) =>\n `Unable to find an element with accessibilityLabel: ${String(labelText)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByLabelText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByLabelTextQueries = {\n getByLabelText: GetByQuery<TextMatch, ByLabelTextOptions>;\n getAllByLabelText: GetAllByQuery<TextMatch, ByLabelTextOptions>;\n queryByLabelText: QueryByQuery<TextMatch, ByLabelTextOptions>;\n queryAllByLabelText: QueryAllByQuery<TextMatch, ByLabelTextOptions>;\n findByLabelText: FindByQuery<TextMatch, ByLabelTextOptions>;\n findAllByLabelText: FindAllByQuery<TextMatch, ByLabelTextOptions>;\n};\n\nexport const bindByLabelTextQueries = (\n instance: ReactTestInstance\n): ByLabelTextQueries => ({\n getByLabelText: getBy(instance),\n getAllByLabelText: getAllBy(instance),\n queryByLabelText: queryBy(instance),\n queryAllByLabelText: queryAllBy(instance),\n findByLabelText: findBy(instance),\n findAllByLabelText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AAEA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAaA,SAASG,mBAAmBA,CAACC,QAA2B,EAAE;EACxD,OAAO,CAACC,IAAe,EAAEC,YAAiC,KAAK;IAC7D,OAAO,IAAAC,gBAAO,EACZH,QAAQ,EACPI,IAAI,IAAK,IAAAC,8BAAc,EAACL,QAAQ,EAAEI,IAAI,EAAEH,IAAI,EAAEC,YAAY,CAAC,EAC5DA,YACF,CAAC;EACH,CAAC;AACH;AAEA,MAAMI,gBAAgB,GAAIC,SAAoB,IAC3C,oDAAmDC,MAAM,CAACD,SAAS,CAAE,GAAE;AAC1E,MAAME,eAAe,GAAIF,SAAoB,IAC1C,sDAAqDC,MAAM,CAACD,SAAS,CAAE,EAAC;AAE3E,MAAM;EAAEG,KAAK;EAAEC,QAAQ;EAAEC,OAAO;EAAEC,UAAU;EAAEC,MAAM;EAAEC;AAAU,CAAC,GAAG,IAAAC,wBAAW,EAC7EjB,mBAAmB,EACnBU,eAAe,EACfH,gBACF,CAAC;AAWM,MAAMW,sBAAsB,GACjCjB,QAA2B,KACH;EACxBkB,cAAc,EAAER,KAAK,CAACV,QAAQ,CAAC;EAC/BmB,iBAAiB,EAAER,QAAQ,CAACX,QAAQ,CAAC;EACrCoB,gBAAgB,EAAER,OAAO,CAACZ,QAAQ,CAAC;EACnCD,mBAAmB,EAAEc,UAAU,CAACb,QAAQ,CAAC;EACzCqB,eAAe,EAAEP,MAAM,CAACd,QAAQ,CAAC;EACjCsB,kBAAkB,EAAEP,SAAS,CAACf,QAAQ;AACxC,CAAC,CAAC;AAACuB,OAAA,CAAAN,sBAAA,GAAAA,sBAAA"}
|
|
@@ -6,18 +6,17 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.bindByPlaceholderTextQueries = void 0;
|
|
7
7
|
var _findAll = require("../helpers/findAll");
|
|
8
8
|
var _matches = require("../matches");
|
|
9
|
-
var _filterNodeByType = require("../helpers/filterNodeByType");
|
|
10
9
|
var _hostComponentNames = require("../helpers/host-component-names");
|
|
11
10
|
var _makeQueries = require("./makeQueries");
|
|
12
|
-
const
|
|
11
|
+
const matchPlaceholderText = (node, placeholder, options = {}) => {
|
|
13
12
|
const {
|
|
14
13
|
exact,
|
|
15
14
|
normalizer
|
|
16
15
|
} = options;
|
|
17
|
-
return (0,
|
|
16
|
+
return (0, _matches.matches)(placeholder, node.props.placeholder, normalizer, exact);
|
|
18
17
|
};
|
|
19
18
|
const queryAllByPlaceholderText = instance => function queryAllByPlaceholderFn(placeholder, queryOptions) {
|
|
20
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
19
|
+
return (0, _findAll.findAll)(instance, node => (0, _hostComponentNames.isHostTextInput)(node) && matchPlaceholderText(node, placeholder, queryOptions), queryOptions);
|
|
21
20
|
};
|
|
22
21
|
const getMultipleError = placeholder => `Found multiple elements with placeholder: ${String(placeholder)} `;
|
|
23
22
|
const getMissingError = placeholder => `Unable to find an element with placeholder: ${String(placeholder)}`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"placeholderText.js","names":["_findAll","require","_matches","
|
|
1
|
+
{"version":3,"file":"placeholderText.js","names":["_findAll","require","_matches","_hostComponentNames","_makeQueries","matchPlaceholderText","node","placeholder","options","exact","normalizer","matches","props","queryAllByPlaceholderText","instance","queryAllByPlaceholderFn","queryOptions","findAll","isHostTextInput","getMultipleError","String","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByPlaceholderTextQueries","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","exports"],"sources":["../../src/queries/placeholderText.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { findAll } from '../helpers/findAll';\nimport { matches, TextMatch, TextMatchOptions } from '../matches';\nimport { isHostTextInput } from '../helpers/host-component-names';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport type { CommonQueryOptions } from './options';\n\ntype ByPlaceholderTextOptions = CommonQueryOptions & TextMatchOptions;\n\nconst matchPlaceholderText = (\n node: ReactTestInstance,\n placeholder: TextMatch,\n options: TextMatchOptions = {}\n) => {\n const { exact, normalizer } = options;\n return matches(placeholder, node.props.placeholder, normalizer, exact);\n};\n\nconst queryAllByPlaceholderText = (\n instance: ReactTestInstance\n): QueryAllByQuery<TextMatch, ByPlaceholderTextOptions> =>\n function queryAllByPlaceholderFn(placeholder, queryOptions) {\n return findAll(\n instance,\n (node) =>\n isHostTextInput(node) &&\n matchPlaceholderText(node, placeholder, queryOptions),\n queryOptions\n );\n };\n\nconst getMultipleError = (placeholder: TextMatch) =>\n `Found multiple elements with placeholder: ${String(placeholder)} `;\nconst getMissingError = (placeholder: TextMatch) =>\n `Unable to find an element with placeholder: ${String(placeholder)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByPlaceholderText,\n getMissingError,\n getMultipleError\n);\n\nexport type ByPlaceholderTextQueries = {\n getByPlaceholderText: GetByQuery<TextMatch, ByPlaceholderTextOptions>;\n getAllByPlaceholderText: GetAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryByPlaceholderText: QueryByQuery<TextMatch, ByPlaceholderTextOptions>;\n queryAllByPlaceholderText: QueryAllByQuery<\n TextMatch,\n ByPlaceholderTextOptions\n >;\n findByPlaceholderText: FindByQuery<TextMatch, ByPlaceholderTextOptions>;\n findAllByPlaceholderText: FindAllByQuery<TextMatch, ByPlaceholderTextOptions>;\n};\n\nexport const bindByPlaceholderTextQueries = (\n instance: ReactTestInstance\n): ByPlaceholderTextQueries => ({\n getByPlaceholderText: getBy(instance),\n getAllByPlaceholderText: getAllBy(instance),\n queryByPlaceholderText: queryBy(instance),\n queryAllByPlaceholderText: queryAllBy(instance),\n findByPlaceholderText: findBy(instance),\n findAllByPlaceholderText: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AAaA,MAAMI,oBAAoB,GAAGA,CAC3BC,IAAuB,EACvBC,WAAsB,EACtBC,OAAyB,GAAG,CAAC,CAAC,KA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essibilityValueIfNeeded = (node, value) => {
|
|
|
28
28
|
const queryAllByRole = instance => function queryAllByRoleFn(role, options) {
|
|
29
29
|
return (0, _findAll.findAll)(instance, node =>
|
|
30
30
|
// run the cheapest checks first, and early exit to avoid unneeded computations
|
|
31
|
-
|
|
31
|
+
(0, _accessiblity.isAccessibilityElement)(node) && (0, _matchStringProp.matchStringProp)(node.props.accessibilityRole, role) && matchAccessibleStateIfNeeded(node, options) && matchAccessibilityValueIfNeeded(node, options?.value) && matchAccessibleNameIfNeeded(node, options?.name), options);
|
|
32
32
|
};
|
|
33
33
|
const formatQueryParams = (role, options = {}) => {
|
|
34
34
|
const params = [`role: "${String(role)}"`];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"role.js","names":["_accessiblity","require","_findAll","_accessibilityState","_accessibilityValue","_matchStringProp","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","findAll","
|
|
1
|
+
{"version":3,"file":"role.js","names":["_accessiblity","require","_findAll","_accessibilityState","_accessibilityValue","_matchStringProp","_within","_makeQueries","matchAccessibleNameIfNeeded","node","name","queryAllByText","queryAllByLabelText","getQueriesForElement","length","matchAccessibleStateIfNeeded","options","matchAccessibilityState","matchAccessibilityValueIfNeeded","value","matchAccessibilityValue","queryAllByRole","instance","queryAllByRoleFn","role","findAll","isAccessibilityElement","matchStringProp","props","accessibilityRole","formatQueryParams","params","String","push","accessibilityStateKeys","forEach","stateKey","undefined","accessiblityValueKeys","valueKey","join","getMultipleError","getMissingError","getBy","getAllBy","queryBy","queryAllBy","findBy","findAllBy","makeQueries","bindByRoleQueries","getByRole","getAllByRole","queryByRole","findByRole","findAllByRole","exports"],"sources":["../../src/queries/role.ts"],"sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport {\n accessibilityStateKeys,\n accessiblityValueKeys,\n isAccessibilityElement,\n} from '../helpers/accessiblity';\nimport { findAll } from '../helpers/findAll';\nimport {\n AccessibilityStateMatcher,\n matchAccessibilityState,\n} from '../helpers/matchers/accessibilityState';\nimport {\n AccessibilityValueMatcher,\n matchAccessibilityValue,\n} from '../helpers/matchers/accessibilityValue';\nimport { matchStringProp } from '../helpers/matchers/matchStringProp';\nimport type { TextMatch } from '../matches';\nimport { getQueriesForElement } from '../within';\nimport { makeQueries } from './makeQueries';\nimport type {\n FindAllByQuery,\n FindByQuery,\n GetAllByQuery,\n GetByQuery,\n QueryAllByQuery,\n QueryByQuery,\n} from './makeQueries';\nimport { CommonQueryOptions } from './options';\n\ntype ByRoleOptions = CommonQueryOptions &\n AccessibilityStateMatcher & {\n name?: TextMatch;\n value?: AccessibilityValueMatcher;\n };\n\nconst matchAccessibleNameIfNeeded = (\n node: ReactTestInstance,\n name?: TextMatch\n) => {\n if (name == null) return true;\n\n const { queryAllByText, queryAllByLabelText } = getQueriesForElement(node);\n return (\n queryAllByText(name).length > 0 || queryAllByLabelText(name).length > 0\n );\n};\n\nconst matchAccessibleStateIfNeeded = (\n node: ReactTestInstance,\n options?: ByRoleOptions\n) => {\n return options != null ? matchAccessibilityState(node, options) : true;\n};\n\nconst matchAccessibilityValueIfNeeded = (\n node: ReactTestInstance,\n value?: AccessibilityValueMatcher\n) => {\n return value != null ? matchAccessibilityValue(node, value) : true;\n};\n\nconst queryAllByRole = (\n instance: ReactTestInstance\n): QueryAllByQuery<TextMatch, ByRoleOptions> =>\n function queryAllByRoleFn(role, options) {\n return findAll(\n instance,\n (node) =>\n // run the cheapest checks first, and early exit to avoid unneeded computations\n isAccessibilityElement(node) &&\n matchStringProp(node.props.accessibilityRole, role) &&\n matchAccessibleStateIfNeeded(node, options) &&\n matchAccessibilityValueIfNeeded(node, options?.value) &&\n matchAccessibleNameIfNeeded(node, options?.name),\n options\n );\n };\n\nconst formatQueryParams = (role: TextMatch, options: ByRoleOptions = {}) => {\n const params = [`role: \"${String(role)}\"`];\n\n if (options.name) {\n params.push(`name: \"${String(options.name)}\"`);\n }\n\n accessibilityStateKeys.forEach((stateKey) => {\n if (options[stateKey] !== undefined) {\n params.push(`${stateKey} state: ${options[stateKey]}`);\n }\n });\n\n accessiblityValueKeys.forEach((valueKey) => {\n if (options?.value?.[valueKey] !== undefined) {\n params.push(`${valueKey} value: ${options?.value?.[valueKey]}`);\n }\n });\n\n return params.join(', ');\n};\n\nconst getMultipleError = (role: TextMatch, options?: ByRoleOptions) =>\n `Found multiple elements with ${formatQueryParams(role, options)}`;\n\nconst getMissingError = (role: TextMatch, options?: ByRoleOptions) =>\n `Unable to find an element with ${formatQueryParams(role, options)}`;\n\nconst { getBy, getAllBy, queryBy, queryAllBy, findBy, findAllBy } = makeQueries(\n queryAllByRole,\n getMissingError,\n getMultipleError\n);\n\nexport type ByRoleQueries = {\n getByRole: GetByQuery<TextMatch, ByRoleOptions>;\n getAllByRole: GetAllByQuery<TextMatch, ByRoleOptions>;\n queryByRole: QueryByQuery<TextMatch, ByRoleOptions>;\n queryAllByRole: QueryAllByQuery<TextMatch, ByRoleOptions>;\n findByRole: FindByQuery<TextMatch, ByRoleOptions>;\n findAllByRole: FindAllByQuery<TextMatch, ByRoleOptions>;\n};\n\nexport const bindByRoleQueries = (\n instance: ReactTestInstance\n): ByRoleQueries => ({\n getByRole: getBy(instance),\n getAllByRole: getAllBy(instance),\n queryByRole: queryBy(instance),\n queryAllByRole: queryAllBy(instance),\n findByRole: findBy(instance),\n findAllByRole: findAllBy(instance),\n});\n"],"mappings":";;;;;;AACA,IAAAA,aAAA,GAAAC,OAAA;AAKA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,mBAAA,GAAAF,OAAA;AAIA,IAAAG,mBAAA,GAAAH,OAAA;AAIA,IAAAI,gBAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAiB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AAER,QAAQ,CAACtB,QAAQ,CAAC;EAChC+B,WAAW,EAAER,OAAO,CAACvB,QAAQ,CAAC;EAC9BD,cAAc,EAAEyB,UAAU,CAACxB,QAAQ,CAAC;EACpCgC,UAAU,EAAEP,MAAM,CAACzB,QAAQ,CAAC;EAC5BiC,aAAa,EAAEP,SAAS,CAAC1B,QAAQ;AACnC,CAAC,CAAC;AAACkC,OAAA,CAAAN,iBAAA,GAAAA,iBAAA"}
|
package/build/queries/testId.js
CHANGED
|
@@ -7,15 +7,15 @@ exports.bindByTestIdQueries = void 0;
|
|
|
7
7
|
var _findAll = require("../helpers/findAll");
|
|
8
8
|
var _matches = require("../matches");
|
|
9
9
|
var _makeQueries = require("./makeQueries");
|
|
10
|
-
const
|
|
10
|
+
const matchTestId = (node, testId, options = {}) => {
|
|
11
11
|
const {
|
|
12
12
|
exact,
|
|
13
13
|
normalizer
|
|
14
14
|
} = options;
|
|
15
|
-
return (0, _matches.matches)(
|
|
15
|
+
return (0, _matches.matches)(testId, node.props.testID, normalizer, exact);
|
|
16
16
|
};
|
|
17
17
|
const queryAllByTestId = instance => function queryAllByTestIdFn(testId, queryOptions) {
|
|
18
|
-
return (0, _findAll.findAll)(instance, node =>
|
|
18
|
+
return (0, _findAll.findAll)(instance, node => matchTestId(node, testId, queryOptions), queryOptions);
|
|
19
19
|
};
|
|
20
20
|
const getMultipleError = testId => `Found multiple elements with testID: ${String(testId)}`;
|
|
21
21
|
const getMissingError = testId => `Unable to find an element with testID: ${String(testId)}`;
|