@testing-library/user-event 12.6.3 → 12.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/keys/navigation-key.js +21 -0
- package/dist/type.js +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,6 @@ change the state of the checkbox.
|
|
|
47
47
|
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
|
48
48
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
|
49
49
|
|
|
50
|
-
|
|
51
50
|
- [Installation](#installation)
|
|
52
51
|
- [API](#api)
|
|
53
52
|
- [`click(element, eventInit, options)`](#clickelement-eventinit-options)
|
|
@@ -202,6 +201,8 @@ The following special character strings are supported:
|
|
|
202
201
|
| `{arrowright}` | ArrowRight | N/A | |
|
|
203
202
|
| `{arrowup}` | ArrowUp | N/A | |
|
|
204
203
|
| `{arrowdown}` | ArrowDown | N/A | |
|
|
204
|
+
| `{home}` | Home | N/A | |
|
|
205
|
+
| `{end}` | End | N/A | |
|
|
205
206
|
| `{shift}` | Shift | `shiftKey` | Does **not** capitalize following characters. |
|
|
206
207
|
| `{ctrl}` | Control | `ctrlKey` | |
|
|
207
208
|
| `{alt}` | Alt | `altKey` | |
|
|
@@ -686,6 +687,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
686
687
|
|
|
687
688
|
<!-- markdownlint-enable -->
|
|
688
689
|
<!-- prettier-ignore-end -->
|
|
690
|
+
|
|
689
691
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
690
692
|
|
|
691
693
|
This project follows the [all-contributors][all-contributors] specification.
|
|
@@ -10,6 +10,12 @@ var _dom = require("@testing-library/dom");
|
|
|
10
10
|
var _utils = require("../utils");
|
|
11
11
|
|
|
12
12
|
const keys = {
|
|
13
|
+
Home: {
|
|
14
|
+
keyCode: 36
|
|
15
|
+
},
|
|
16
|
+
End: {
|
|
17
|
+
keyCode: 35
|
|
18
|
+
},
|
|
13
19
|
ArrowLeft: {
|
|
14
20
|
keyCode: 37
|
|
15
21
|
},
|
|
@@ -23,6 +29,21 @@ function getSelectionRange(currentElement, key) {
|
|
|
23
29
|
selectionStart,
|
|
24
30
|
selectionEnd
|
|
25
31
|
} = currentElement();
|
|
32
|
+
|
|
33
|
+
if (key === 'Home') {
|
|
34
|
+
return {
|
|
35
|
+
selectionStart: 0,
|
|
36
|
+
selectionEnd: 0
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (key === 'End') {
|
|
41
|
+
return {
|
|
42
|
+
selectionStart: selectionEnd + 1,
|
|
43
|
+
selectionEnd: selectionEnd + 1
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
26
47
|
const cursorChange = Number(key in keys) * (key === 'ArrowLeft' ? -1 : 1);
|
|
27
48
|
return {
|
|
28
49
|
selectionStart: selectionStart + cursorChange,
|
package/dist/type.js
CHANGED
|
@@ -106,6 +106,8 @@ const specialCharMap = {
|
|
|
106
106
|
escape: '{esc}',
|
|
107
107
|
delete: '{del}',
|
|
108
108
|
backspace: '{backspace}',
|
|
109
|
+
home: '{home}',
|
|
110
|
+
end: '{end}',
|
|
109
111
|
selectAll: '{selectall}',
|
|
110
112
|
space: '{space}',
|
|
111
113
|
whitespace: ' '
|
|
@@ -116,6 +118,8 @@ const specialCharCallbackMap = {
|
|
|
116
118
|
[specialCharMap.arrowRight]: (0, _navigationKey.navigationKey)('ArrowRight'),
|
|
117
119
|
[specialCharMap.arrowDown]: handleArrowDown,
|
|
118
120
|
[specialCharMap.arrowUp]: handleArrowUp,
|
|
121
|
+
[specialCharMap.home]: (0, _navigationKey.navigationKey)('Home'),
|
|
122
|
+
[specialCharMap.end]: (0, _navigationKey.navigationKey)('End'),
|
|
119
123
|
[specialCharMap.enter]: handleEnter,
|
|
120
124
|
[specialCharMap.escape]: handleEsc,
|
|
121
125
|
[specialCharMap.delete]: handleDel,
|