import { beforeEach, describe, expect, it, vi } from 'vitest' describe('uiStore theme handling', () => { beforeEach(() => { vi.resetModules() window.localStorage.clear() document.documentElement.removeAttribute('data-theme') document.documentElement.style.colorScheme = '' }) it('defaults new installs to the pure white theme', async () => { const { initializeTheme, useUIStore } = await import('./uiStore') expect(useUIStore.getState().theme).toBe('white') initializeTheme() expect(document.documentElement.getAttribute('data-theme')).toBe('white') expect(document.documentElement.style.colorScheme).toBe('light') }) it('hydrates and applies the pure white theme as a light color scheme', async () => { window.localStorage.setItem('cc-haha-theme', 'white') const { initializeTheme, useUIStore } = await import('./uiStore') expect(useUIStore.getState().theme).toBe('white') initializeTheme() expect(document.documentElement.getAttribute('data-theme')).toBe('white') expect(document.documentElement.style.colorScheme).toBe('light') }) it('cycles through pure white, warm classic, and dark themes', async () => { const { useUIStore } = await import('./uiStore') useUIStore.getState().toggleTheme() expect(useUIStore.getState().theme).toBe('light') expect(document.documentElement.style.colorScheme).toBe('light') useUIStore.getState().toggleTheme() expect(useUIStore.getState().theme).toBe('dark') expect(document.documentElement.style.colorScheme).toBe('dark') useUIStore.getState().toggleTheme() expect(useUIStore.getState().theme).toBe('white') expect(document.documentElement.style.colorScheme).toBe('light') }) })