import { beforeEach, describe, expect, it } from 'vitest' import { clearEventDraft, loadEventDraft, saveEventDraft } from '@/features/events/eventDraftStore' describe('eventDraftStore', () => { beforeEach(() => { localStorage.clear() }) it('stores drafts separately for each user', () => { saveEventDraft('zahra', { title: 'رویداد زهرا' }, 3) saveEventDraft('ali', { title: 'رویداد علی' }, 2) expect(loadEventDraft<{ title: string }>('zahra')).toMatchObject({ data: { title: 'رویداد زهرا' }, step: 3 }) expect(loadEventDraft<{ title: string }>('ali')).toMatchObject({ data: { title: 'رویداد علی' }, step: 2 }) }) it('clears only the requested user draft', () => { saveEventDraft('zahra', { title: 'draft' }, 1) clearEventDraft('zahra') expect(loadEventDraft('zahra')).toBeNull() }) it('discards corrupt or incompatible drafts', () => { localStorage.setItem('ghabilee:event-create-draft:zahra', '{broken') expect(loadEventDraft('zahra')).toBeNull() }) })