Skip to content

Commit

Permalink
feat: one more test
Browse files Browse the repository at this point in the history
Signed-off-by: Michel Mendiola <[email protected]>
  • Loading branch information
MissAllSunday committed Dec 16, 2024
1 parent c58b38c commit 799f0f8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/api/Comment/Delete.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import '@testing-library/jest-dom';

import { responses } from '../../__fixtures__/responses';
import { baseUrl } from '../Base';
import { resolveDelete } from '../Resolvers/Delete';
import { deleteComment } from './Delete';

jest.mock('../Resolvers/Delete');
jest.mock('../Base');

global.fetch = jest.fn(() =>
Promise.resolve({
json: () => Promise.resolve(responses.basic),
}),
) as jest.Mock;

describe('Delete Comment is invoked', () => {
beforeEach(() => {
(global.fetch as jest.Mock).mockResolvedValueOnce(responses.basic);
(baseUrl as jest.Mock).mockReturnValue('url');
});
describe('and resource was deleted', () => {
it('calls resolver', async () => {
await deleteComment(1);
expect(resolveDelete as jest.Mock).toHaveBeenCalledWith(responses.basic, 'Your comment was successfully deleted!');
});
});
});

0 comments on commit 799f0f8

Please sign in to comment.