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\useLocalstorage.test.ts from Jest to Vitest #2844

Merged
Merged
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
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
Loading