admin/features/events/eventDraftStore.test.ts
alisaza e1eaf5eff5 feat: initial ghabilee-admin backoffice app
Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js
app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
2026-09-05 13:12:59 +03:30

31 lines
1.0 KiB
TypeScript

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()
})
})