mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-06 22:36:07 +00:00
Hide popout when checkbox is checked
This commit is contained in:
@@ -17,7 +17,7 @@ describe("PopoutController", () => {
|
||||
<button id="button" data-popout-target="button">On demand</button>
|
||||
<div id="dialog" data-popout-target="dialog" style="display: none;">
|
||||
<input id="input1">
|
||||
<input id="input2">
|
||||
<input id="input2" type="checkbox" data-action="change->popout#closeIfChecked">
|
||||
</div>
|
||||
</div>
|
||||
<input id="input3">
|
||||
@@ -72,6 +72,21 @@ describe("PopoutController", () => {
|
||||
|
||||
expect(dialog.style.display).toBe("block"); // visible
|
||||
});
|
||||
|
||||
it("closes the dialog when checkbox is checked", () => {
|
||||
input2.click();
|
||||
|
||||
expect(dialog.style.display).toBe("none"); // not visible
|
||||
});
|
||||
|
||||
it("doesn't close the dialog when checkbox is unchecked", () => {
|
||||
input2.click();
|
||||
button.dispatchEvent(new Event("click")); // Dialog is opened again
|
||||
input2.click();
|
||||
|
||||
expect(input2.checked).toBe(false);
|
||||
expect(dialog.style.display).toBe("block"); // visible
|
||||
});
|
||||
});
|
||||
|
||||
describe("Cleaning up", () => {
|
||||
|
||||
Reference in New Issue
Block a user