admin/features/events/presentEventCapacityBadge.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

60 lines
1.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { describe, expect, it } from 'vitest'
import { presentEventCapacityBadge } from '@/features/events/presentEventCapacityBadge'
import { texts } from '@/texts'
describe('presentEventCapacityBadge', () => {
it('returns remaining capacity for open events', () => {
const result = presentEventCapacityBadge({
capacity: 10,
bookedCount: 3,
reservedCapacity: 0,
status: 'published',
endsAt: '2030-07-01T14:00:00.000Z',
})
expect(result.tone).toBe('neutral')
expect(result.label).toContain('۷')
})
it('marks full and ended events as danger', () => {
expect(
presentEventCapacityBadge({
capacity: 5,
bookedCount: 5,
status: 'full',
endsAt: '2030-07-01T14:00:00.000Z',
}).tone
).toBe('danger')
expect(
presentEventCapacityBadge({
capacity: 10,
bookedCount: 2,
status: 'completed',
endsAt: '2020-01-01T00:00:00.000Z',
})
).toEqual({ label: texts.events.eventEnded, tone: 'danger' })
})
it('hides capacity badge for cancelled and rejected events', () => {
expect(
presentEventCapacityBadge({
capacity: 10,
bookedCount: 2,
status: 'cancelled',
endsAt: '2030-07-01T14:00:00.000Z',
})
).toEqual({ label: '', tone: 'neutral' })
expect(
presentEventCapacityBadge({
capacity: 10,
bookedCount: 2,
status: 'rejected',
endsAt: '2030-07-01T14:00:00.000Z',
})
).toEqual({ label: '', tone: 'neutral' })
})
})