admin/texts/format.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

19 lines
809 B
TypeScript

import { describe, expect, it } from 'vitest'
import { format } from '@/texts/format'
describe('texts format', () => {
it('replaces placeholders with string and number values', () => {
expect(format('لینک {channel} رویداد کپی شد', { channel: 'تلگرام' })).toBe('لینک تلگرام رویداد کپی شد')
expect(format('{count} صندلی باقی مانده', { count: 3 })).toBe('3 صندلی باقی مانده')
})
it('leaves missing keys as placeholders', () => {
expect(format('سلام {name}، کد {code}', { name: 'علی' })).toBe('سلام علی، کد {code}')
})
it('replaces the same key more than once', () => {
expect(format('{x} و دوباره {x}', { x: 'آزمایش' })).toBe('آزمایش و دوباره آزمایش')
})
})