From 3e8031307dd67f25a50dc4c96bcd9a974632eca2 Mon Sep 17 00:00:00 2001 From: AceHunterr Date: Tue, 24 Dec 2024 23:05:58 +0530 Subject: [PATCH] Refactored src/utils/convertToBase64.test.ts from Jest to Vitest --- .../{convertToBase64.test.ts => convertToBase64.spec.ts} | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) rename src/utils/{convertToBase64.test.ts => convertToBase64.spec.ts} (90%) diff --git a/src/utils/convertToBase64.test.ts b/src/utils/convertToBase64.spec.ts similarity index 90% rename from src/utils/convertToBase64.test.ts rename to src/utils/convertToBase64.spec.ts index 51198ccc29..85b97ac31a 100644 --- a/src/utils/convertToBase64.test.ts +++ b/src/utils/convertToBase64.spec.ts @@ -1,3 +1,4 @@ +import { describe, it, expect, vi } from 'vitest'; import convertToBase64 from './convertToBase64'; describe('convertToBase64', () => { @@ -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'); @@ -29,5 +30,6 @@ describe('convertToBase64', () => { expect(mockFileReader).toHaveBeenCalledTimes(1); expect(mockFileReader).toHaveBeenCalledWith(); expect(result).toBe(''); + mockFileReader.mockRestore(); }); });