@testing-library/react-native 12.2.0 → 12.2.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/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/package.json +5 -4
- package/.DS_Store +0 -0
- package/.codecov.yml +0 -9
- package/.eslintcache +0 -1
- package/.eslintignore +0 -2
- package/.eslintrc +0 -19
- package/.flowconfig +0 -63
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -38
- package/.github/ISSUE_TEMPLATE/feature_request.md +0 -14
- package/.github/ISSUE_TEMPLATE/question.md +0 -9
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/actions/setup-deps/action.yml +0 -22
- package/.github/actions/setup-website-deps/action.yml +0 -22
- package/.github/dependabot.yml +0 -10
- package/.github/workflows/deploy-website.yml +0 -36
- package/.github/workflows/example-apps.yml +0 -25
- package/.github/workflows/main.yml +0 -103
- package/.gitignore +0 -11
- package/.prettierrc.js +0 -5
- package/CODE_OF_CONDUCT.md +0 -73
- package/CONTRIBUTING.md +0 -64
- package/babel.config.js +0 -22
- 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/README.md +0 -17
- package/examples/basic/.expo/devices.json +0 -3
- package/examples/basic/.expo/packager-info.json +0 -4
- package/examples/basic/.expo/settings.json +0 -8
- package/examples/basic/.expo-shared/assets.json +0 -4
- package/examples/basic/.gitignore +0 -14
- package/examples/basic/App.tsx +0 -20
- package/examples/basic/README.md +0 -11
- package/examples/basic/__tests__/App.test.tsx +0 -119
- package/examples/basic/app.json +0 -31
- package/examples/basic/assets/adaptive-icon.png +0 -0
- package/examples/basic/assets/favicon.png +0 -0
- package/examples/basic/assets/icon.png +0 -0
- package/examples/basic/assets/splash.png +0 -0
- package/examples/basic/babel.config.js +0 -6
- package/examples/basic/components/Home.tsx +0 -28
- package/examples/basic/components/LoginForm.tsx +0 -138
- package/examples/basic/jest-setup.ts +0 -7
- package/examples/basic/jest.config.js +0 -5
- package/examples/basic/package.json +0 -30
- package/examples/basic/tsconfig.json +0 -7
- package/examples/basic/yarn-error.log +0 -8083
- package/examples/basic/yarn.lock +0 -8878
- package/examples/react-navigation/README.md +0 -16
- package/examples/react-navigation/babel.config.js +0 -4
- package/examples/react-navigation/jest-setup.js +0 -11
- package/examples/react-navigation/jest.config.js +0 -10
- package/examples/react-navigation/package.json +0 -31
- package/examples/react-navigation/src/App.js +0 -21
- package/examples/react-navigation/src/DrawerNavigator.js +0 -15
- package/examples/react-navigation/src/DrawerNavigator.test.js +0 -42
- package/examples/react-navigation/src/NativeStackNavigator.js +0 -15
- package/examples/react-navigation/src/NativeStackNavigator.test.js +0 -34
- package/examples/react-navigation/src/StackNavigator.js +0 -15
- package/examples/react-navigation/src/StackNavigator.test.js +0 -34
- package/examples/react-navigation/src/TabNavigator.js +0 -15
- package/examples/react-navigation/src/TabNavigator.test.js +0 -21
- package/examples/react-navigation/src/screens/DetailsScreen.js +0 -43
- package/examples/react-navigation/src/screens/DetailsScreen.test.js +0 -27
- package/examples/react-navigation/src/screens/DrawerHomeScreen.js +0 -26
- package/examples/react-navigation/src/screens/HomeScreen.js +0 -48
- package/examples/react-navigation/src/screens/SettingsScreen.js +0 -20
- package/examples/react-navigation/src/test-utils.js +0 -12
- package/examples/react-navigation/yarn.lock +0 -5610
- package/examples/redux/App.js +0 -27
- package/examples/redux/README.md +0 -5
- package/examples/redux/actions/todoActions.js +0 -25
- package/examples/redux/babel.config.js +0 -6
- package/examples/redux/components/AddTodo.js +0 -73
- package/examples/redux/components/AddTodo.test.js +0 -27
- package/examples/redux/components/TodoElem.js +0 -25
- package/examples/redux/components/TodoList.js +0 -29
- package/examples/redux/components/TodoList.test.js +0 -34
- package/examples/redux/index.js +0 -8
- package/examples/redux/jest-setup.js +0 -2
- package/examples/redux/jest.config.js +0 -4
- package/examples/redux/package.json +0 -23
- package/examples/redux/reducers/index.js +0 -6
- package/examples/redux/reducers/todoReducer.js +0 -27
- package/examples/redux/store.js +0 -10
- package/examples/redux/test-utils.js +0 -11
- package/examples/redux/yarn-error.log +0 -8083
- package/examples/redux/yarn.lock +0 -8423
- package/experiments-app/.expo/README.md +0 -15
- package/experiments-app/.expo/devices.json +0 -3
- package/experiments-app/.expo/settings.json +0 -10
- package/experiments-app/.gitignore +0 -17
- package/experiments-app/.prettierrc.js +0 -5
- package/experiments-app/app.json +0 -30
- package/experiments-app/assets/adaptive-icon.png +0 -0
- package/experiments-app/assets/favicon.png +0 -0
- package/experiments-app/assets/icon.png +0 -0
- package/experiments-app/assets/splash.png +0 -0
- package/experiments-app/babel.config.js +0 -6
- package/experiments-app/index.js +0 -4
- package/experiments-app/package.json +0 -31
- package/experiments-app/src/App.tsx +0 -31
- package/experiments-app/src/MainScreen.tsx +0 -51
- package/experiments-app/src/experiments.ts +0 -17
- package/experiments-app/src/screens/TextInputEventPropagation.tsx +0 -54
- package/experiments-app/src/screens/TextInputEvents.tsx +0 -60
- package/experiments-app/src/utils/helpers.ts +0 -8
- package/experiments-app/tsconfig.json +0 -6
- package/experiments-app/yarn.lock +0 -6913
- package/flow-typed/npm/jest_v26.x.x.js +0 -1218
- package/flow-typed/npm/react-test-renderer_v16.x.x.js +0 -81
- package/jest-setup.ts +0 -10
- package/renovate.json +0 -19
- package/scripts/test_react_17 +0 -12
- package/src/.DS_Store +0 -0
- package/src/__tests__/.DS_Store +0 -0
- package/src/__tests__/__snapshots__/render-debug.test.tsx.snap +0 -548
- package/src/__tests__/__snapshots__/render.test.tsx.snap +0 -39
- package/src/__tests__/act.test.tsx +0 -56
- package/src/__tests__/auto-cleanup-skip.test.tsx +0 -39
- package/src/__tests__/auto-cleanup.test.tsx +0 -50
- package/src/__tests__/cleanup.test.tsx +0 -26
- package/src/__tests__/config.test.ts +0 -55
- package/src/__tests__/fireEvent-textInput.test.tsx +0 -154
- package/src/__tests__/fireEvent.test.tsx +0 -485
- package/src/__tests__/host-component-names.test.tsx +0 -109
- package/src/__tests__/host-text-nesting.test.tsx +0 -90
- package/src/__tests__/jest-native.test.tsx +0 -84
- package/src/__tests__/questionsBoard.test.tsx +0 -62
- package/src/__tests__/react-native-api.test.tsx +0 -126
- package/src/__tests__/render-debug.test.tsx +0 -207
- package/src/__tests__/render-stringValidation.test.tsx +0 -157
- package/src/__tests__/render.test.tsx +0 -256
- package/src/__tests__/renderHook.test.tsx +0 -114
- package/src/__tests__/screen.test.tsx +0 -66
- package/src/__tests__/timerUtils.ts +0 -7
- package/src/__tests__/timers.test.ts +0 -27
- package/src/__tests__/waitFor.test.tsx +0 -327
- package/src/__tests__/waitForElementToBeRemoved.test.tsx +0 -151
- package/src/__tests__/within.test.tsx +0 -96
- package/src/act.ts +0 -86
- package/src/cleanup.ts +0 -15
- package/src/config.ts +0 -72
- package/src/fireEvent.ts +0 -159
- package/src/flush-micro-tasks.ts +0 -30
- package/src/helpers/__tests__/accessiblity.test.tsx +0 -373
- package/src/helpers/__tests__/component-tree.test.tsx +0 -226
- package/src/helpers/__tests__/format-default.tsx +0 -114
- package/src/helpers/__tests__/getTextContent.test.tsx +0 -49
- package/src/helpers/__tests__/includeHiddenElements.test.tsx +0 -39
- package/src/helpers/__tests__/query-name.test.ts +0 -10
- package/src/helpers/__tests__/timers.test.ts +0 -8
- package/src/helpers/accessiblity.ts +0 -108
- package/src/helpers/component-tree.ts +0 -89
- package/src/helpers/debugDeep.ts +0 -27
- package/src/helpers/debugShallow.ts +0 -22
- package/src/helpers/deprecation.ts +0 -53
- package/src/helpers/errors.ts +0 -66
- package/src/helpers/filterNodeByType.ts +0 -7
- package/src/helpers/findAll.ts +0 -68
- package/src/helpers/format-default.ts +0 -72
- package/src/helpers/format.ts +0 -47
- package/src/helpers/getTextContent.ts +0 -20
- package/src/helpers/host-component-names.tsx +0 -75
- package/src/helpers/matchers/__tests__/matchArrayValue.test.ts +0 -34
- package/src/helpers/matchers/__tests__/matchObject.test.ts +0 -37
- package/src/helpers/matchers/__tests__/matchStringValue.test.ts +0 -15
- package/src/helpers/matchers/accessibilityState.ts +0 -48
- package/src/helpers/matchers/accessibilityValue.ts +0 -24
- package/src/helpers/matchers/matchArrayProp.ts +0 -21
- package/src/helpers/matchers/matchLabelText.ts +0 -51
- package/src/helpers/matchers/matchObjectProp.ts +0 -25
- package/src/helpers/matchers/matchStringProp.ts +0 -23
- package/src/helpers/matchers/matchTextContent.ts +0 -20
- package/src/helpers/pointer-events.ts +0 -27
- package/src/helpers/query-name.ts +0 -4
- package/src/helpers/stringValidation.ts +0 -36
- package/src/helpers/timers.ts +0 -98
- package/src/index.ts +0 -33
- package/src/matches.ts +0 -49
- package/src/pure.ts +0 -27
- package/src/queries/__tests__/a11yState.test.tsx +0 -439
- package/src/queries/__tests__/a11yValue.test.tsx +0 -309
- package/src/queries/__tests__/displayValue.test.tsx +0 -221
- package/src/queries/__tests__/hintText.test.tsx +0 -177
- package/src/queries/__tests__/labelText.test.tsx +0 -242
- package/src/queries/__tests__/makeQueries.test.tsx +0 -235
- package/src/queries/__tests__/placeholderText.test.tsx +0 -136
- package/src/queries/__tests__/role-value.test.tsx +0 -176
- package/src/queries/__tests__/role.test.tsx +0 -824
- package/src/queries/__tests__/testId.test.tsx +0 -200
- package/src/queries/__tests__/text.test.tsx +0 -556
- package/src/queries/a11yState.ts +0 -131
- package/src/queries/a11yValue.ts +0 -131
- package/src/queries/displayValue.ts +0 -78
- package/src/queries/hintText.ts +0 -112
- package/src/queries/labelText.ts +0 -59
- package/src/queries/makeQueries.ts +0 -255
- package/src/queries/options.ts +0 -14
- package/src/queries/placeholderText.ts +0 -79
- package/src/queries/role.ts +0 -132
- package/src/queries/testId.ts +0 -71
- package/src/queries/text.ts +0 -66
- package/src/queries/unsafeProps.ts +0 -76
- package/src/queries/unsafeType.ts +0 -73
- package/src/react-versions.ts +0 -11
- package/src/render-act.ts +0 -19
- package/src/render.tsx +0 -183
- package/src/renderHook.tsx +0 -56
- package/src/screen.ts +0 -123
- package/src/shallow.ts +0 -18
- package/src/test-utils/events.ts +0 -24
- package/src/test-utils/index.ts +0 -1
- package/src/user-event/event-builder/common.ts +0 -66
- package/src/user-event/event-builder/index.ts +0 -7
- package/src/user-event/event-builder/text-input.ts +0 -86
- package/src/user-event/index.ts +0 -17
- package/src/user-event/press/__tests__/longPress.real-timers.test.tsx +0 -117
- package/src/user-event/press/__tests__/longPress.test.tsx +0 -157
- package/src/user-event/press/__tests__/press.real-timers.test.tsx +0 -320
- package/src/user-event/press/__tests__/press.test.tsx +0 -457
- package/src/user-event/press/constants.ts +0 -7
- package/src/user-event/press/index.ts +0 -1
- package/src/user-event/press/press.ts +0 -169
- package/src/user-event/setup/index.ts +0 -2
- package/src/user-event/setup/setup.ts +0 -127
- package/src/user-event/type/__tests__/__snapshots__/type-managed.test.tsx.snap +0 -339
- package/src/user-event/type/__tests__/__snapshots__/type.test.tsx.snap +0 -668
- package/src/user-event/type/__tests__/parseKeys.test.ts +0 -23
- package/src/user-event/type/__tests__/type-managed.test.tsx +0 -121
- package/src/user-event/type/__tests__/type.test.tsx +0 -336
- package/src/user-event/type/index.ts +0 -1
- package/src/user-event/type/parseKeys.ts +0 -41
- package/src/user-event/type/type.ts +0 -135
- package/src/user-event/utils/__tests__/dispatch-event.test.tsx +0 -41
- package/src/user-event/utils/__tests__/wait.test.ts +0 -63
- package/src/user-event/utils/content-size.ts +0 -25
- package/src/user-event/utils/dispatch-event.ts +0 -38
- package/src/user-event/utils/index.ts +0 -5
- package/src/user-event/utils/text-range.ts +0 -11
- package/src/user-event/utils/wait.ts +0 -15
- package/src/user-event/utils/warn-about-real-timers.ts +0 -13
- package/src/waitFor.ts +0 -228
- package/src/waitForElementToBeRemoved.ts +0 -42
- package/src/within.ts +0 -30
- package/tsconfig.json +0 -17
- package/tsconfig.release.json +0 -8
- 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/website/.gitignore +0 -20
- package/website/README.md +0 -33
- package/website/docker/.dockerignore +0 -3
- package/website/docker/Dockerfile +0 -9
- package/website/docker/docker-compose.yml +0 -11
- package/website/docs/API.md +0 -940
- package/website/docs/EslintPLluginTestingLibrary.md +0 -28
- package/website/docs/FAQ.md +0 -44
- package/website/docs/GettingStarted.md +0 -100
- package/website/docs/HowShouldIQuery.md +0 -21
- package/website/docs/MigrationV11.md +0 -64
- package/website/docs/MigrationV12.md +0 -67
- package/website/docs/MigrationV2.md +0 -126
- package/website/docs/MigrationV7.md +0 -119
- package/website/docs/MigrationV9.md +0 -67
- package/website/docs/Queries.md +0 -567
- package/website/docs/ReactNavigation.md +0 -371
- package/website/docs/ReduxIntegration.md +0 -137
- package/website/docs/TestingEnvironment.md +0 -154
- package/website/docs/Troubleshooting.md +0 -44
- package/website/docs/UnderstandingAct.md +0 -227
- package/website/docs/UserEvent.md +0 -143
- package/website/docusaurus.config.js +0 -114
- package/website/package.json +0 -31
- package/website/sidebars.js +0 -20
- package/website/src/components/Feature.js +0 -31
- package/website/src/css/custom.css +0 -13
- package/website/src/css/index.module.css +0 -77
- package/website/src/pages/index.js +0 -82
- package/website/static/.nojekyll +0 -0
- package/website/static/css/custom.css +0 -28
- package/website/static/img/hit.png +0 -0
- package/website/static/img/locomotive.png +0 -0
- package/website/static/img/owl.png +0 -0
- package/website/static/img/tools.png +0 -0
- package/website/yarn.lock +0 -7669
- package/yarn-error.log +0 -10613
- package/yarn.lock +0 -7765
|
@@ -1,824 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
TouchableOpacity,
|
|
4
|
-
TouchableWithoutFeedback,
|
|
5
|
-
Text,
|
|
6
|
-
View,
|
|
7
|
-
Pressable,
|
|
8
|
-
Button as RNButton,
|
|
9
|
-
} from 'react-native';
|
|
10
|
-
import { render } from '../..';
|
|
11
|
-
|
|
12
|
-
const TEXT_LABEL = 'cool text';
|
|
13
|
-
|
|
14
|
-
// Little hack to make all the methods happy with type
|
|
15
|
-
const NO_MATCHES_TEXT: any = 'not-existent-element';
|
|
16
|
-
|
|
17
|
-
const getMultipleInstancesFoundMessage = (value: string) => {
|
|
18
|
-
return `Found multiple elements with role: "${value}"`;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const getNoInstancesFoundMessage = (value: string) => {
|
|
22
|
-
return `Unable to find an element with role: "${value}"`;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const Typography = ({ children, ...rest }: any) => {
|
|
26
|
-
return <Text {...rest}>{children}</Text>;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const Button = ({ children }: { children: React.ReactNode }) => (
|
|
30
|
-
<TouchableOpacity accessibilityRole="button">
|
|
31
|
-
<Typography accessibilityRole="link">{children}</Typography>
|
|
32
|
-
</TouchableOpacity>
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const Section = () => (
|
|
36
|
-
<>
|
|
37
|
-
<Typography accessibilityRole="link">Title</Typography>
|
|
38
|
-
<Button>{TEXT_LABEL}</Button>
|
|
39
|
-
</>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
test('getByRole, queryByRole, findByRole', async () => {
|
|
43
|
-
const { getByRole, queryByRole, findByRole } = render(<Section />);
|
|
44
|
-
|
|
45
|
-
expect(getByRole('button').props.accessibilityRole).toEqual('button');
|
|
46
|
-
const button = queryByRole(/button/g);
|
|
47
|
-
expect(button?.props.accessibilityRole).toEqual('button');
|
|
48
|
-
|
|
49
|
-
expect(() => getByRole(NO_MATCHES_TEXT)).toThrow(
|
|
50
|
-
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
expect(queryByRole(NO_MATCHES_TEXT)).toBeNull();
|
|
54
|
-
|
|
55
|
-
expect(() => getByRole('link')).toThrow(
|
|
56
|
-
getMultipleInstancesFoundMessage('link')
|
|
57
|
-
);
|
|
58
|
-
expect(() => queryByRole('link')).toThrow(
|
|
59
|
-
getMultipleInstancesFoundMessage('link')
|
|
60
|
-
);
|
|
61
|
-
|
|
62
|
-
const asyncButton = await findByRole('button');
|
|
63
|
-
expect(asyncButton.props.accessibilityRole).toEqual('button');
|
|
64
|
-
await expect(findByRole(NO_MATCHES_TEXT)).rejects.toThrow(
|
|
65
|
-
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
|
|
66
|
-
);
|
|
67
|
-
await expect(findByRole('link')).rejects.toThrow(
|
|
68
|
-
getMultipleInstancesFoundMessage('link')
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('getAllByRole, queryAllByRole, findAllByRole', async () => {
|
|
73
|
-
const { getAllByRole, queryAllByRole, findAllByRole } = render(<Section />);
|
|
74
|
-
|
|
75
|
-
expect(getAllByRole('link')).toHaveLength(2);
|
|
76
|
-
expect(queryAllByRole(/ink/g)).toHaveLength(2);
|
|
77
|
-
|
|
78
|
-
expect(() => getAllByRole(NO_MATCHES_TEXT)).toThrow(
|
|
79
|
-
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
|
|
80
|
-
);
|
|
81
|
-
expect(queryAllByRole(NO_MATCHES_TEXT)).toEqual([]);
|
|
82
|
-
|
|
83
|
-
await expect(findAllByRole('link')).resolves.toHaveLength(2);
|
|
84
|
-
await expect(findAllByRole(NO_MATCHES_TEXT)).rejects.toThrow(
|
|
85
|
-
getNoInstancesFoundMessage(NO_MATCHES_TEXT)
|
|
86
|
-
);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
describe('supports name option', () => {
|
|
90
|
-
test('returns an element that has the corresponding role and a children with the name', () => {
|
|
91
|
-
const { getByRole } = render(
|
|
92
|
-
<TouchableOpacity accessibilityRole="button" testID="target-button">
|
|
93
|
-
<Text>Save</Text>
|
|
94
|
-
</TouchableOpacity>
|
|
95
|
-
);
|
|
96
|
-
|
|
97
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
98
|
-
expect(getByRole('button', { name: 'Save' }).props.testID).toBe(
|
|
99
|
-
'target-button'
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
test('returns an element that has the corresponding role when several children include the name', () => {
|
|
104
|
-
const { getByRole } = render(
|
|
105
|
-
<TouchableOpacity accessibilityRole="button" testID="target-button">
|
|
106
|
-
<Text>Save</Text>
|
|
107
|
-
<Text>Save</Text>
|
|
108
|
-
</TouchableOpacity>
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
112
|
-
expect(getByRole('button', { name: 'Save' }).props.testID).toBe(
|
|
113
|
-
'target-button'
|
|
114
|
-
);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
test('returns an element that has the corresponding role and a children with a matching accessibilityLabel', () => {
|
|
118
|
-
const { getByRole } = render(
|
|
119
|
-
<TouchableOpacity accessibilityRole="button" testID="target-button">
|
|
120
|
-
<Text accessibilityLabel="Save" />
|
|
121
|
-
</TouchableOpacity>
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
125
|
-
expect(getByRole('button', { name: 'Save' }).props.testID).toBe(
|
|
126
|
-
'target-button'
|
|
127
|
-
);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
test('returns an element that has the corresponding role and a matching accessibilityLabel', () => {
|
|
131
|
-
const { getByRole } = render(
|
|
132
|
-
<TouchableOpacity
|
|
133
|
-
accessibilityRole="button"
|
|
134
|
-
testID="target-button"
|
|
135
|
-
accessibilityLabel="Save"
|
|
136
|
-
></TouchableOpacity>
|
|
137
|
-
);
|
|
138
|
-
|
|
139
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
140
|
-
expect(getByRole('button', { name: 'Save' }).props.testID).toBe(
|
|
141
|
-
'target-button'
|
|
142
|
-
);
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
test('returns an element when the direct child is text', () => {
|
|
146
|
-
const { getByRole, getByTestId } = render(
|
|
147
|
-
<Text accessibilityRole="header" testID="target-header">
|
|
148
|
-
About
|
|
149
|
-
</Text>
|
|
150
|
-
);
|
|
151
|
-
|
|
152
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
153
|
-
expect(getByRole('header', { name: 'About' })).toBe(
|
|
154
|
-
getByTestId('target-header')
|
|
155
|
-
);
|
|
156
|
-
expect(getByRole('header', { name: 'About' }).props.testID).toBe(
|
|
157
|
-
'target-header'
|
|
158
|
-
);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
test('returns an element with nested Text as children', () => {
|
|
162
|
-
const { getByRole, getByTestId } = render(
|
|
163
|
-
<Text accessibilityRole="header" testID="parent">
|
|
164
|
-
<Text testID="child">About</Text>
|
|
165
|
-
</Text>
|
|
166
|
-
);
|
|
167
|
-
|
|
168
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
169
|
-
expect(getByRole('header', { name: 'About' })).toBe(getByTestId('parent'));
|
|
170
|
-
expect(getByRole('header', { name: 'About' }).props.testID).toBe('parent');
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
test('returns a header with an accessibilityLabel', () => {
|
|
174
|
-
const { getByRole, getByTestId } = render(
|
|
175
|
-
<Text
|
|
176
|
-
accessibilityRole="header"
|
|
177
|
-
testID="target-header"
|
|
178
|
-
accessibilityLabel="About"
|
|
179
|
-
/>
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
// assert on the testId to be sure that the returned element is the one with the accessibilityRole
|
|
183
|
-
expect(getByRole('header', { name: 'About' })).toBe(
|
|
184
|
-
getByTestId('target-header')
|
|
185
|
-
);
|
|
186
|
-
expect(getByRole('header', { name: 'About' }).props.testID).toBe(
|
|
187
|
-
'target-header'
|
|
188
|
-
);
|
|
189
|
-
});
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
describe('supports accessibility states', () => {
|
|
193
|
-
describe('disabled', () => {
|
|
194
|
-
test('returns a disabled element when required', () => {
|
|
195
|
-
const { getByRole, queryByRole } = render(
|
|
196
|
-
<TouchableOpacity
|
|
197
|
-
accessibilityRole="button"
|
|
198
|
-
accessibilityState={{ disabled: true }}
|
|
199
|
-
/>
|
|
200
|
-
);
|
|
201
|
-
|
|
202
|
-
expect(getByRole('button', { disabled: true })).toBeTruthy();
|
|
203
|
-
expect(queryByRole('button', { disabled: false })).toBe(null);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
test('returns the correct element when only one matches all the requirements', () => {
|
|
207
|
-
const { getByRole } = render(
|
|
208
|
-
<>
|
|
209
|
-
<TouchableOpacity
|
|
210
|
-
testID="correct"
|
|
211
|
-
accessibilityRole="button"
|
|
212
|
-
accessibilityState={{ disabled: true }}
|
|
213
|
-
>
|
|
214
|
-
<Text>Save</Text>
|
|
215
|
-
</TouchableOpacity>
|
|
216
|
-
<TouchableOpacity testID="wrong" accessibilityRole="button">
|
|
217
|
-
<Text>Save</Text>
|
|
218
|
-
</TouchableOpacity>
|
|
219
|
-
</>
|
|
220
|
-
);
|
|
221
|
-
|
|
222
|
-
expect(
|
|
223
|
-
getByRole('button', { name: 'Save', disabled: true }).props.testID
|
|
224
|
-
).toBe('correct');
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
test('returns an implicitly enabled element', () => {
|
|
228
|
-
const { getByRole, queryByRole } = render(
|
|
229
|
-
<TouchableOpacity accessibilityRole="button"></TouchableOpacity>
|
|
230
|
-
);
|
|
231
|
-
|
|
232
|
-
expect(getByRole('button', { disabled: false })).toBeTruthy();
|
|
233
|
-
expect(queryByRole('button', { disabled: true })).toBe(null);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
test('returns an explicitly enabled element', () => {
|
|
237
|
-
const { getByRole, queryByRole } = render(
|
|
238
|
-
<TouchableOpacity
|
|
239
|
-
accessibilityRole="button"
|
|
240
|
-
accessibilityState={{ disabled: false }}
|
|
241
|
-
></TouchableOpacity>
|
|
242
|
-
);
|
|
243
|
-
|
|
244
|
-
expect(getByRole('button', { disabled: false })).toBeTruthy();
|
|
245
|
-
expect(queryByRole('button', { disabled: true })).toBe(null);
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
test('does not return disabled elements when querying for non disabled', () => {
|
|
249
|
-
const { queryByRole } = render(
|
|
250
|
-
<TouchableOpacity
|
|
251
|
-
accessibilityRole="button"
|
|
252
|
-
accessibilityState={{ disabled: true }}
|
|
253
|
-
></TouchableOpacity>
|
|
254
|
-
);
|
|
255
|
-
|
|
256
|
-
expect(queryByRole('button', { disabled: false })).toBe(null);
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
test('returns elements using the built-in disabled prop', () => {
|
|
260
|
-
const { getByRole } = render(
|
|
261
|
-
<>
|
|
262
|
-
<Pressable disabled accessibilityRole="button">
|
|
263
|
-
<Text>Pressable</Text>
|
|
264
|
-
</Pressable>
|
|
265
|
-
|
|
266
|
-
<TouchableWithoutFeedback disabled accessibilityRole="button">
|
|
267
|
-
<View>
|
|
268
|
-
<Text>TouchableWithoutFeedback</Text>
|
|
269
|
-
</View>
|
|
270
|
-
</TouchableWithoutFeedback>
|
|
271
|
-
<RNButton disabled onPress={() => {}} title="RNButton" />
|
|
272
|
-
</>
|
|
273
|
-
);
|
|
274
|
-
|
|
275
|
-
expect(
|
|
276
|
-
getByRole('button', { name: 'Pressable', disabled: true })
|
|
277
|
-
).toBeTruthy();
|
|
278
|
-
|
|
279
|
-
expect(
|
|
280
|
-
getByRole('button', {
|
|
281
|
-
name: 'TouchableWithoutFeedback',
|
|
282
|
-
disabled: true,
|
|
283
|
-
})
|
|
284
|
-
).toBeTruthy();
|
|
285
|
-
|
|
286
|
-
expect(
|
|
287
|
-
getByRole('button', { name: 'RNButton', disabled: true })
|
|
288
|
-
).toBeTruthy();
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
describe('selected', () => {
|
|
293
|
-
test('returns a selected element when required', () => {
|
|
294
|
-
const { getByRole, queryByRole } = render(
|
|
295
|
-
<TouchableOpacity
|
|
296
|
-
accessibilityRole="tab"
|
|
297
|
-
accessibilityState={{ selected: true }}
|
|
298
|
-
/>
|
|
299
|
-
);
|
|
300
|
-
|
|
301
|
-
expect(getByRole('tab', { selected: true })).toBeTruthy();
|
|
302
|
-
expect(queryByRole('tab', { selected: false })).toBe(null);
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
test('returns the correct element when only one matches all the requirements', () => {
|
|
306
|
-
const { getByRole } = render(
|
|
307
|
-
<>
|
|
308
|
-
<TouchableOpacity
|
|
309
|
-
testID="correct"
|
|
310
|
-
accessibilityRole="tab"
|
|
311
|
-
accessibilityState={{ selected: true }}
|
|
312
|
-
>
|
|
313
|
-
<Text>Save</Text>
|
|
314
|
-
</TouchableOpacity>
|
|
315
|
-
<TouchableOpacity testID="wrong" accessibilityRole="tab">
|
|
316
|
-
<Text>Save</Text>
|
|
317
|
-
</TouchableOpacity>
|
|
318
|
-
</>
|
|
319
|
-
);
|
|
320
|
-
|
|
321
|
-
expect(
|
|
322
|
-
getByRole('tab', { name: 'Save', selected: true }).props.testID
|
|
323
|
-
).toBe('correct');
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
test('returns an implicitly non selected element', () => {
|
|
327
|
-
const { getByRole, queryByRole } = render(
|
|
328
|
-
<TouchableOpacity accessibilityRole="tab"></TouchableOpacity>
|
|
329
|
-
);
|
|
330
|
-
|
|
331
|
-
expect(getByRole('tab', { selected: false })).toBeTruthy();
|
|
332
|
-
expect(queryByRole('tab', { selected: true })).toBe(null);
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
test('returns an explicitly non selected element', () => {
|
|
336
|
-
const { getByRole, queryByRole } = render(
|
|
337
|
-
<TouchableOpacity
|
|
338
|
-
accessibilityRole="tab"
|
|
339
|
-
accessibilityState={{ selected: false }}
|
|
340
|
-
></TouchableOpacity>
|
|
341
|
-
);
|
|
342
|
-
|
|
343
|
-
expect(getByRole('tab', { selected: false })).toBeTruthy();
|
|
344
|
-
expect(queryByRole('tab', { selected: true })).toBe(null);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
test('does not return selected elements when querying for non selected', () => {
|
|
348
|
-
const { queryByRole } = render(
|
|
349
|
-
<TouchableOpacity
|
|
350
|
-
accessibilityRole="tab"
|
|
351
|
-
accessibilityState={{ selected: true }}
|
|
352
|
-
></TouchableOpacity>
|
|
353
|
-
);
|
|
354
|
-
|
|
355
|
-
expect(queryByRole('tab', { selected: false })).toBe(null);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
describe('checked', () => {
|
|
360
|
-
test('returns a checked element when required', () => {
|
|
361
|
-
const { getByRole, queryByRole } = render(
|
|
362
|
-
<TouchableOpacity
|
|
363
|
-
accessibilityRole="checkbox"
|
|
364
|
-
accessibilityState={{ checked: true }}
|
|
365
|
-
/>
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
expect(getByRole('checkbox', { checked: true })).toBeTruthy();
|
|
369
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
370
|
-
expect(queryByRole('checkbox', { checked: 'mixed' })).toBe(null);
|
|
371
|
-
});
|
|
372
|
-
|
|
373
|
-
it('returns `mixed` checkboxes', () => {
|
|
374
|
-
const { queryByRole, getByRole } = render(
|
|
375
|
-
<TouchableOpacity
|
|
376
|
-
accessibilityRole="checkbox"
|
|
377
|
-
accessibilityState={{ checked: 'mixed' }}
|
|
378
|
-
/>
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
expect(getByRole('checkbox', { checked: 'mixed' })).toBeTruthy();
|
|
382
|
-
expect(queryByRole('checkbox', { checked: true })).toBe(null);
|
|
383
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
384
|
-
});
|
|
385
|
-
|
|
386
|
-
it('does not return mixed checkboxes when querying for checked: true', () => {
|
|
387
|
-
const { queryByRole } = render(
|
|
388
|
-
<TouchableOpacity
|
|
389
|
-
accessibilityRole="checkbox"
|
|
390
|
-
accessibilityState={{ checked: 'mixed' }}
|
|
391
|
-
/>
|
|
392
|
-
);
|
|
393
|
-
|
|
394
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
test('returns the correct element when only one matches all the requirements', () => {
|
|
398
|
-
const { getByRole } = render(
|
|
399
|
-
<>
|
|
400
|
-
<TouchableOpacity
|
|
401
|
-
testID="correct"
|
|
402
|
-
accessibilityRole="checkbox"
|
|
403
|
-
accessibilityState={{ checked: true }}
|
|
404
|
-
>
|
|
405
|
-
<Text>Save</Text>
|
|
406
|
-
</TouchableOpacity>
|
|
407
|
-
<TouchableOpacity testID="wrong" accessibilityRole="checkbox">
|
|
408
|
-
<Text>Save</Text>
|
|
409
|
-
</TouchableOpacity>
|
|
410
|
-
</>
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
expect(
|
|
414
|
-
getByRole('checkbox', { name: 'Save', checked: true }).props.testID
|
|
415
|
-
).toBe('correct');
|
|
416
|
-
});
|
|
417
|
-
|
|
418
|
-
test('does not return return as non checked an element with checked: undefined', () => {
|
|
419
|
-
const { queryByRole } = render(
|
|
420
|
-
<TouchableOpacity accessibilityRole="checkbox"></TouchableOpacity>
|
|
421
|
-
);
|
|
422
|
-
|
|
423
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
424
|
-
});
|
|
425
|
-
|
|
426
|
-
test('returns an explicitly non checked element', () => {
|
|
427
|
-
const { getByRole, queryByRole } = render(
|
|
428
|
-
<TouchableOpacity
|
|
429
|
-
accessibilityRole="checkbox"
|
|
430
|
-
accessibilityState={{ checked: false }}
|
|
431
|
-
></TouchableOpacity>
|
|
432
|
-
);
|
|
433
|
-
|
|
434
|
-
expect(getByRole('checkbox', { checked: false })).toBeTruthy();
|
|
435
|
-
expect(queryByRole('checkbox', { checked: true })).toBe(null);
|
|
436
|
-
});
|
|
437
|
-
|
|
438
|
-
test('does not return checked elements when querying for non checked', () => {
|
|
439
|
-
const { queryByRole } = render(
|
|
440
|
-
<TouchableOpacity
|
|
441
|
-
accessibilityRole="checkbox"
|
|
442
|
-
accessibilityState={{ checked: true }}
|
|
443
|
-
></TouchableOpacity>
|
|
444
|
-
);
|
|
445
|
-
|
|
446
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
test('does not return mixed elements when querying for non checked', () => {
|
|
450
|
-
const { queryByRole } = render(
|
|
451
|
-
<TouchableOpacity
|
|
452
|
-
accessibilityRole="checkbox"
|
|
453
|
-
accessibilityState={{ checked: 'mixed' }}
|
|
454
|
-
></TouchableOpacity>
|
|
455
|
-
);
|
|
456
|
-
|
|
457
|
-
expect(queryByRole('checkbox', { checked: false })).toBe(null);
|
|
458
|
-
});
|
|
459
|
-
});
|
|
460
|
-
|
|
461
|
-
describe('busy', () => {
|
|
462
|
-
test('returns a busy element when required', () => {
|
|
463
|
-
const { getByRole, queryByRole } = render(
|
|
464
|
-
<TouchableOpacity
|
|
465
|
-
accessibilityRole="button"
|
|
466
|
-
accessibilityState={{ busy: true }}
|
|
467
|
-
/>
|
|
468
|
-
);
|
|
469
|
-
|
|
470
|
-
expect(getByRole('button', { busy: true })).toBeTruthy();
|
|
471
|
-
expect(queryByRole('button', { busy: false })).toBe(null);
|
|
472
|
-
});
|
|
473
|
-
|
|
474
|
-
test('returns the correct element when only one matches all the requirements', () => {
|
|
475
|
-
const { getByRole } = render(
|
|
476
|
-
<>
|
|
477
|
-
<TouchableOpacity
|
|
478
|
-
testID="correct"
|
|
479
|
-
accessibilityRole="button"
|
|
480
|
-
accessibilityState={{ busy: true }}
|
|
481
|
-
>
|
|
482
|
-
<Text>Save</Text>
|
|
483
|
-
</TouchableOpacity>
|
|
484
|
-
<TouchableOpacity testID="wrong" accessibilityRole="button">
|
|
485
|
-
<Text>Save</Text>
|
|
486
|
-
</TouchableOpacity>
|
|
487
|
-
</>
|
|
488
|
-
);
|
|
489
|
-
|
|
490
|
-
expect(
|
|
491
|
-
getByRole('button', { name: 'Save', busy: true }).props.testID
|
|
492
|
-
).toBe('correct');
|
|
493
|
-
});
|
|
494
|
-
|
|
495
|
-
test('returns an implicitly non busy element', () => {
|
|
496
|
-
const { getByRole, queryByRole } = render(
|
|
497
|
-
<TouchableOpacity accessibilityRole="button"></TouchableOpacity>
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
expect(getByRole('button', { busy: false })).toBeTruthy();
|
|
501
|
-
expect(queryByRole('button', { busy: true })).toBe(null);
|
|
502
|
-
});
|
|
503
|
-
|
|
504
|
-
test('returns an explicitly non busy element', () => {
|
|
505
|
-
const { getByRole, queryByRole } = render(
|
|
506
|
-
<TouchableOpacity
|
|
507
|
-
accessibilityRole="button"
|
|
508
|
-
accessibilityState={{ busy: false }}
|
|
509
|
-
></TouchableOpacity>
|
|
510
|
-
);
|
|
511
|
-
|
|
512
|
-
expect(getByRole('button', { busy: false })).toBeTruthy();
|
|
513
|
-
expect(queryByRole('button', { busy: true })).toBe(null);
|
|
514
|
-
});
|
|
515
|
-
|
|
516
|
-
test('does not return busy elements when querying for non busy', () => {
|
|
517
|
-
const { queryByRole } = render(
|
|
518
|
-
<TouchableOpacity
|
|
519
|
-
accessibilityRole="button"
|
|
520
|
-
accessibilityState={{ selected: true }}
|
|
521
|
-
></TouchableOpacity>
|
|
522
|
-
);
|
|
523
|
-
|
|
524
|
-
expect(queryByRole('button', { selected: false })).toBe(null);
|
|
525
|
-
});
|
|
526
|
-
});
|
|
527
|
-
|
|
528
|
-
describe('expanded', () => {
|
|
529
|
-
test('returns a expanded element when required', () => {
|
|
530
|
-
const { getByRole, queryByRole } = render(
|
|
531
|
-
<TouchableOpacity
|
|
532
|
-
accessibilityRole="button"
|
|
533
|
-
accessibilityState={{ expanded: true }}
|
|
534
|
-
/>
|
|
535
|
-
);
|
|
536
|
-
|
|
537
|
-
expect(getByRole('button', { expanded: true })).toBeTruthy();
|
|
538
|
-
expect(queryByRole('button', { expanded: false })).toBe(null);
|
|
539
|
-
});
|
|
540
|
-
|
|
541
|
-
test('returns the correct element when only one matches all the requirements', () => {
|
|
542
|
-
const { getByRole } = render(
|
|
543
|
-
<>
|
|
544
|
-
<TouchableOpacity
|
|
545
|
-
testID="correct"
|
|
546
|
-
accessibilityRole="button"
|
|
547
|
-
accessibilityState={{ expanded: true }}
|
|
548
|
-
>
|
|
549
|
-
<Text>Save</Text>
|
|
550
|
-
</TouchableOpacity>
|
|
551
|
-
<TouchableOpacity testID="wrong" accessibilityRole="button">
|
|
552
|
-
<Text>Save</Text>
|
|
553
|
-
</TouchableOpacity>
|
|
554
|
-
</>
|
|
555
|
-
);
|
|
556
|
-
|
|
557
|
-
expect(
|
|
558
|
-
getByRole('button', { name: 'Save', expanded: true }).props.testID
|
|
559
|
-
).toBe('correct');
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
test('does not return return as non expanded an element with expanded: undefined', () => {
|
|
563
|
-
const { queryByRole } = render(
|
|
564
|
-
<TouchableOpacity accessibilityRole="button"></TouchableOpacity>
|
|
565
|
-
);
|
|
566
|
-
|
|
567
|
-
expect(queryByRole('button', { expanded: false })).toBe(null);
|
|
568
|
-
});
|
|
569
|
-
|
|
570
|
-
test('returns an explicitly non expanded element', () => {
|
|
571
|
-
const { getByRole, queryByRole } = render(
|
|
572
|
-
<TouchableOpacity
|
|
573
|
-
accessibilityRole="button"
|
|
574
|
-
accessibilityState={{ expanded: false }}
|
|
575
|
-
></TouchableOpacity>
|
|
576
|
-
);
|
|
577
|
-
|
|
578
|
-
expect(getByRole('button', { expanded: false })).toBeTruthy();
|
|
579
|
-
expect(queryByRole('button', { expanded: true })).toBe(null);
|
|
580
|
-
});
|
|
581
|
-
|
|
582
|
-
test('does not return expanded elements when querying for non expanded', () => {
|
|
583
|
-
const { queryByRole } = render(
|
|
584
|
-
<TouchableOpacity
|
|
585
|
-
accessibilityRole="button"
|
|
586
|
-
accessibilityState={{ expanded: true }}
|
|
587
|
-
></TouchableOpacity>
|
|
588
|
-
);
|
|
589
|
-
|
|
590
|
-
expect(queryByRole('button', { expanded: false })).toBe(null);
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
|
|
594
|
-
test('ignores non queried accessibilityState', () => {
|
|
595
|
-
const { getByRole, queryByRole } = render(
|
|
596
|
-
<TouchableOpacity
|
|
597
|
-
accessibilityRole="button"
|
|
598
|
-
accessibilityState={{
|
|
599
|
-
disabled: true,
|
|
600
|
-
// set `selected`, but don't query it
|
|
601
|
-
selected: true,
|
|
602
|
-
}}
|
|
603
|
-
>
|
|
604
|
-
<Text>Save</Text>
|
|
605
|
-
</TouchableOpacity>
|
|
606
|
-
);
|
|
607
|
-
|
|
608
|
-
expect(
|
|
609
|
-
getByRole('button', {
|
|
610
|
-
name: 'Save',
|
|
611
|
-
disabled: true,
|
|
612
|
-
})
|
|
613
|
-
).toBeTruthy();
|
|
614
|
-
expect(
|
|
615
|
-
queryByRole('button', {
|
|
616
|
-
name: 'Save',
|
|
617
|
-
disabled: false,
|
|
618
|
-
})
|
|
619
|
-
).toBe(null);
|
|
620
|
-
});
|
|
621
|
-
|
|
622
|
-
test('matches an element combining all the options', () => {
|
|
623
|
-
const { getByRole } = render(
|
|
624
|
-
<TouchableOpacity
|
|
625
|
-
accessibilityRole="button"
|
|
626
|
-
accessibilityState={{
|
|
627
|
-
disabled: true,
|
|
628
|
-
selected: true,
|
|
629
|
-
checked: true,
|
|
630
|
-
busy: true,
|
|
631
|
-
expanded: true,
|
|
632
|
-
}}
|
|
633
|
-
>
|
|
634
|
-
<Text>Save</Text>
|
|
635
|
-
</TouchableOpacity>
|
|
636
|
-
);
|
|
637
|
-
|
|
638
|
-
expect(
|
|
639
|
-
getByRole('button', {
|
|
640
|
-
name: 'Save',
|
|
641
|
-
disabled: true,
|
|
642
|
-
selected: true,
|
|
643
|
-
checked: true,
|
|
644
|
-
busy: true,
|
|
645
|
-
expanded: true,
|
|
646
|
-
})
|
|
647
|
-
).toBeTruthy();
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
describe('error messages', () => {
|
|
652
|
-
test('gives a descriptive error message when querying with a role', () => {
|
|
653
|
-
const { getByRole } = render(<View />);
|
|
654
|
-
|
|
655
|
-
expect(() => getByRole('button')).toThrowErrorMatchingInlineSnapshot(`
|
|
656
|
-
"Unable to find an element with role: "button"
|
|
657
|
-
|
|
658
|
-
<View />"
|
|
659
|
-
`);
|
|
660
|
-
});
|
|
661
|
-
|
|
662
|
-
test('gives a descriptive error message when querying with a role and a name', () => {
|
|
663
|
-
const { getByRole } = render(<View />);
|
|
664
|
-
|
|
665
|
-
expect(() => getByRole('button', { name: 'Save' }))
|
|
666
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
667
|
-
"Unable to find an element with role: "button", name: "Save"
|
|
668
|
-
|
|
669
|
-
<View />"
|
|
670
|
-
`);
|
|
671
|
-
});
|
|
672
|
-
|
|
673
|
-
test('gives a descriptive error message when querying with a role, a name and accessibility state', () => {
|
|
674
|
-
const { getByRole } = render(<View />);
|
|
675
|
-
|
|
676
|
-
expect(() => getByRole('button', { name: 'Save', disabled: true }))
|
|
677
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
678
|
-
"Unable to find an element with role: "button", name: "Save", disabled state: true
|
|
679
|
-
|
|
680
|
-
<View />"
|
|
681
|
-
`);
|
|
682
|
-
});
|
|
683
|
-
|
|
684
|
-
test('gives a descriptive error message when querying with a role, a name and several accessibility state', () => {
|
|
685
|
-
const { getByRole } = render(<View />);
|
|
686
|
-
|
|
687
|
-
expect(() =>
|
|
688
|
-
getByRole('button', { name: 'Save', disabled: true, selected: true })
|
|
689
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
690
|
-
"Unable to find an element with role: "button", name: "Save", disabled state: true, selected state: true
|
|
691
|
-
|
|
692
|
-
<View />"
|
|
693
|
-
`);
|
|
694
|
-
});
|
|
695
|
-
|
|
696
|
-
test('gives a descriptive error message when querying with a role and an accessibility state', () => {
|
|
697
|
-
const { getByRole } = render(<View />);
|
|
698
|
-
|
|
699
|
-
expect(() => getByRole('button', { disabled: true }))
|
|
700
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
701
|
-
"Unable to find an element with role: "button", disabled state: true
|
|
702
|
-
|
|
703
|
-
<View />"
|
|
704
|
-
`);
|
|
705
|
-
});
|
|
706
|
-
|
|
707
|
-
test('gives a descriptive error message when querying with a role and an accessibility value', () => {
|
|
708
|
-
const { getByRole } = render(<View />);
|
|
709
|
-
|
|
710
|
-
expect(() => getByRole('adjustable', { value: { min: 1 } }))
|
|
711
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
712
|
-
"Unable to find an element with role: "adjustable", min value: 1
|
|
713
|
-
|
|
714
|
-
<View />"
|
|
715
|
-
`);
|
|
716
|
-
|
|
717
|
-
expect(() =>
|
|
718
|
-
getByRole('adjustable', {
|
|
719
|
-
value: { min: 1, max: 2, now: 1, text: /hello/ },
|
|
720
|
-
})
|
|
721
|
-
).toThrowErrorMatchingInlineSnapshot(`
|
|
722
|
-
"Unable to find an element with role: "adjustable", min value: 1, max value: 2, now value: 1, text value: /hello/
|
|
723
|
-
|
|
724
|
-
<View />"
|
|
725
|
-
`);
|
|
726
|
-
});
|
|
727
|
-
});
|
|
728
|
-
|
|
729
|
-
test('byRole queries support hidden option', () => {
|
|
730
|
-
const { getByRole, queryByRole } = render(
|
|
731
|
-
<Pressable accessibilityRole="button" style={{ display: 'none' }}>
|
|
732
|
-
<Text>Hidden from accessibility</Text>
|
|
733
|
-
</Pressable>
|
|
734
|
-
);
|
|
735
|
-
|
|
736
|
-
expect(getByRole('button', { includeHiddenElements: true })).toBeTruthy();
|
|
737
|
-
|
|
738
|
-
expect(queryByRole('button')).toBeFalsy();
|
|
739
|
-
expect(queryByRole('button', { includeHiddenElements: false })).toBeFalsy();
|
|
740
|
-
expect(() => getByRole('button', { includeHiddenElements: false }))
|
|
741
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
742
|
-
"Unable to find an element with role: "button"
|
|
743
|
-
|
|
744
|
-
<View
|
|
745
|
-
accessibilityRole="button"
|
|
746
|
-
style={
|
|
747
|
-
{
|
|
748
|
-
"display": "none",
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
>
|
|
752
|
-
<Text>
|
|
753
|
-
Hidden from accessibility
|
|
754
|
-
</Text>
|
|
755
|
-
</View>"
|
|
756
|
-
`);
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
describe('matches only accessible elements', () => {
|
|
760
|
-
test('matches elements with accessible={true}', () => {
|
|
761
|
-
const { queryByRole } = render(
|
|
762
|
-
<View accessibilityRole="menu" accessible={true}>
|
|
763
|
-
<Text>Action</Text>
|
|
764
|
-
</View>
|
|
765
|
-
);
|
|
766
|
-
expect(queryByRole('menu', { name: 'Action' })).toBeTruthy();
|
|
767
|
-
});
|
|
768
|
-
|
|
769
|
-
test('ignores elements with accessible={false}', () => {
|
|
770
|
-
const { queryByRole } = render(
|
|
771
|
-
<Pressable accessibilityRole="button" accessible={false}>
|
|
772
|
-
<Text>Action</Text>
|
|
773
|
-
</Pressable>
|
|
774
|
-
);
|
|
775
|
-
expect(queryByRole('button', { name: 'Action' })).toBeFalsy();
|
|
776
|
-
});
|
|
777
|
-
|
|
778
|
-
test('ignores elements with accessible={undefined} and that are implicitely not accessible', () => {
|
|
779
|
-
const { queryByRole } = render(
|
|
780
|
-
<View accessibilityRole="menu">
|
|
781
|
-
<Text>Action</Text>
|
|
782
|
-
</View>
|
|
783
|
-
);
|
|
784
|
-
expect(queryByRole('menu', { name: 'Action' })).toBeFalsy();
|
|
785
|
-
});
|
|
786
|
-
});
|
|
787
|
-
|
|
788
|
-
test('error message renders the element tree, preserving only helpful props', async () => {
|
|
789
|
-
const view = render(<View accessibilityRole="button" key="3" />);
|
|
790
|
-
|
|
791
|
-
expect(() => view.getByRole('link')).toThrowErrorMatchingInlineSnapshot(`
|
|
792
|
-
"Unable to find an element with role: "link"
|
|
793
|
-
|
|
794
|
-
<View
|
|
795
|
-
accessibilityRole="button"
|
|
796
|
-
/>"
|
|
797
|
-
`);
|
|
798
|
-
|
|
799
|
-
expect(() => view.getAllByRole('link')).toThrowErrorMatchingInlineSnapshot(`
|
|
800
|
-
"Unable to find an element with role: "link"
|
|
801
|
-
|
|
802
|
-
<View
|
|
803
|
-
accessibilityRole="button"
|
|
804
|
-
/>"
|
|
805
|
-
`);
|
|
806
|
-
|
|
807
|
-
await expect(view.findByRole('link')).rejects
|
|
808
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
809
|
-
"Unable to find an element with role: "link"
|
|
810
|
-
|
|
811
|
-
<View
|
|
812
|
-
accessibilityRole="button"
|
|
813
|
-
/>"
|
|
814
|
-
`);
|
|
815
|
-
|
|
816
|
-
await expect(view.findAllByRole('link')).rejects
|
|
817
|
-
.toThrowErrorMatchingInlineSnapshot(`
|
|
818
|
-
"Unable to find an element with role: "link"
|
|
819
|
-
|
|
820
|
-
<View
|
|
821
|
-
accessibilityRole="button"
|
|
822
|
-
/>"
|
|
823
|
-
`);
|
|
824
|
-
});
|