Add on_click_outside behavior on dropdown_controller

"It's a Surprise Tool That Will Help Us Later"
This commit is contained in:
Jean-Baptiste Bellet
2023-07-06 15:00:29 +02:00
parent d78af187e0
commit 02aea989be
2 changed files with 22 additions and 0 deletions

View File

@@ -44,5 +44,16 @@ describe("Dropdown controller", () => {
expect(arrow.classList.contains("expandedCLass2")).toBe(true);
expect(arrow.classList.contains("collapsedClass")).toBe(false);
});
it ("hide menu when click outside", () => {
const dropdown = document.getElementById("dropdown");
const menu = document.getElementById("menu");
dropdown.click();
expect(menu.classList.contains("hidden")).toBe(false);
document.body.click();
expect(menu.classList.contains("hidden")).toBe(true);
});
});
});