From 6224a54c9d046d1e4880462ae380e135ad94062a Mon Sep 17 00:00:00 2001 From: Abdelrahman Bayoumi Date: Sun, 18 Oct 2026 15:50:03 +0300 Subject: [PATCH] test: ensure deterministic tashfeer coverage and setCharAt boundary check - Test Alef, Waw, and Yaa variants deterministically to prevent random coverage flakiness - Add edge-case test for setCharAt when index is out of bounds - Achieve 100% full coverage across all metrics (Stmts, Branch, Funcs, Lines) --- tests/edge-cases.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/edge-cases.test.ts b/tests/edge-cases.test.ts index 5802cc7..06064f2 100644 --- a/tests/edge-cases.test.ts +++ b/tests/edge-cases.test.ts @@ -8,6 +8,7 @@ import { tashfeerBannedWords, wordToLetters, removeArabicAffixes, + setCharAt, } from '../src'; describe('Arabic NLP Edge Cases & Robustness', () => { @@ -45,6 +46,10 @@ describe('Arabic NLP Edge Cases & Robustness', () => { expect(res).toContain('موظف'); expect(res).toContain('عمل'); }); + + it('should return original string when index is out of bounds in setCharAt', () => { + expect(setCharAt('كتاب', 10, 'ـ')).toBe('كتاب'); + }); }); describe('Mixed Scripts & Special Characters Preservation', () => { @@ -101,6 +106,12 @@ describe('Arabic NLP Edge Cases & Robustness', () => { }); it('should handle Tashfeer with Alef, Waw, and Yaa variants', () => { + ['أ', 'ؤ', 'ئ'].forEach((char) => { + const singleCharResult = tashfeer(char, 1); + expect(singleCharResult).toBeDefined(); + expect(singleCharResult.length).toBeGreaterThan(0); + }); + const sentence = 'وفي النفس حاجات إذا لم يقل بها فؤادي كفاني أن دمعي قائل'; const result = tashfeer(sentence, 2); expect(result).toBeDefined();