@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
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`clear() supports basic case: value: "Hello! 1`] = `
|
|
4
|
+
[
|
|
5
|
+
{
|
|
6
|
+
"name": "focus",
|
|
7
|
+
"payload": {
|
|
8
|
+
"nativeEvent": {
|
|
9
|
+
"target": 0,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"name": "selectionChange",
|
|
15
|
+
"payload": {
|
|
16
|
+
"nativeEvent": {
|
|
17
|
+
"selection": {
|
|
18
|
+
"end": 6,
|
|
19
|
+
"start": 0,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"name": "keyPress",
|
|
26
|
+
"payload": {
|
|
27
|
+
"nativeEvent": {
|
|
28
|
+
"key": "Backspace",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "change",
|
|
34
|
+
"payload": {
|
|
35
|
+
"nativeEvent": {
|
|
36
|
+
"eventCount": 0,
|
|
37
|
+
"target": 0,
|
|
38
|
+
"text": "",
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"name": "changeText",
|
|
44
|
+
"payload": "",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "selectionChange",
|
|
48
|
+
"payload": {
|
|
49
|
+
"nativeEvent": {
|
|
50
|
+
"selection": {
|
|
51
|
+
"end": 0,
|
|
52
|
+
"start": 0,
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "endEditing",
|
|
59
|
+
"payload": {
|
|
60
|
+
"nativeEvent": {
|
|
61
|
+
"target": 0,
|
|
62
|
+
"text": "",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"name": "blur",
|
|
68
|
+
"payload": {
|
|
69
|
+
"nativeEvent": {
|
|
70
|
+
"target": 0,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
]
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
exports[`clear() supports defaultValue prop: defaultValue: "Hello Default!" 1`] = `
|
|
78
|
+
[
|
|
79
|
+
{
|
|
80
|
+
"name": "focus",
|
|
81
|
+
"payload": {
|
|
82
|
+
"nativeEvent": {
|
|
83
|
+
"target": 0,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "selectionChange",
|
|
89
|
+
"payload": {
|
|
90
|
+
"nativeEvent": {
|
|
91
|
+
"selection": {
|
|
92
|
+
"end": 14,
|
|
93
|
+
"start": 0,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "keyPress",
|
|
100
|
+
"payload": {
|
|
101
|
+
"nativeEvent": {
|
|
102
|
+
"key": "Backspace",
|
|
103
|
+
},
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"name": "change",
|
|
108
|
+
"payload": {
|
|
109
|
+
"nativeEvent": {
|
|
110
|
+
"eventCount": 0,
|
|
111
|
+
"target": 0,
|
|
112
|
+
"text": "",
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"name": "changeText",
|
|
118
|
+
"payload": "",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"name": "selectionChange",
|
|
122
|
+
"payload": {
|
|
123
|
+
"nativeEvent": {
|
|
124
|
+
"selection": {
|
|
125
|
+
"end": 0,
|
|
126
|
+
"start": 0,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "endEditing",
|
|
133
|
+
"payload": {
|
|
134
|
+
"nativeEvent": {
|
|
135
|
+
"target": 0,
|
|
136
|
+
"text": "",
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "blur",
|
|
142
|
+
"payload": {
|
|
143
|
+
"nativeEvent": {
|
|
144
|
+
"target": 0,
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
]
|
|
149
|
+
`;
|
|
150
|
+
|
|
151
|
+
exports[`clear() supports multiline: value: "Hello World!
|
|
152
|
+
How are you?" multiline: true, 1`] = `
|
|
153
|
+
[
|
|
154
|
+
{
|
|
155
|
+
"name": "focus",
|
|
156
|
+
"payload": {
|
|
157
|
+
"nativeEvent": {
|
|
158
|
+
"target": 0,
|
|
159
|
+
},
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"name": "selectionChange",
|
|
164
|
+
"payload": {
|
|
165
|
+
"nativeEvent": {
|
|
166
|
+
"selection": {
|
|
167
|
+
"end": 25,
|
|
168
|
+
"start": 0,
|
|
169
|
+
},
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"name": "keyPress",
|
|
175
|
+
"payload": {
|
|
176
|
+
"nativeEvent": {
|
|
177
|
+
"key": "Backspace",
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"name": "textInput",
|
|
183
|
+
"payload": {
|
|
184
|
+
"nativeEvent": {
|
|
185
|
+
"previousText": "Hello World!
|
|
186
|
+
How are you?",
|
|
187
|
+
"range": {
|
|
188
|
+
"end": 0,
|
|
189
|
+
"start": 0,
|
|
190
|
+
},
|
|
191
|
+
"target": 0,
|
|
192
|
+
"text": "",
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
"name": "change",
|
|
198
|
+
"payload": {
|
|
199
|
+
"nativeEvent": {
|
|
200
|
+
"eventCount": 0,
|
|
201
|
+
"target": 0,
|
|
202
|
+
"text": "",
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"name": "changeText",
|
|
208
|
+
"payload": "",
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
"name": "selectionChange",
|
|
212
|
+
"payload": {
|
|
213
|
+
"nativeEvent": {
|
|
214
|
+
"selection": {
|
|
215
|
+
"end": 0,
|
|
216
|
+
"start": 0,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "contentSizeChange",
|
|
223
|
+
"payload": {
|
|
224
|
+
"nativeEvent": {
|
|
225
|
+
"contentSize": {
|
|
226
|
+
"height": 16,
|
|
227
|
+
"width": 0,
|
|
228
|
+
},
|
|
229
|
+
"target": 0,
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
"name": "endEditing",
|
|
235
|
+
"payload": {
|
|
236
|
+
"nativeEvent": {
|
|
237
|
+
"target": 0,
|
|
238
|
+
"text": "",
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"name": "blur",
|
|
244
|
+
"payload": {
|
|
245
|
+
"nativeEvent": {
|
|
246
|
+
"target": 0,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
]
|
|
251
|
+
`;
|
|
252
|
+
|
|
253
|
+
exports[`clear() works when not all events have handlers 1`] = `
|
|
254
|
+
[
|
|
255
|
+
{
|
|
256
|
+
"name": "changeText",
|
|
257
|
+
"payload": "",
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
"name": "endEditing",
|
|
261
|
+
"payload": {
|
|
262
|
+
"nativeEvent": {
|
|
263
|
+
"target": 0,
|
|
264
|
+
"text": "",
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
},
|
|
268
|
+
]
|
|
269
|
+
`;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { View, TextInput, TextInputProps } from 'react-native';
|
|
3
|
+
import { createEventLogger } from '../../test-utils/events';
|
|
4
|
+
import { render, userEvent } from '../..';
|
|
5
|
+
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
jest.useRealTimers();
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
function renderTextInputWithToolkit(props: TextInputProps = {}) {
|
|
11
|
+
const { events, logEvent } = createEventLogger();
|
|
12
|
+
|
|
13
|
+
const screen = render(
|
|
14
|
+
<TextInput
|
|
15
|
+
testID="input"
|
|
16
|
+
onFocus={logEvent('focus')}
|
|
17
|
+
onBlur={logEvent('blur')}
|
|
18
|
+
onPressIn={logEvent('pressIn')}
|
|
19
|
+
onPressOut={logEvent('pressOut')}
|
|
20
|
+
onChange={logEvent('change')}
|
|
21
|
+
onChangeText={logEvent('changeText')}
|
|
22
|
+
onKeyPress={logEvent('keyPress')}
|
|
23
|
+
onTextInput={logEvent('textInput')}
|
|
24
|
+
onSelectionChange={logEvent('selectionChange')}
|
|
25
|
+
onSubmitEditing={logEvent('submitEditing')}
|
|
26
|
+
onEndEditing={logEvent('endEditing')}
|
|
27
|
+
onContentSizeChange={logEvent('contentSizeChange')}
|
|
28
|
+
{...props}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const textInput = screen.getByTestId('input');
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
events,
|
|
36
|
+
textInput,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
describe('clear()', () => {
|
|
41
|
+
it('supports basic case', async () => {
|
|
42
|
+
jest.spyOn(Date, 'now').mockImplementation(() => 100100100100);
|
|
43
|
+
const { textInput, events } = renderTextInputWithToolkit({
|
|
44
|
+
value: 'Hello!',
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const user = userEvent.setup();
|
|
48
|
+
await user.clear(textInput);
|
|
49
|
+
|
|
50
|
+
const eventNames = events.map((e) => e.name);
|
|
51
|
+
expect(eventNames).toEqual([
|
|
52
|
+
'focus',
|
|
53
|
+
'selectionChange',
|
|
54
|
+
'keyPress',
|
|
55
|
+
'change',
|
|
56
|
+
'changeText',
|
|
57
|
+
'selectionChange',
|
|
58
|
+
'endEditing',
|
|
59
|
+
'blur',
|
|
60
|
+
]);
|
|
61
|
+
|
|
62
|
+
expect(events).toMatchSnapshot('value: "Hello!');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it.each(['modern', 'legacy'])('works with %s fake timers', async (type) => {
|
|
66
|
+
jest.useFakeTimers({ legacyFakeTimers: type === 'legacy' });
|
|
67
|
+
const { textInput, events } = renderTextInputWithToolkit({
|
|
68
|
+
value: 'Hello!',
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const user = userEvent.setup();
|
|
72
|
+
await user.clear(textInput);
|
|
73
|
+
|
|
74
|
+
const eventNames = events.map((e) => e.name);
|
|
75
|
+
expect(eventNames).toEqual([
|
|
76
|
+
'focus',
|
|
77
|
+
'selectionChange',
|
|
78
|
+
'keyPress',
|
|
79
|
+
'change',
|
|
80
|
+
'changeText',
|
|
81
|
+
'selectionChange',
|
|
82
|
+
'endEditing',
|
|
83
|
+
'blur',
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('supports defaultValue prop', async () => {
|
|
88
|
+
const { textInput, events } = renderTextInputWithToolkit({
|
|
89
|
+
defaultValue: 'Hello Default!',
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const user = userEvent.setup();
|
|
93
|
+
await user.clear(textInput);
|
|
94
|
+
|
|
95
|
+
const eventNames = events.map((e) => e.name);
|
|
96
|
+
expect(eventNames).toEqual([
|
|
97
|
+
'focus',
|
|
98
|
+
'selectionChange',
|
|
99
|
+
'keyPress',
|
|
100
|
+
'change',
|
|
101
|
+
'changeText',
|
|
102
|
+
'selectionChange',
|
|
103
|
+
'endEditing',
|
|
104
|
+
'blur',
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
expect(events).toMatchSnapshot('defaultValue: "Hello Default!"');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('does respect editable prop', async () => {
|
|
111
|
+
const { textInput } = renderTextInputWithToolkit({
|
|
112
|
+
value: 'Hello!',
|
|
113
|
+
editable: false,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const user = userEvent.setup();
|
|
117
|
+
user.clear(textInput);
|
|
118
|
+
|
|
119
|
+
expect(textInput.props.value).toBe('Hello!');
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it('does respect pointer-events prop', async () => {
|
|
123
|
+
const { textInput } = renderTextInputWithToolkit({
|
|
124
|
+
value: 'Hello!',
|
|
125
|
+
pointerEvents: 'none',
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const user = userEvent.setup();
|
|
129
|
+
user.clear(textInput);
|
|
130
|
+
|
|
131
|
+
expect(textInput.props.value).toBe('Hello!');
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it('supports multiline', async () => {
|
|
135
|
+
const { textInput, events } = renderTextInputWithToolkit({
|
|
136
|
+
value: 'Hello World!\nHow are you?',
|
|
137
|
+
multiline: true,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
const user = userEvent.setup();
|
|
141
|
+
await user.clear(textInput);
|
|
142
|
+
|
|
143
|
+
const eventNames = events.map((e) => e.name);
|
|
144
|
+
expect(eventNames).toEqual([
|
|
145
|
+
'focus',
|
|
146
|
+
'selectionChange',
|
|
147
|
+
'keyPress',
|
|
148
|
+
'textInput',
|
|
149
|
+
'change',
|
|
150
|
+
'changeText',
|
|
151
|
+
'selectionChange',
|
|
152
|
+
'contentSizeChange',
|
|
153
|
+
'endEditing',
|
|
154
|
+
'blur',
|
|
155
|
+
]);
|
|
156
|
+
|
|
157
|
+
expect(events).toMatchSnapshot(
|
|
158
|
+
'value: "Hello World!\nHow are you?" multiline: true,'
|
|
159
|
+
);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
it('works when not all events have handlers', async () => {
|
|
163
|
+
const { events, logEvent } = createEventLogger();
|
|
164
|
+
const screen = render(
|
|
165
|
+
<TextInput
|
|
166
|
+
testID="input"
|
|
167
|
+
onChangeText={logEvent('changeText')}
|
|
168
|
+
onEndEditing={logEvent('endEditing')}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
const user = userEvent.setup();
|
|
173
|
+
await user.clear(screen.getByTestId('input'));
|
|
174
|
+
|
|
175
|
+
const eventNames = events.map((e) => e.name);
|
|
176
|
+
expect(eventNames).toEqual(['changeText', 'endEditing']);
|
|
177
|
+
|
|
178
|
+
expect(events).toMatchSnapshot();
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it('does NOT work on View', async () => {
|
|
182
|
+
const screen = render(<View testID="input" />);
|
|
183
|
+
|
|
184
|
+
const user = userEvent.setup();
|
|
185
|
+
await expect(
|
|
186
|
+
user.clear(screen.getByTestId('input'))
|
|
187
|
+
).rejects.toThrowErrorMatchingInlineSnapshot(
|
|
188
|
+
`"clear() only supports host "TextInput" elements. Passed element has type: "View"."`
|
|
189
|
+
);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// View that ignores props type checking
|
|
193
|
+
const AnyView = View as React.ComponentType<any>;
|
|
194
|
+
|
|
195
|
+
it('does NOT bubble up', async () => {
|
|
196
|
+
const parentHandler = jest.fn();
|
|
197
|
+
const screen = render(
|
|
198
|
+
<AnyView
|
|
199
|
+
onChangeText={parentHandler}
|
|
200
|
+
onChange={parentHandler}
|
|
201
|
+
onKeyPress={parentHandler}
|
|
202
|
+
onTextInput={parentHandler}
|
|
203
|
+
onFocus={parentHandler}
|
|
204
|
+
onBlur={parentHandler}
|
|
205
|
+
onEndEditing={parentHandler}
|
|
206
|
+
onPressIn={parentHandler}
|
|
207
|
+
onPressOut={parentHandler}
|
|
208
|
+
>
|
|
209
|
+
<TextInput testID="input" />
|
|
210
|
+
</AnyView>
|
|
211
|
+
);
|
|
212
|
+
|
|
213
|
+
const user = userEvent.setup();
|
|
214
|
+
await user.clear(screen.getByTestId('input'));
|
|
215
|
+
expect(parentHandler).not.toHaveBeenCalled();
|
|
216
|
+
});
|
|
217
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ReactTestInstance } from 'react-test-renderer';
|
|
2
|
+
import { ErrorWithStack } from '../helpers/errors';
|
|
3
|
+
import { isHostTextInput } from '../helpers/host-component-names';
|
|
4
|
+
import { isPointerEventEnabled } from '../helpers/pointer-events';
|
|
5
|
+
import { EventBuilder } from './event-builder';
|
|
6
|
+
import { UserEventInstance } from './setup';
|
|
7
|
+
import { dispatchEvent, wait, isEditableTextInput } from './utils';
|
|
8
|
+
import { emitTypingEvents } from './type/type';
|
|
9
|
+
|
|
10
|
+
export async function clear(
|
|
11
|
+
this: UserEventInstance,
|
|
12
|
+
element: ReactTestInstance
|
|
13
|
+
): Promise<void> {
|
|
14
|
+
if (!isHostTextInput(element)) {
|
|
15
|
+
throw new ErrorWithStack(
|
|
16
|
+
`clear() only supports host "TextInput" elements. Passed element has type: "${element.type}".`,
|
|
17
|
+
clear
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (!isEditableTextInput(element) || !isPointerEventEnabled(element)) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// 1. Enter element
|
|
26
|
+
dispatchEvent(element, 'focus', EventBuilder.Common.focus());
|
|
27
|
+
|
|
28
|
+
// 2. Select all
|
|
29
|
+
const previousText = element.props.value ?? element.props.defaultValue ?? '';
|
|
30
|
+
const selectionRange = {
|
|
31
|
+
start: 0,
|
|
32
|
+
end: previousText.length,
|
|
33
|
+
};
|
|
34
|
+
dispatchEvent(
|
|
35
|
+
element,
|
|
36
|
+
'selectionChange',
|
|
37
|
+
EventBuilder.TextInput.selectionChange(selectionRange)
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
// 3. Press backspace
|
|
41
|
+
const finalText = '';
|
|
42
|
+
await emitTypingEvents(
|
|
43
|
+
this.config,
|
|
44
|
+
element,
|
|
45
|
+
'Backspace',
|
|
46
|
+
finalText,
|
|
47
|
+
previousText
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
// 4. Exit element
|
|
51
|
+
await wait(this.config);
|
|
52
|
+
dispatchEvent(
|
|
53
|
+
element,
|
|
54
|
+
'endEditing',
|
|
55
|
+
EventBuilder.TextInput.endEditing(finalText)
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
dispatchEvent(element, 'blur', EventBuilder.Common.blur());
|
|
59
|
+
}
|
package/src/user-event/index.ts
CHANGED
|
@@ -2,13 +2,15 @@ import { ReactTestInstance } from 'react-test-renderer';
|
|
|
2
2
|
import act from '../../act';
|
|
3
3
|
import { getHostParent } from '../../helpers/component-tree';
|
|
4
4
|
import { isPointerEventEnabled } from '../../helpers/pointer-events';
|
|
5
|
-
import {
|
|
6
|
-
isHostText,
|
|
7
|
-
isHostTextInput,
|
|
8
|
-
} from '../../helpers/host-component-names';
|
|
5
|
+
import { isHostText } from '../../helpers/host-component-names';
|
|
9
6
|
import { EventBuilder } from '../event-builder';
|
|
10
7
|
import { UserEventConfig, UserEventInstance } from '../setup';
|
|
11
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
dispatchEvent,
|
|
10
|
+
isEditableTextInput,
|
|
11
|
+
wait,
|
|
12
|
+
warnAboutRealTimersIfNeeded,
|
|
13
|
+
} from '../utils';
|
|
12
14
|
import { DEFAULT_MIN_PRESS_DURATION } from './constants';
|
|
13
15
|
|
|
14
16
|
export interface PressOptions {
|
|
@@ -51,7 +53,7 @@ const basePress = async (
|
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
55
|
|
|
54
|
-
if (
|
|
56
|
+
if (isEditableTextInput(element) && isPointerEventEnabled(element)) {
|
|
55
57
|
await emitTextInputPressEvents(config, element, options);
|
|
56
58
|
return;
|
|
57
59
|
}
|
|
@@ -125,14 +127,6 @@ const isPressableText = (element: ReactTestInstance) => {
|
|
|
125
127
|
);
|
|
126
128
|
};
|
|
127
129
|
|
|
128
|
-
const isEnabledTextInput = (element: ReactTestInstance) => {
|
|
129
|
-
return (
|
|
130
|
-
isHostTextInput(element) &&
|
|
131
|
-
isPointerEventEnabled(element) &&
|
|
132
|
-
element.props.editable !== false
|
|
133
|
-
);
|
|
134
|
-
};
|
|
135
|
-
|
|
136
130
|
/**
|
|
137
131
|
* Dispatches a press event sequence for Text.
|
|
138
132
|
*/
|
|
@@ -2,6 +2,7 @@ import { ReactTestInstance } from 'react-test-renderer';
|
|
|
2
2
|
import { jestFakeTimersAreEnabled } from '../../helpers/timers';
|
|
3
3
|
import { PressOptions, press, longPress } from '../press';
|
|
4
4
|
import { TypeOptions, type } from '../type';
|
|
5
|
+
import { clear } from '../clear';
|
|
5
6
|
|
|
6
7
|
export interface UserEventSetupOptions {
|
|
7
8
|
/**
|
|
@@ -84,7 +85,7 @@ export interface UserEventInstance {
|
|
|
84
85
|
) => Promise<void>;
|
|
85
86
|
|
|
86
87
|
/**
|
|
87
|
-
* Simulate user pressing on given `TextInput` element and typing given text.
|
|
88
|
+
* Simulate user pressing on a given `TextInput` element and typing given text.
|
|
88
89
|
*
|
|
89
90
|
* This method will trigger the events for each character of the text:
|
|
90
91
|
* `keyPress`, `change`, `changeText`, `endEditing`, etc.
|
|
@@ -92,7 +93,7 @@ export interface UserEventInstance {
|
|
|
92
93
|
* It will also trigger events connected with entering and leaving the text
|
|
93
94
|
* input.
|
|
94
95
|
*
|
|
95
|
-
* The exact events sent depend on the props of TextInput (`editable`,
|
|
96
|
+
* The exact events sent depend on the props of the TextInput (`editable`,
|
|
96
97
|
* `multiline`, value, defaultValue, etc) and passed options.
|
|
97
98
|
*
|
|
98
99
|
* @param element TextInput element to type on
|
|
@@ -108,6 +109,19 @@ export interface UserEventInstance {
|
|
|
108
109
|
text: string,
|
|
109
110
|
options?: TypeOptions
|
|
110
111
|
) => Promise<void>;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Simulate user clearing the text of a given `TextInput` element.
|
|
115
|
+
*
|
|
116
|
+
* This method will simulate:
|
|
117
|
+
* 1. entering TextInput
|
|
118
|
+
* 2. selecting all text
|
|
119
|
+
* 3. pressing backspace to delete all text
|
|
120
|
+
* 4. leaving TextInput
|
|
121
|
+
*
|
|
122
|
+
* @param element TextInput element to clear
|
|
123
|
+
*/
|
|
124
|
+
clear: (element: ReactTestInstance) => Promise<void>;
|
|
111
125
|
}
|
|
112
126
|
|
|
113
127
|
function createInstance(config: UserEventConfig): UserEventInstance {
|
|
@@ -120,6 +134,7 @@ function createInstance(config: UserEventConfig): UserEventInstance {
|
|
|
120
134
|
press: press.bind(instance),
|
|
121
135
|
longPress: longPress.bind(instance),
|
|
122
136
|
type: type.bind(instance),
|
|
137
|
+
clear: clear.bind(instance),
|
|
123
138
|
};
|
|
124
139
|
|
|
125
140
|
Object.assign(instance, api);
|