@testing-library/user-event 11.4.1 β 11.4.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/README.md +4 -1
- package/dist/type.js +21 -4
- package/package.json +2 -5
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
[![MIT License][license-badge]][license]
|
|
24
24
|
|
|
25
25
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
26
|
-
[](#contributors-)
|
|
27
27
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
28
28
|
[![PRs Welcome][prs-badge]][prs]
|
|
29
29
|
[![Code of Conduct][coc-badge]][coc]
|
|
@@ -510,6 +510,9 @@ Thanks goes to these people ([emoji key][emojis]):
|
|
|
510
510
|
<td align="center"><a href="https://hung.dev"><img src="https://avatars3.githubusercontent.com/u/8603085?v=4" width="100px;" alt=""/><br /><sub><b>Hung Viet Nguyen</b></sub></a><br /><a href="https://github.com/testing-library/user-event/issues?q=author%3Anvh95" title="Bug reports">π</a></td>
|
|
511
511
|
<td align="center"><a href="https://nickmccurdy.com/"><img src="https://avatars0.githubusercontent.com/u/927220?v=4" width="100px;" alt=""/><br /><sub><b>Nick McCurdy</b></sub></a><br /><a href="#projectManagement-nickmccurdy" title="Project Management">π</a> <a href="#question-nickmccurdy" title="Answering Questions">π¬</a> <a href="https://github.com/testing-library/user-event/commits?author=nickmccurdy" title="Code">π»</a> <a href="https://github.com/testing-library/user-event/commits?author=nickmccurdy" title="Tests">β οΈ</a></td>
|
|
512
512
|
</tr>
|
|
513
|
+
<tr>
|
|
514
|
+
<td align="center"><a href="http://timdeschryver.dev"><img src="https://avatars1.githubusercontent.com/u/28659384?v=4" width="100px;" alt=""/><br /><sub><b>Tim Deschryver</b></sub></a><br /><a href="https://github.com/testing-library/user-event/commits?author=timdeschryver" title="Tests">β οΈ</a></td>
|
|
515
|
+
</tr>
|
|
513
516
|
</table>
|
|
514
517
|
|
|
515
518
|
<!-- markdownlint-enable -->
|
package/dist/type.js
CHANGED
|
@@ -252,7 +252,7 @@ async function typeImpl(element, text, {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
const eventOverrides = {};
|
|
255
|
-
let prevWasMinus;
|
|
255
|
+
let prevWasMinus, prevWasPeriod;
|
|
256
256
|
|
|
257
257
|
for (const callback of eventCallbacks) {
|
|
258
258
|
if (delay > 0) await wait(delay);
|
|
@@ -260,10 +260,12 @@ async function typeImpl(element, text, {
|
|
|
260
260
|
if (!currentElement().disabled) {
|
|
261
261
|
const returnValue = await callback({
|
|
262
262
|
prevWasMinus,
|
|
263
|
+
prevWasPeriod,
|
|
263
264
|
eventOverrides
|
|
264
265
|
});
|
|
265
266
|
Object.assign(eventOverrides, returnValue == null ? void 0 : returnValue.eventOverrides);
|
|
266
267
|
prevWasMinus = returnValue == null ? void 0 : returnValue.prevWasMinus;
|
|
268
|
+
prevWasPeriod = returnValue == null ? void 0 : returnValue.prevWasPeriod;
|
|
267
269
|
}
|
|
268
270
|
}
|
|
269
271
|
}
|
|
@@ -391,12 +393,13 @@ async function typeImpl(element, text, {
|
|
|
391
393
|
|
|
392
394
|
async function typeCharacter(char, {
|
|
393
395
|
prevWasMinus = false,
|
|
396
|
+
prevWasPeriod = false,
|
|
394
397
|
eventOverrides
|
|
395
398
|
}) {
|
|
396
399
|
const key = char; // TODO: check if this also valid for characters with diacritic markers e.g. ΓΊΓ© etc
|
|
397
400
|
|
|
398
401
|
const keyCode = char.charCodeAt(0);
|
|
399
|
-
let nextPrevWasMinus;
|
|
402
|
+
let nextPrevWasMinus, nextPrevWasPeriod;
|
|
400
403
|
|
|
401
404
|
const keyDownDefaultNotPrevented = _dom.fireEvent.keyDown(currentElement(), {
|
|
402
405
|
key,
|
|
@@ -416,7 +419,14 @@ async function typeImpl(element, text, {
|
|
|
416
419
|
});
|
|
417
420
|
|
|
418
421
|
if (keyPressDefaultNotPrevented) {
|
|
419
|
-
|
|
422
|
+
let newEntry = char;
|
|
423
|
+
|
|
424
|
+
if (prevWasMinus) {
|
|
425
|
+
newEntry = `-${char}`;
|
|
426
|
+
} else if (prevWasPeriod) {
|
|
427
|
+
newEntry = `.${char}`;
|
|
428
|
+
}
|
|
429
|
+
|
|
420
430
|
const {
|
|
421
431
|
prevValue
|
|
422
432
|
} = await fireInputEventIfNeeded({ ...calculateNewValue(newEntry),
|
|
@@ -439,6 +449,12 @@ async function typeImpl(element, text, {
|
|
|
439
449
|
} else {
|
|
440
450
|
nextPrevWasMinus = newEntry === '-';
|
|
441
451
|
}
|
|
452
|
+
|
|
453
|
+
if (newValue === prevValue && newEntry !== '.') {
|
|
454
|
+
nextPrevWasPeriod = prevWasPeriod;
|
|
455
|
+
} else {
|
|
456
|
+
nextPrevWasPeriod = newEntry === '.';
|
|
457
|
+
}
|
|
442
458
|
}
|
|
443
459
|
}
|
|
444
460
|
}
|
|
@@ -453,7 +469,8 @@ async function typeImpl(element, text, {
|
|
|
453
469
|
});
|
|
454
470
|
|
|
455
471
|
return {
|
|
456
|
-
prevWasMinus: nextPrevWasMinus
|
|
472
|
+
prevWasMinus: nextPrevWasMinus,
|
|
473
|
+
prevWasPeriod: nextPrevWasPeriod
|
|
457
474
|
};
|
|
458
475
|
}
|
|
459
476
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/user-event",
|
|
3
|
-
"version": "11.4.
|
|
3
|
+
"version": "11.4.2",
|
|
4
4
|
"description": "Fire events the same way the user does",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "typings/index.d.ts",
|
|
@@ -43,11 +43,8 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@testing-library/dom": "^7.9.0",
|
|
45
45
|
"@testing-library/jest-dom": "^5.9.0",
|
|
46
|
-
"@testing-library/react": "^10.2.1",
|
|
47
46
|
"is-ci": "^2.0.0",
|
|
48
|
-
"kcd-scripts": "^6.2.
|
|
49
|
-
"react": "^16.13.1",
|
|
50
|
-
"react-dom": "^16.13.1"
|
|
47
|
+
"kcd-scripts": "^6.2.3"
|
|
51
48
|
},
|
|
52
49
|
"peerDependencies": {
|
|
53
50
|
"@testing-library/dom": ">=7.9.0"
|