/** * Test setup for bun test runner * * Provides DOM environment (happy-dom) for React component tests * and global test utilities. */ import { GlobalRegistrator } from '@happy-dom/global-registrator'; // Register happy-dom globals (window, document, etc.) GlobalRegistrator.register(); // Provide localStorage mock for tests that need it if (typeof globalThis.localStorage === 'undefined') { const storage = new Map(); globalThis.localStorage = { getItem: (key: string) => storage.get(key) ?? null, setItem: (key: string, value: string) => storage.set(key, value), removeItem: (key: string) => storage.delete(key), clear: () => storage.clear(), get length() { return storage.size; }, key: (index: number) => [...storage.keys()][index] ?? null, }; } // Provide sessionStorage mock if (typeof globalThis.sessionStorage === 'undefined') { const storage = new Map(); globalThis.sessionStorage = { getItem: (key: string) => storage.get(key) ?? null, setItem: (key: string, value: string) => storage.set(key, value), removeItem: (key: string) => storage.delete(key), clear: () => storage.clear(), get length() { return storage.size; }, key: (index: number) => [...storage.keys()][index] ?? null, }; }