Skip to content

Commit

Permalink
update post mock
Browse files Browse the repository at this point in the history
  • Loading branch information
nkylstad committed Dec 2, 2024
1 parent 5bf5893 commit c3df21f
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { FeedbackForm } from './FeedbackForm';
import axios from 'axios';

describe('FeedbackForm', () => {
beforeAll(() => {
jest.mock('app-shared/utils/networking', () => {
return {
post: jest.fn(() => Promise.resolve()),
};
});
});
jest.mock('axios');
var mockedAxios = axios as jest.Mocked<typeof axios>;

describe('FeedbackForm', () => {
afterAll(() => {
jest.clearAllMocks();
});
Expand All @@ -31,6 +27,7 @@ describe('FeedbackForm', () => {

it('should close the feedback form when clicking send', async () => {
const user = userEvent.setup();
mockedAxios.post.mockResolvedValueOnce({});
renderFeedbackForm();
await user.click(screen.getByRole('button', { name: 'Gi tilbakemelding' }));
expect(await screen.findByRole('dialog')).toBeInTheDocument();
Expand Down

0 comments on commit c3df21f

Please sign in to comment.