mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-22 05:18:51 +00:00
Only initialise Stimulus app once in Jest tests in :beforeAll rather than :beforeEach
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>
This commit is contained in:
@@ -6,13 +6,18 @@ import { Application } from "stimulus";
|
||||
import paymentmethod_controller from "../../../app/webpacker/controllers/paymentmethod_controller";
|
||||
|
||||
describe("PaymentmethodController", () => {
|
||||
beforeAll(() => {
|
||||
const application = Application.start();
|
||||
application.register("paymentmethod", paymentmethod_controller);
|
||||
});
|
||||
|
||||
describe("#selectPaymentMethod", () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = `<div data-controller="paymentmethod">
|
||||
<input id="paymentmethod_1" data-action="click->paymentmethod#selectPaymentMethod" data-paymentmethod-id="paymentmethod1" data-paymentmethod-target="input" />
|
||||
<input id="paymentmethod_2" data-action="click->paymentmethod#selectPaymentMethod" data-paymentmethod-id="paymentmethod2" data-paymentmethod-target="input" checked="checked" />
|
||||
<input id="paymentmethod_3" data-action="click->paymentmethod#selectPaymentMethod" data-paymentmethod-id="paymentmethod3" data-paymentmethod-target="input"/>
|
||||
|
||||
|
||||
<div class="paymentmethod-container" id="paymentmethod1">
|
||||
<input type="number" id="input1" />
|
||||
<select id="select1" >
|
||||
@@ -32,9 +37,6 @@ describe("PaymentmethodController", () => {
|
||||
</select>
|
||||
</div>
|
||||
</div>`;
|
||||
|
||||
const application = Application.start();
|
||||
application.register("paymentmethod", paymentmethod_controller);
|
||||
});
|
||||
|
||||
it("fill the right payment container", () => {
|
||||
|
||||
Reference in New Issue
Block a user