Replace toggle_controller with method inside generic ctrller

- move toggle method from toggle_controller inside toggle_control
    ctrller
  - change corresponding html attributes in view
  - mode corresponding spec in toggle_controller ctrller spec
  - delete now unused toggle controller + spec
This commit is contained in:
cyrillefr
2024-01-25 10:08:53 +01:00
parent a005069394
commit e6c0afa477
5 changed files with 32 additions and 52 deletions

View File

@@ -88,4 +88,24 @@ describe("ToggleControlController", () => {
});
});
});
describe("#toggleDisplay", () => {
beforeEach(() => {
document.body.innerHTML = `<div data-controller="toggle-control">
<span id="button" data-action="click->toggle-control#toggleDisplay" data-toggle-show="true" />
<div id="content" data-toggle-control-target="content" >
content
</div>
</div>`;
});
it("toggles the content", () => {
const button = document.getElementById("button");
const content = document.getElementById("content");
expect(content.style.display).toBe("");
button.click();
expect(content.style.display).toBe("block");
});
});
});