Skip to content

Commit

Permalink
Refactored src/utils/convertToBase64.test.ts from Jest to Vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
AceHunterr committed Dec 24, 2024
1 parent 7755890 commit 3e80313
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { describe, it, expect, vi } from 'vitest';
import convertToBase64 from './convertToBase64';

describe('convertToBase64', () => {
Expand All @@ -16,7 +17,7 @@ describe('convertToBase64', () => {
it('should handle errors thrown by FileReader', async () => {
// Arrange
const file = new File(['hello'], 'hello.txt', { type: 'text/plain' });
const mockFileReader = jest
const mockFileReader = vi
.spyOn(global, 'FileReader')
.mockImplementationOnce(() => {
throw new Error('Test error');
Expand All @@ -29,5 +30,6 @@ describe('convertToBase64', () => {
expect(mockFileReader).toHaveBeenCalledTimes(1);
expect(mockFileReader).toHaveBeenCalledWith();
expect(result).toBe('');
mockFileReader.mockRestore();
});
});

0 comments on commit 3e80313

Please sign in to comment.