Skip to content

Commit

Permalink
Fixes #37821 - fix axios mock
Browse files Browse the repository at this point in the history
  • Loading branch information
MariaAga committed Sep 13, 2024
1 parent 1a5c1b9 commit ca7fa79
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 3 additions & 6 deletions webpack/assets/javascripts/react_app/mockRequests.js
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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();
Original file line number Diff line number Diff line change
@@ -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 = `<meta name="csrf-param" content="authenticity_token" />
<meta name="csrf-token" content="token123" />`;
});
afterEach(() => {
mockReset();
});

it('SubmitForm must include an object item/values', () => {
expect(() => {
Expand Down

0 comments on commit ca7fa79

Please sign in to comment.