admin/lib/smsSegments.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

34 lines
824 B
TypeScript
Raw 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 { countSmsSegments } from '@/lib/smsSegments'
describe('countSmsSegments', () => {
it('counts a short Persian body as one UCS-2 segment', () => {
const text = 'رزرو شما تأیید شد'
expect(countSmsSegments(text)).toEqual({
chars: Array.from(text).length,
segments: 1,
unicode: true,
})
})
it('splits a long Persian body into 67-character segments', () => {
const body = 'ا'.repeat(71)
expect(countSmsSegments(body)).toEqual({
chars: 71,
segments: 2,
unicode: true,
})
})
it('keeps GSM-7 English within 160 characters as one segment', () => {
expect(countSmsSegments('Your booking is confirmed')).toEqual({
chars: 25,
segments: 1,
unicode: false,
})
})
})