Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored src/utils/convertToBase64.test.ts from Jest to Vitest #2780

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified .node-version
Binary file not shown.
54 changes: 49 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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();
});
});
Loading