mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
Before there was an issue with the remote_toggle_controller tests, which contains two tests. If you commented out one test and ran the other it would pass and vice versa but if both tests were uncommented only the first test would ever pass, the second one would fail. See https://github.com/openfoodfoundation/openfoodnetwork/pull/8805#discussion_r801464322 Co-authored-by: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com>
35 lines
936 B
JavaScript
35 lines
936 B
JavaScript
/**
|
|
* @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");
|
|
});
|
|
});
|
|
});
|