Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/edge-cases.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
tashfeerBannedWords,
wordToLetters,
removeArabicAffixes,
setCharAt,
} from '../src';

describe('Arabic NLP Edge Cases & Robustness', () => {
Expand Down Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();
Expand Down
Loading