/** * v2.2.284 — 텔레그램 중앙 포맷 (renderTelegram / parseTimesCsv). * 위키 포맷처럼 메시지 포맷도 단일 모듈 — 모든 발신 빌더가 이 규약을 공유한다. */ import { renderTelegram, parseTimesCsv, tgWho, tgSubject, tgCut } from '../src/integrations/telegram/messageFormat'; describe('renderTelegram — 모바일 규약', () => { test('헤더·번호 항목·보조줄·잘림 표기·푸터', () => { const out = renderTelegram({ emoji: '📧', title: '답할 이메일', count: 10, sections: [{ count: 10, maxItems: 2, items: [ { main: '계약 검토', sub: '김성환 · 2일째' }, { main: '견적 문의', sub: '오실묵 · 1일째' }, { main: '세번째', sub: 'x' }, ], }], footer: '처리했으면 `/email done O번호`', }); expect(out).toContain('📧 *답할 이메일* (10)'); expect(out).toContain('1. 계약 검토'); expect(out).toContain(' 김성환 · 2일째'); expect(out).toContain('… 외 8건'); // count 기준 잘림 표기 expect(out).toContain('_처리했으면'); expect(out).not.toContain('세번째'); // maxItems 컷 }); test('3,800자 캡', () => { const out = renderTelegram({ emoji: 'x', title: 't', sections: [{ lines: Array.from({ length: 300 }, () => 'a'.repeat(40)) }], }); expect(out.length).toBeLessThanOrEqual(3810); expect(out).toContain('…(잘림)'); }); test('보조 유틸 — 발신자 괄호 제거·RE/FW 제거', () => { expect(tgWho('김성환(칼리버스-칼리버스)')).toBe('김성환'); expect(tgSubject('RE: FW: 계약 검토의 건')).toBe('계약 검토의 건'); expect(tgCut('12345', 3)).toBe('12…'); }); }); describe('parseTimesCsv — 발송 스케줄 파서', () => { test('정상 파싱 + 정렬', () => { expect(parseTimesCsv('15:00, 09:00')).toEqual([ { hour: 9, minute: 0 }, { hour: 15, minute: 0 }, ]); expect(parseTimesCsv('9:30')).toEqual([{ hour: 9, minute: 30 }]); }); test('잘못된 토큰 무시·빈 값 → []', () => { expect(parseTimesCsv('25:00, abc, 12:60, 12:30')).toEqual([{ hour: 12, minute: 30 }]); expect(parseTimesCsv('')).toEqual([]); }); });