diff --git a/tests/number-field.test.ts b/tests/number-field.test.ts index 0f3b534..784cd6a 100644 --- a/tests/number-field.test.ts +++ b/tests/number-field.test.ts @@ -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);