import { describe, it, expect, beforeEach } from 'vitest' import { useLocaleStore, LOCALE_STORAGE_KEY } from '@/state/localeStore' beforeEach(() => { localStorage.removeItem(LOCALE_STORAGE_KEY) useLocaleStore.setState({ locale: 'fr' }) }) describe('localeStore', () => { it('defaults to fr when localStorage is empty', () => { expect(useLocaleStore.getState().locale).toBe('fr') }) it('setLocale updates state', () => { useLocaleStore.getState().setLocale('en') expect(useLocaleStore.getState().locale).toBe('en') }) it('setLocale writes to localStorage', () => { useLocaleStore.getState().setLocale('en') expect(localStorage.getItem(LOCALE_STORAGE_KEY)).toBe('en') }) })