test: reproduce NumberField typing regression within one task
This commit is contained in:
@@ -202,9 +202,13 @@ describe("NumberField public contracts", () => {
|
||||
["9", "49"],
|
||||
["0", "490"],
|
||||
] as const) {
|
||||
await input.trigger("keydown", { key });
|
||||
await input.setValue(text);
|
||||
await input.trigger("input");
|
||||
// Keep keydown and text insertion in one task: awaiting trigger() here
|
||||
// would flush the old nextTick(restore) before typing and hide the bug.
|
||||
input.element.dispatchEvent(
|
||||
new KeyboardEvent("keydown", { key, bubbles: true, cancelable: true }),
|
||||
);
|
||||
(input.element as HTMLInputElement).value = text;
|
||||
input.element.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
await nextTick();
|
||||
await nextTick();
|
||||
expect((input.element as HTMLInputElement).value).toBe(text);
|
||||
|
||||
Reference in New Issue
Block a user