diff --git a/frontends/nextjs/src/hooks/data/__tests__/useKV.validation.test.ts b/frontends/nextjs/src/hooks/data/__tests__/useKV.validation.test.ts index 19b6f25a5..9fce4cef4 100644 --- a/frontends/nextjs/src/hooks/data/__tests__/useKV.validation.test.ts +++ b/frontends/nextjs/src/hooks/data/__tests__/useKV.validation.test.ts @@ -5,27 +5,23 @@ import { useKV } from '@/hooks/data/useKV' const STORAGE_PREFIX = 'mb_kv:' let store: Record -const setupLocalStorage = (): void => { - store = {} - vi.stubGlobal('localStorage', { - getItem: vi.fn((key: string) => store[key] ?? null), - setItem: vi.fn((key: string, value: string) => { - store[key] = value - }), - removeItem: vi.fn((key: string) => { - delete store[key] - }), - clear: vi.fn(() => { - Object.keys(store).forEach(k => delete store[k]) - }), - length: 0, - key: vi.fn(() => null), - }) -} - describe('useKV validation', () => { beforeEach(() => { - setupLocalStorage() + store = {} + vi.stubGlobal('localStorage', { + getItem: vi.fn((key: string) => store[key] ?? null), + setItem: vi.fn((key: string, value: string) => { + store[key] = value + }), + removeItem: vi.fn((key: string) => { + delete store[key] + }), + clear: vi.fn(() => { + Object.keys(store).forEach(k => delete store[k]) + }), + length: 0, + key: vi.fn(() => null), + }) }) it.each([