diff --git a/client/src/controllers/ActionController.test.js b/client/src/controllers/ActionController.test.js
index 6b8fdf0e85..94bf3f6a45 100644
--- a/client/src/controllers/ActionController.test.js
+++ b/client/src/controllers/ActionController.test.js
@@ -5,6 +5,15 @@ describe('ActionController', () => {
let app;
const oldWindowLocation = window.location;
+ const setup = async (html) => {
+ document.body.innerHTML = `${html}`;
+
+ app = Application.start();
+ app.register('w-action', ActionController);
+
+ await Promise.resolve();
+ };
+
beforeAll(() => {
delete window.location;
@@ -23,19 +32,16 @@ describe('ActionController', () => {
});
describe('post method', () => {
- beforeEach(() => {
- document.body.innerHTML = `
- `;
-
- app = Application.start();
- app.register('w-action', ActionController);
+ beforeEach(async () => {
+ await setup(`
+ `);
});
it('it should allow for a form POST with created data', () => {
@@ -54,8 +60,8 @@ describe('ActionController', () => {
});
describe('click method', () => {
- beforeEach(() => {
- document.body.innerHTML = `
+ beforeEach(async () => {
+ await setup(`
`;
-
- app = Application.start();
- app.register('w-action', ActionController);
+ `);
});
it('should call click method when button is clicked via Stimulus action', () => {
@@ -84,15 +87,12 @@ describe('ActionController', () => {
});
describe('redirect method', () => {
- beforeEach(() => {
- document.body.innerHTML = `
+ beforeEach(async () => {
+ await setup(`
`;
-
- app = Application.start();
- app.register('w-action', ActionController);
+ `);
});
it('should have a redirect method that falls back to any element value', () => {