@testing-library/user-event 12.2.2 → 12.6.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 CHANGED
@@ -47,6 +47,7 @@ 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
+
50
51
  - [Installation](#installation)
51
52
  - [API](#api)
52
53
  - [`click(element, eventInit, options)`](#clickelement-eventinit-options)
@@ -60,6 +61,7 @@ change the state of the checkbox.
60
61
  - [`hover(element)`](#hoverelement)
61
62
  - [`unhover(element)`](#unhoverelement)
62
63
  - [`paste(element, text, eventInit, options)`](#pasteelement-text-eventinit-options)
64
+ - [`specialChars`](#specialchars)
63
65
  - [Issues](#issues)
64
66
  - [🐛 Bugs](#-bugs)
65
67
  - [💡 Feature Requests](#-feature-requests)
@@ -89,11 +91,16 @@ import userEvent from '@testing-library/user-event'
89
91
 
90
92
  // or
91
93
 
92
- var userEvent = require('@testing-library/user-event')
94
+ const {default: userEvent} = require('@testing-library/user-event')
93
95
  ```
94
96
 
95
97
  ## API
96
98
 
99
+ Note: All userEvent methods are synchronous with one exception: when `delay`
100
+ with `userEvent.type` as described below). We also discourage using `userEvent`
101
+ inside `before/after` blocks at all, for important reasons described in
102
+ ["Avoid Nesting When You're Testing"](https://kentcdodds.com/blog/avoid-nesting-when-youre-testing).
103
+
97
104
  ### `click(element, eventInit, options)`
98
105
 
99
106
  Clicks `element`, depending on what `element` is it can have different side
@@ -183,20 +190,23 @@ to `await`!
183
190
 
184
191
  The following special character strings are supported:
185
192
 
186
- | Text string | Key | Modifier | Notes |
187
- | -------------- | ---------- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
188
- | `{enter}` | Enter | N/A | Will insert a newline character (`<textarea />` only). |
189
- | `{space}` | `' '` | N/A | |
190
- | `{esc}` | Escape | N/A | |
191
- | `{backspace}` | Backspace | N/A | Will delete the previous character (or the characters within the `selectedRange`, see example below). |
192
- | `{del}` | Delete | N/A | Will delete the next character (or the characters within the `selectedRange`, see example below) |
193
- | `{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) |
194
- | `{arrowleft}` | ArrowLeft | N/A | |
195
- | `{arrowright}` | ArrowRight | N/A | |
196
- | `{shift}` | Shift | `shiftKey` | Does **not** capitalize following characters. |
197
- | `{ctrl}` | Control | `ctrlKey` | |
198
- | `{alt}` | Alt | `altKey` | |
199
- | `{meta}` | OS | `metaKey` | |
193
+ | Text string | Key | Modifier | Notes |
194
+ | -------------- | ---------- | ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
195
+ | `{enter}` | Enter | N/A | Will insert a newline character (`<textarea />` only). |
196
+ | `{space}` | `' '` | N/A | |
197
+ | `{esc}` | Escape | N/A | |
198
+ | `{backspace}` | Backspace | N/A | Will delete the previous character (or the characters within the `selectedRange`, see example below). |
199
+ | `{del}` | Delete | N/A | Will delete the next character (or the characters within the `selectedRange`, see example below) |
200
+ | `{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) |
201
+ | `{arrowleft}` | ArrowLeft | N/A | |
202
+ | `{arrowright}` | ArrowRight | N/A | |
203
+ | `{arrowup}` | ArrowUp | N/A | |
204
+ | `{arrowdown}` | ArrowDown | N/A | |
205
+ | `{shift}` | Shift | `shiftKey` | Does **not** capitalize following characters. |
206
+ | `{ctrl}` | Control | `ctrlKey` | |
207
+ | `{alt}` | Alt | `altKey` | |
208
+ | `{meta}` | OS | `metaKey` | |
209
+ | `{capslock}` | CapsLock | `modifierCapsLock` | Fires both keydown and keyup when used (simulates a user clicking their "Caps Lock" button to enable caps lock). |
200
210
 
201
211
  > **A note about modifiers:** Modifier keys (`{shift}`, `{ctrl}`, `{alt}`,
202
212
  > `{meta}`) will activate their corresponding event modifiers for the duration
@@ -234,6 +244,32 @@ test('delete characters within the selectedRange', () => {
234
244
  })
235
245
  ```
236
246
 
247
+ #### <input type="time" /> support
248
+
249
+ The following is an example of usage of this library with
250
+ `<input type="time" />`
251
+
252
+ ```jsx
253
+ import React from 'react
254
+ import {render, screen} from '@testing-library/react'
255
+ import userEvent from '@testing-library/user-event'
256
+
257
+ test('types into the input', () => {
258
+ render(
259
+ <>
260
+ <label for="time">Enter a time</label>
261
+ <input
262
+ type="time"
263
+ id="time"
264
+ />
265
+ </>
266
+ )
267
+ const input = screen.getByLabelText(/enter a time/i)
268
+ userEvent.type(input, '13:58')
269
+ expect(input.value).toBe('13:58')
270
+ })
271
+ ```
272
+
237
273
  ### `upload(element, file, [{ clickInit, changeInit }])`
238
274
 
239
275
  Uploads file to an `<input>`. For uploading multiple files use `<input>` with
@@ -485,6 +521,47 @@ test('should paste text in input', () => {
485
521
  You can use the `eventInit` if what you're pasting should have `clipboardData`
486
522
  (like `files`).
487
523
 
524
+ ### `specialChars`
525
+
526
+ A handful set of special characters used in [type](#typeelement-text-options)
527
+ method.
528
+
529
+ | Key | Character |
530
+ | ---------- | -------------- |
531
+ | arrowLeft | `{arrowleft}` |
532
+ | arrowRight | `{arrowright}` |
533
+ | arrowDown | `{arrowdown}` |
534
+ | arrowUp | `{arrowup}` |
535
+ | enter | `{enter}` |
536
+ | escape | `{esc}` |
537
+ | delete | `{del}` |
538
+ | backspace | `{backspace}` |
539
+ | selectAll | `{selectall}` |
540
+ | space | `{space}` |
541
+ | whitespace | `' '` |
542
+
543
+ Usage example:
544
+
545
+ ```jsx
546
+ import React from 'react'
547
+ import {render, screen} from '@testing-library/react'
548
+ import userEvent, {specialChars} from '@testing-library/user-event'
549
+
550
+ test('delete characters within the selectedRange', () => {
551
+ render(
552
+ <div>
553
+ <label htmlFor="my-input">Example:</label>
554
+ <input id="my-input" type="text" value="This is a bad example" />
555
+ </div>,
556
+ )
557
+ const input = screen.getByLabelText(/example/i)
558
+ input.setSelectionRange(10, 13)
559
+ userEvent.type(input, `${specialChars.backspace}good`)
560
+
561
+ expect(input).toHaveValue('This is a good example')
562
+ })
563
+ ```
564
+
488
565
  ## Issues
489
566
 
490
567
  _Looking to contribute? Look for the [Good First Issue][good-first-issue]
@@ -597,6 +674,12 @@ Thanks goes to these people ([emoji key][emojis]):
597
674
  <td align="center"><a href="https://github.com/jesujcastillom"><img src="https://avatars3.githubusercontent.com/u/7827281?v=4" width="100px;" alt=""/><br /><sub><b>Jesu Castillo</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=jesujcastillom" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=jesujcastillom" title="Tests">⚠️</a></td>
598
675
  <td align="center"><a href="https://sarahdayan.dev"><img src="https://avatars1.githubusercontent.com/u/5370675?v=4" width="100px;" alt=""/><br /><sub><b>Sarah Dayan</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=sarahdayan" title="Documentation">📖</a></td>
599
676
  <td align="center"><a href="http://saul-mirone.github.io/"><img src="https://avatars0.githubusercontent.com/u/10047788?v=4" width="100px;" alt=""/><br /><sub><b>Mirone</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3ASaul-Mirone" title="Bug reports">🐛</a></td>
677
+ <td align="center"><a href="https://github.com/amandapouget"><img src="https://avatars3.githubusercontent.com/u/12855692?v=4" width="100px;" alt=""/><br /><sub><b>Amanda Pouget</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=amandapouget" title="Documentation">📖</a></td>
678
+ <td align="center"><a href="https://github.com/Sonic12040"><img src="https://avatars3.githubusercontent.com/u/21055893?v=4" width="100px;" alt=""/><br /><sub><b>Sonic12040</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=Sonic12040" title="Documentation">📖</a></td>
679
+ <td align="center"><a href="https://github.com/gndelia"><img src="https://avatars1.githubusercontent.com/u/352474?v=4" width="100px;" alt=""/><br /><sub><b>Gonzalo D'Elia</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Tests">⚠️</a> <a href="https://github.com/testing-library/user-event/commits?author=gndelia" title="Documentation">📖</a></td>
680
+ </tr>
681
+ <tr>
682
+ <td align="center"><a href="https://github.com/vasilii-kovalev"><img src="https://avatars0.githubusercontent.com/u/10310491?v=4" width="100px;" alt=""/><br /><sub><b>Vasilii Kovalev</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=vasilii-kovalev" title="Code">💻</a> <a href="https://github.com/testing-library/user-event/commits?author=vasilii-kovalev" title="Documentation">📖</a></td>
600
683
  </tr>
601
684
  </table>
602
685
 
@@ -614,7 +697,7 @@ MIT
614
697
  <!-- prettier-ignore-start -->
615
698
  [npm]: https://www.npmjs.com
616
699
  [node]: https://nodejs.org
617
- [build-badge]: https://img.shields.io/github/workflow/status/testing-library/user-event/validate/main?logo=github&style=flat-square
700
+ [build-badge]: https://img.shields.io/github/workflow/status/testing-library/user-event/validate/master?logo=github&style=flat-square
618
701
  [build]: https://github.com/testing-library/user-event/actions?query=workflow%3Avalidate
619
702
  [coverage-badge]: https://img.shields.io/codecov/c/github/testing-library/user-event.svg?style=flat-square
620
703
  [coverage]: https://codecov.io/github/testing-library/user-event
package/dist/click.js CHANGED
@@ -88,7 +88,7 @@ function clickElement(element, init, {
88
88
  _dom.fireEvent.click(element, (0, _utils.getMouseEventOptions)('click', init, clickCount));
89
89
 
90
90
  const parentLabel = element.closest('label');
91
- if (parentLabel == null ? void 0 : parentLabel.control) (0, _focus.focus)(parentLabel.control, init);
91
+ if (parentLabel != null && parentLabel.control) (0, _focus.focus)(parentLabel.control, init);
92
92
  }
93
93
  }
94
94
 
package/dist/index.js CHANGED
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "specialChars", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _type.specialCharMap;
10
+ }
11
+ });
6
12
  exports.default = void 0;
7
13
 
8
14
  var _click = require("./click");
package/dist/type.js CHANGED
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.type = type;
7
+ exports.specialCharMap = void 0;
7
8
 
8
9
  var _dom = require("@testing-library/dom");
9
10
 
@@ -37,18 +38,91 @@ const modifierCallbackMap = { ...createModifierCallbackEntries({
37
38
  key: 'Meta',
38
39
  keyCode: 93,
39
40
  modifierProperty: 'metaKey'
40
- })
41
+ }),
42
+ // capslock is inline because of the need to fire both keydown and keyup on use, while preserving the modifier state.
43
+ '{capslock}': function ({
44
+ currentElement,
45
+ eventOverrides
46
+ }) {
47
+ const newEventOverrides = {
48
+ modifierCapsLock: true
49
+ };
50
+
51
+ _dom.fireEvent.keyDown(currentElement(), {
52
+ key: 'CapsLock',
53
+ keyCode: 20,
54
+ which: 20,
55
+ ...eventOverrides,
56
+ ...newEventOverrides
57
+ });
58
+
59
+ _dom.fireEvent.keyUp(currentElement(), {
60
+ key: 'CapsLock',
61
+ keyCode: 20,
62
+ which: 20,
63
+ ...eventOverrides,
64
+ ...newEventOverrides
65
+ });
66
+
67
+ return {
68
+ eventOverrides: newEventOverrides
69
+ };
70
+ },
71
+ '{/capslock}': function ({
72
+ currentElement,
73
+ eventOverrides
74
+ }) {
75
+ const newEventOverrides = {
76
+ modifierCapsLock: false
77
+ };
78
+
79
+ _dom.fireEvent.keyDown(currentElement(), {
80
+ key: 'CapsLock',
81
+ keyCode: 20,
82
+ which: 20,
83
+ ...eventOverrides,
84
+ ...newEventOverrides
85
+ });
86
+
87
+ _dom.fireEvent.keyUp(currentElement(), {
88
+ key: 'CapsLock',
89
+ keyCode: 20,
90
+ which: 20,
91
+ ...eventOverrides,
92
+ ...newEventOverrides
93
+ });
94
+
95
+ return {
96
+ eventOverrides: newEventOverrides
97
+ };
98
+ }
99
+ };
100
+ const specialCharMap = {
101
+ arrowLeft: '{arrowleft}',
102
+ arrowRight: '{arrowright}',
103
+ arrowDown: '{arrowdown}',
104
+ arrowUp: '{arrowup}',
105
+ enter: '{enter}',
106
+ escape: '{esc}',
107
+ delete: '{del}',
108
+ backspace: '{backspace}',
109
+ selectAll: '{selectall}',
110
+ space: '{space}',
111
+ whitespace: ' '
41
112
  };
113
+ exports.specialCharMap = specialCharMap;
42
114
  const specialCharCallbackMap = {
43
- '{arrowleft}': (0, _navigationKey.navigationKey)('ArrowLeft'),
44
- '{arrowright}': (0, _navigationKey.navigationKey)('ArrowRight'),
45
- '{enter}': handleEnter,
46
- '{esc}': handleEsc,
47
- '{del}': handleDel,
48
- '{backspace}': handleBackspace,
49
- '{selectall}': handleSelectall,
50
- '{space}': handleSpace,
51
- ' ': handleSpace
115
+ [specialCharMap.arrowLeft]: (0, _navigationKey.navigationKey)('ArrowLeft'),
116
+ [specialCharMap.arrowRight]: (0, _navigationKey.navigationKey)('ArrowRight'),
117
+ [specialCharMap.arrowDown]: handleArrowDown,
118
+ [specialCharMap.arrowUp]: handleArrowUp,
119
+ [specialCharMap.enter]: handleEnter,
120
+ [specialCharMap.escape]: handleEsc,
121
+ [specialCharMap.delete]: handleDel,
122
+ [specialCharMap.backspace]: handleBackspace,
123
+ [specialCharMap.selectAll]: handleSelectall,
124
+ [specialCharMap.space]: handleSpace,
125
+ [specialCharMap.whitespace]: handleSpace
52
126
  };
53
127
 
54
128
  function wait(time) {
@@ -324,6 +398,12 @@ function typeCharacter(char, {
324
398
  newEntry = textToBeTyped;
325
399
  }
326
400
 
401
+ const timeNewEntry = (0, _utils.buildTimeValue)(textToBeTyped);
402
+
403
+ if ((0, _utils.isValidInputTimeValue)(currentElement(), timeNewEntry)) {
404
+ newEntry = timeNewEntry;
405
+ }
406
+
327
407
  const inputEvent = fireInputEventIfNeeded({ ...(0, _utils.calculateNewValue)(newEntry, currentElement()),
328
408
  eventOverrides: {
329
409
  data: key,
@@ -340,14 +420,15 @@ function typeCharacter(char, {
340
420
  value: textToBeTyped
341
421
  }
342
422
  });
343
- } // typing "-" into a number input will not actually update the value
423
+ }
424
+
425
+ fireChangeForInputTimeIfValid(currentElement, prevValue, timeNewEntry); // typing "-" into a number input will not actually update the value
344
426
  // so for the next character we type, the value should be set to
345
427
  // `-${newEntry}`
346
428
  // we also preserve the prevWasMinus when the value is unchanged due
347
429
  // to typing an invalid character (typing "-a3" results in "-3")
348
430
  // same applies for the decimal character.
349
431
 
350
-
351
432
  if (currentElement().type === 'number') {
352
433
  const newValue = (0, _utils.getValue)(currentElement());
353
434
 
@@ -379,6 +460,16 @@ function typeCharacter(char, {
379
460
  prevValue,
380
461
  typedValue: textToBeTyped
381
462
  };
463
+ }
464
+
465
+ function fireChangeForInputTimeIfValid(currentElement, prevValue, timeNewEntry) {
466
+ if ((0, _utils.isValidInputTimeValue)(currentElement(), timeNewEntry) && prevValue !== timeNewEntry) {
467
+ _dom.fireEvent.change(currentElement(), {
468
+ target: {
469
+ value: timeNewEntry
470
+ }
471
+ });
472
+ }
382
473
  } // yes, calculateNewBackspaceValue and calculateNewValue look extremely similar
383
474
  // and you may be tempted to create a shared abstraction.
384
475
  // If you, brave soul, decide to so endevor, please increment this count
@@ -714,4 +805,48 @@ function handleSpaceOnClickable({
714
805
  _dom.fireEvent.click(currentElement(), { ...eventOverrides
715
806
  });
716
807
  }
808
+ }
809
+
810
+ function handleArrowDown({
811
+ currentElement,
812
+ eventOverrides
813
+ }) {
814
+ const key = 'ArrowDown';
815
+ const keyCode = 40;
816
+
817
+ _dom.fireEvent.keyDown(currentElement(), {
818
+ key,
819
+ keyCode,
820
+ which: keyCode,
821
+ ...eventOverrides
822
+ });
823
+
824
+ _dom.fireEvent.keyUp(currentElement(), {
825
+ key,
826
+ keyCode,
827
+ which: keyCode,
828
+ ...eventOverrides
829
+ });
830
+ }
831
+
832
+ function handleArrowUp({
833
+ currentElement,
834
+ eventOverrides
835
+ }) {
836
+ const key = 'ArrowUp';
837
+ const keyCode = 38;
838
+
839
+ _dom.fireEvent.keyDown(currentElement(), {
840
+ key,
841
+ keyCode,
842
+ which: keyCode,
843
+ ...eventOverrides
844
+ });
845
+
846
+ _dom.fireEvent.keyUp(currentElement(), {
847
+ key,
848
+ keyCode,
849
+ which: keyCode,
850
+ ...eventOverrides
851
+ });
717
852
  }
package/dist/utils.js CHANGED
@@ -12,6 +12,8 @@ exports.calculateNewValue = calculateNewValue;
12
12
  exports.setSelectionRangeIfNecessary = setSelectionRangeIfNecessary;
13
13
  exports.eventWrapper = eventWrapper;
14
14
  exports.isValidDateValue = isValidDateValue;
15
+ exports.isValidInputTimeValue = isValidInputTimeValue;
16
+ exports.buildTimeValue = buildTimeValue;
15
17
  exports.getValue = getValue;
16
18
  exports.getSelectionRange = getSelectionRange;
17
19
  exports.isContentEditable = isContentEditable;
@@ -95,7 +97,7 @@ function isLabelWithInternallyDisabledControl(element) {
95
97
  function getActiveElement(document) {
96
98
  const activeElement = document.activeElement;
97
99
 
98
- if (activeElement == null ? void 0 : activeElement.shadowRoot) {
100
+ if (activeElement != null && activeElement.shadowRoot) {
99
101
  return getActiveElement(activeElement.shadowRoot);
100
102
  } else {
101
103
  return activeElement;
@@ -185,6 +187,14 @@ function calculateNewValue(newEntry, element) {
185
187
  newValue = value;
186
188
  }
187
189
 
190
+ if (element.type === 'time' && !isValidInputTimeValue(element, newValue)) {
191
+ if (isValidInputTimeValue(element, newEntry)) {
192
+ newValue = newEntry;
193
+ } else {
194
+ newValue = value;
195
+ }
196
+ }
197
+
188
198
  if (!supportsMaxLength(element) || maxLength < 0) {
189
199
  return {
190
200
  newValue,
@@ -249,4 +259,49 @@ function isValidDateValue(element, value) {
249
259
  const clone = element.cloneNode();
250
260
  clone.value = value;
251
261
  return clone.value === value;
262
+ }
263
+
264
+ function buildTimeValue(value) {
265
+ function build(onlyDigitsValue, index) {
266
+ const hours = onlyDigitsValue.slice(0, index);
267
+ const validHours = Math.min(parseInt(hours, 10), 23);
268
+ const minuteCharacters = onlyDigitsValue.slice(index);
269
+ const parsedMinutes = parseInt(minuteCharacters, 10);
270
+ const validMinutes = Math.min(parsedMinutes, 59);
271
+ return `${validHours.toString().padStart(2, '0')}:${validMinutes.toString().padStart(2, '0')}`;
272
+ }
273
+
274
+ const onlyDigitsValue = value.replace(/\D/g, '');
275
+
276
+ if (onlyDigitsValue.length < 2) {
277
+ return value;
278
+ }
279
+
280
+ const firstDigit = parseInt(onlyDigitsValue[0], 10);
281
+ const secondDigit = parseInt(onlyDigitsValue[1], 10);
282
+
283
+ if (firstDigit >= 3 || firstDigit === 2 && secondDigit >= 4) {
284
+ let index;
285
+
286
+ if (firstDigit >= 3) {
287
+ index = 1;
288
+ } else {
289
+ index = 2;
290
+ }
291
+
292
+ return build(onlyDigitsValue, index);
293
+ }
294
+
295
+ if (value.length === 2) {
296
+ return value;
297
+ }
298
+
299
+ return build(onlyDigitsValue, 2);
300
+ }
301
+
302
+ function isValidInputTimeValue(element, timeValue) {
303
+ if (element.type !== 'time') return false;
304
+ const clone = element.cloneNode();
305
+ clone.value = timeValue;
306
+ return clone.value === timeValue;
252
307
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/user-event",
3
- "version": "12.2.2",
3
+ "version": "12.6.0",
4
4
  "description": "Fire events the same way the user does",
5
5
  "main": "dist/index.js",
6
6
  "typings": "typings/index.d.ts",
@@ -36,19 +36,19 @@
36
36
  "test:debug": "kcd-scripts --inspect-brk test --runInBand",
37
37
  "test:update": "npm test -- --updateSnapshot --coverage",
38
38
  "validate": "kcd-scripts validate",
39
- "typecheck": "tsc --project typings"
39
+ "typecheck": "kcd-scripts typecheck --build typings"
40
40
  },
41
41
  "dependencies": {
42
- "@babel/runtime": "^7.10.2"
42
+ "@babel/runtime": "^7.12.5"
43
43
  },
44
44
  "devDependencies": {
45
- "@testing-library/dom": "^7.21.4",
46
- "@testing-library/jest-dom": "^5.11.1",
45
+ "@testing-library/dom": "^7.28.1",
46
+ "@testing-library/jest-dom": "^5.11.6",
47
47
  "@types/estree": "0.0.45",
48
48
  "is-ci": "^2.0.0",
49
49
  "jest-serializer-ansi": "^1.0.3",
50
- "kcd-scripts": "^6.2.3",
51
- "typescript": "^4.0.5"
50
+ "kcd-scripts": "^7.5.1",
51
+ "typescript": "^4.1.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@testing-library/dom": ">=7.21.4"
@@ -57,6 +57,7 @@ declare const userEvent: {
57
57
  element: TargetElement,
58
58
  text: string,
59
59
  userOpts?: T,
60
+ // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
60
61
  ) => T extends {delay: number} ? Promise<void> : void
61
62
  tab: (userOpts?: ITabUserOptions) => void
62
63
  paste: (
@@ -73,3 +74,17 @@ declare const userEvent: {
73
74
  }
74
75
 
75
76
  export default userEvent
77
+
78
+ export enum specialChars {
79
+ arrowLeft = '{arrowleft}',
80
+ arrowRight = '{arrowright}',
81
+ arrowDown = '{arrowdown}',
82
+ arrowUp = '{arrowup}',
83
+ enter = '{enter}',
84
+ escape = '{esc}',
85
+ delete = '{del}',
86
+ backspace = '{backspace}',
87
+ selectAll = '{selectall}',
88
+ space = '{space}',
89
+ whitespace = ' ',
90
+ }