24 lines
653 B
TypeScript
24 lines
653 B
TypeScript
import "@testing-library/jest-dom/vitest";
|
|
|
|
// Polyfill localStorage for jsdom if not available
|
|
if (typeof localStorage === "undefined") {
|
|
const store: Record<string, string> = {};
|
|
(global as any).localStorage = {
|
|
getItem: (key: string) => store[key] || null,
|
|
setItem: (key: string, value: string) => {
|
|
store[key] = String(value);
|
|
},
|
|
removeItem: (key: string) => {
|
|
delete store[key];
|
|
},
|
|
clear: () => {
|
|
for (const key in store) {
|
|
delete store[key];
|
|
}
|
|
},
|
|
key: (index: number) => Object.keys(store)[index] || null,
|
|
get length() {
|
|
return Object.keys(store).length;
|
|
},
|
|
};
|
|
}
|