Skip to content

Commit

Permalink
Refactored .\src\utils\useLocalstorage.test.ts from Jest to Vitest (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
AceHunterr authored Dec 24, 2024
1 parent c217676 commit 9fbb202
Showing 1 changed file with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// SKIP_LOCALSTORAGE_CHECK

import {
getStorageKey,
getItem,
setItem,
removeItem,
useLocalStorage,
} from './useLocalstorage';
import { describe, it, expect, beforeEach, vi } from 'vitest';

describe('Storage Helper Functions', () => {
beforeEach(() => {
Expand Down Expand Up @@ -95,7 +98,7 @@ describe('Storage Helper Functions', () => {
const storageHelper = useLocalStorage(customPrefix);
const key = 'testKey';

const spyGetStorageKey = jest.spyOn(storageHelper, 'getStorageKey');
const spyGetStorageKey = vi.spyOn(storageHelper, 'getStorageKey');
storageHelper.getStorageKey(key);

expect(spyGetStorageKey).toHaveBeenCalledWith(key);
Expand All @@ -106,7 +109,7 @@ describe('Storage Helper Functions', () => {
const storageHelper = useLocalStorage(customPrefix);
const key = 'testKey';

const spyGetItem = jest.spyOn(storageHelper, 'getItem');
const spyGetItem = vi.spyOn(storageHelper, 'getItem');
storageHelper.getItem(key);

expect(spyGetItem).toHaveBeenCalledWith(key);
Expand All @@ -118,7 +121,7 @@ describe('Storage Helper Functions', () => {
const key = 'testKey';
const value = 'data';

const spySetItem = jest.spyOn(storageHelper, 'setItem');
const spySetItem = vi.spyOn(storageHelper, 'setItem');
storageHelper.setItem(key, value);

expect(spySetItem).toHaveBeenCalledWith(key, value);
Expand All @@ -129,7 +132,7 @@ describe('Storage Helper Functions', () => {
const storageHelper = useLocalStorage(customPrefix);
const key = 'testKey';

const spyRemoveItem = jest.spyOn(storageHelper, 'removeItem');
const spyRemoveItem = vi.spyOn(storageHelper, 'removeItem');
storageHelper.removeItem(key);

expect(spyRemoveItem).toHaveBeenCalledWith(key);
Expand Down

0 comments on commit 9fbb202

Please sign in to comment.