Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
60 lines
1.5 KiB
TypeScript
60 lines
1.5 KiB
TypeScript
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' })
|
||
})
|
||
})
|