mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-27 06:05:19 +00:00
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:
@@ -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");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/**
|
||||
* @jest-environment jsdom
|
||||
*/
|
||||
|
||||
import { Application } from "stimulus";
|
||||
import toggle_controller from "../../../app/webpacker/controllers/toggle_controller";
|
||||
|
||||
describe("ToggleController", () => {
|
||||
beforeAll(() => {
|
||||
const application = Application.start();
|
||||
application.register("toggle", toggle_controller);
|
||||
});
|
||||
|
||||
describe("#toggle", () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `<div data-controller="toggle">
|
||||
<span id="button" data-action="click->toggle#toggle" data-toggle-show="true" />
|
||||
<div id="content" data-toggle-target="content" >
|
||||
content
|
||||
</div>
|
||||
</div>`;
|
||||
});
|
||||
|
||||
it("toggle 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");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user