@testing-library/user-event 12.4.0 → 12.5.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 +4 -1
- package/dist/type.js +46 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -198,11 +198,13 @@ The following special character strings are supported:
|
|
|
198
198
|
| `{selectall}` | N/A | N/A | Selects all the text of the element. Note that this will only work for elements that support selection ranges (so, not `email`, `password`, `number`, among others) |
|
|
199
199
|
| `{arrowleft}` | ArrowLeft | N/A | |
|
|
200
200
|
| `{arrowright}` | ArrowRight | N/A | |
|
|
201
|
+
| `{arrowup}` | ArrowUp | N/A | |
|
|
202
|
+
| `{arrowdown}` | ArrowDown | N/A | |
|
|
201
203
|
| `{shift}` | Shift | `shiftKey` | Does **not** capitalize following characters. |
|
|
202
204
|
| `{ctrl}` | Control | `ctrlKey` | |
|
|
203
205
|
| `{alt}` | Alt | `altKey` | |
|
|
204
206
|
| `{meta}` | OS | `metaKey` | |
|
|
205
|
-
| `{capslock}` | CapsLock | `modifierCapsLock` | Fires both keydown and keyup when used (simulates a user clicking their "Caps Lock" button to enable caps lock).
|
|
207
|
+
| `{capslock}` | CapsLock | `modifierCapsLock` | Fires both keydown and keyup when used (simulates a user clicking their "Caps Lock" button to enable caps lock). |
|
|
206
208
|
|
|
207
209
|
> **A note about modifiers:** Modifier keys (`{shift}`, `{ctrl}`, `{alt}`,
|
|
208
210
|
> `{meta}`) will activate their corresponding event modifiers for the duration
|
|
@@ -637,6 +639,7 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
637
639
|
|
|
638
640
|
<!-- markdownlint-enable -->
|
|
639
641
|
<!-- prettier-ignore-end -->
|
|
642
|
+
|
|
640
643
|
<!-- ALL-CONTRIBUTORS-LIST:END -->
|
|
641
644
|
|
|
642
645
|
This project follows the [all-contributors][all-contributors] specification.
|
package/dist/type.js
CHANGED
|
@@ -99,6 +99,8 @@ const modifierCallbackMap = { ...createModifierCallbackEntries({
|
|
|
99
99
|
const specialCharCallbackMap = {
|
|
100
100
|
'{arrowleft}': (0, _navigationKey.navigationKey)('ArrowLeft'),
|
|
101
101
|
'{arrowright}': (0, _navigationKey.navigationKey)('ArrowRight'),
|
|
102
|
+
'{arrowdown}': handleArrowDown,
|
|
103
|
+
'{arrowup}': handleArrowUp,
|
|
102
104
|
'{enter}': handleEnter,
|
|
103
105
|
'{esc}': handleEsc,
|
|
104
106
|
'{del}': handleDel,
|
|
@@ -788,4 +790,48 @@ function handleSpaceOnClickable({
|
|
|
788
790
|
_dom.fireEvent.click(currentElement(), { ...eventOverrides
|
|
789
791
|
});
|
|
790
792
|
}
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function handleArrowDown({
|
|
796
|
+
currentElement,
|
|
797
|
+
eventOverrides
|
|
798
|
+
}) {
|
|
799
|
+
const key = 'ArrowDown';
|
|
800
|
+
const keyCode = 40;
|
|
801
|
+
|
|
802
|
+
_dom.fireEvent.keyDown(currentElement(), {
|
|
803
|
+
key,
|
|
804
|
+
keyCode,
|
|
805
|
+
which: keyCode,
|
|
806
|
+
...eventOverrides
|
|
807
|
+
});
|
|
808
|
+
|
|
809
|
+
_dom.fireEvent.keyUp(currentElement(), {
|
|
810
|
+
key,
|
|
811
|
+
keyCode,
|
|
812
|
+
which: keyCode,
|
|
813
|
+
...eventOverrides
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
function handleArrowUp({
|
|
818
|
+
currentElement,
|
|
819
|
+
eventOverrides
|
|
820
|
+
}) {
|
|
821
|
+
const key = 'ArrowUp';
|
|
822
|
+
const keyCode = 38;
|
|
823
|
+
|
|
824
|
+
_dom.fireEvent.keyDown(currentElement(), {
|
|
825
|
+
key,
|
|
826
|
+
keyCode,
|
|
827
|
+
which: keyCode,
|
|
828
|
+
...eventOverrides
|
|
829
|
+
});
|
|
830
|
+
|
|
831
|
+
_dom.fireEvent.keyUp(currentElement(), {
|
|
832
|
+
key,
|
|
833
|
+
keyCode,
|
|
834
|
+
which: keyCode,
|
|
835
|
+
...eventOverrides
|
|
836
|
+
});
|
|
791
837
|
}
|