From 9acb26c7f9f3b34c20a4119cbd0dd4f33a7500b3 Mon Sep 17 00:00:00 2001 From: Aral Roca Date: Sun, 15 Dec 2024 00:24:13 +0100 Subject: [PATCH] fix: fix userEvent.select and deselect to work in new versions of happy-dom --- packages/brisa/src/core/test/api/index.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/brisa/src/core/test/api/index.ts b/packages/brisa/src/core/test/api/index.ts index 38d7e1a21..7e8d88afc 100644 --- a/packages/brisa/src/core/test/api/index.ts +++ b/packages/brisa/src/core/test/api/index.ts @@ -241,17 +241,15 @@ export const userEvent = { }, select: (select: HTMLSelectElement, value: string) => { select.value = value; - // Note: Dispatching 'input' event is also dispatching 'change' event - // in Happy-DOM, so we don't need to dispatch 'change' event separately select.dispatchEvent(new Event('input', { bubbles: true })); + select.dispatchEvent(new Event('change', { bubbles: true })); }, - deselect: (selecgt: HTMLSelectElement, value: string) => { - if (value === selecgt.value) { - selecgt.value = ''; + deselect: (select: HTMLSelectElement, value: string) => { + if (value === select.value) { + select.value = ''; } - // Note: Dispatching 'input' event is also dispatching 'change' event - // in Happy-DOM, so we don't need to dispatch 'change' event separately - selecgt.dispatchEvent(new Event('input', { bubbles: true })); + select.dispatchEvent(new Event('input', { bubbles: true })); + select.dispatchEvent(new Event('change', { bubbles: true })); }, upload: (input: HTMLInputElement, file: File) => { // @ts-ignore