Files
webmail/lib/__tests__/bidi.test.ts
T

16 lines
671 B
TypeScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. 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 { stripBidiControls } from '@/lib/bidi';
describe('stripBidiControls', () => {
it('removes the characters that reorder what the reader sees', () => {
// An RTL override makes `report‮fdp.exe` read as `reportexe.pdf`.
expect(stripBidiControls('report‮fdp.exe')).toBe('reportfdp.exe');
expect(stripBidiControls('⁦a⁩‎b‏‪‫‬‭')).toBe('ab');
});
it('leaves ordinary text, including right-to-left scripts, alone', () => {
expect(stripBidiControls('Rechnung März.pdf')).toBe('Rechnung März.pdf');
expect(stripBidiControls('تقرير.pdf')).toBe('تقرير.pdf');
});
});