mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-23 20:26:49 +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>
33 lines
962 B
JavaScript
33 lines
962 B
JavaScript
/**
|
|
* @jest-environment jsdom
|
|
*/
|
|
|
|
import { Application } from "stimulus";
|
|
import updateinput_controller from "../../../app/webpacker/controllers/updateinput_controller";
|
|
|
|
describe("updateInput controller", () => {
|
|
beforeAll(() => {
|
|
const application = Application.start();
|
|
application.register("updateinput", updateinput_controller);
|
|
});
|
|
|
|
describe("#update", () => {
|
|
beforeEach(() => {
|
|
document.body.innerHTML = `<form data-controller="updateinput">
|
|
<input id="input" type="hidden" value="false" data-updateinput-target="input" />
|
|
<div id="submit" data-action="click->updateinput#update" data-updateinput-value="true" />
|
|
</form>`;
|
|
});
|
|
|
|
it("update the input value", () => {
|
|
const submit = document.getElementById("submit");
|
|
const input = document.getElementById("input");
|
|
expect(input.value).toBe("false");
|
|
|
|
submit.click();
|
|
|
|
expect(input.value).toBe("true");
|
|
});
|
|
});
|
|
});
|