From ca7fa798f8d1a98652f814e830869747d10d57de Mon Sep 17 00:00:00 2001 From: MariaAga Date: Fri, 13 Sep 2024 17:41:09 +0100 Subject: [PATCH] Fixes #37821 - fix axios mock --- webpack/assets/javascripts/react_app/mockRequests.js | 9 +++------ .../react_app/redux/actions/common/forms.test.js | 4 ---- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/webpack/assets/javascripts/react_app/mockRequests.js b/webpack/assets/javascripts/react_app/mockRequests.js index 954b7cb8518..156866745ea 100644 --- a/webpack/assets/javascripts/react_app/mockRequests.js +++ b/webpack/assets/javascripts/react_app/mockRequests.js @@ -1,7 +1,7 @@ import axios from 'axios'; import { MockAdapter } from '@theforeman/test'; -export const mock = () => new MockAdapter(axios); +export const mock = new MockAdapter(axios); const methods = { GET: 'onGet', POST: 'onPost', @@ -15,9 +15,6 @@ export const mockRequest = ({ data = null, status = 200, response = null, -}) => - mock() - [methods[method]](url, data) - .reply(status, response); +}) => mock[methods[method]](url, data).reply(status, response); -export const mockReset = () => mock().reset(); +export const mockReset = () => mock.reset(); diff --git a/webpack/assets/javascripts/react_app/redux/actions/common/forms.test.js b/webpack/assets/javascripts/react_app/redux/actions/common/forms.test.js index e4fc1e3745c..e44bcf23939 100644 --- a/webpack/assets/javascripts/react_app/redux/actions/common/forms.test.js +++ b/webpack/assets/javascripts/react_app/redux/actions/common/forms.test.js @@ -1,15 +1,11 @@ /* eslint-disable promise/prefer-await-to-then */ import { submitForm } from './forms'; -import { mockReset } from '../../../mockRequests'; describe('form actions', () => { beforeEach(() => { document.head.innerHTML = ` `; }); - afterEach(() => { - mockReset(); - }); it('SubmitForm must include an object item/values', () => { expect(() => {