Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { formatChatDayLabel, formatEventDayTimeRange, toLocalDayKey } from '@/lib/formatters'
|
|
|
|
describe('formatChatDayLabel', () => {
|
|
it('returns امروز، فردا and دیروز for nearby days', () => {
|
|
const now = new Date('2026-07-31T15:00:00')
|
|
|
|
expect(formatChatDayLabel('2026-07-31T08:00:00', now)).toBe('امروز')
|
|
expect(formatChatDayLabel('2026-08-01T08:00:00', now)).toBe('فردا')
|
|
expect(formatChatDayLabel('2026-07-30T08:00:00', now)).toBe('دیروز')
|
|
expect(formatChatDayLabel('2026-07-28T08:00:00', now)).not.toMatch(/امروز|فردا|دیروز/)
|
|
})
|
|
|
|
it('builds stable local day keys', () => {
|
|
expect(toLocalDayKey('2026-07-31T23:30:00')).toMatch(/^\d{4}-\d{2}-\d{2}$/)
|
|
})
|
|
})
|
|
|
|
describe('formatEventDayTimeRange', () => {
|
|
it('joins day label with start and end times', () => {
|
|
const now = new Date('2026-07-31T12:00:00')
|
|
const label = formatEventDayTimeRange('2026-07-31T14:30:00', '2026-07-31T17:00:00', now)
|
|
|
|
expect(label.startsWith('امروز')).toBe(true)
|
|
expect(label).toContain('تا')
|
|
})
|
|
})
|