From 930ef98a893e0d42813e00ea5b63b6cc6a07e3c1 Mon Sep 17 00:00:00 2001 From: Aral Roca Gomez Date: Sun, 15 Dec 2024 00:27:30 +0100 Subject: [PATCH] fix: fix userEvent.select and deselect to work in new versions of happy-dom (#681) --- 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