mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-25 06:14:59 +00:00
Update frontends/nextjs/src/hooks/data/__tests__/useKV.validation.test.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -5,27 +5,23 @@ import { useKV } from '@/hooks/data/useKV'
|
||||
const STORAGE_PREFIX = 'mb_kv:'
|
||||
let store: Record<string, string>
|
||||
|
||||
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([
|
||||
|
||||
Reference in New Issue
Block a user