import { escapeSpecialChar } from "./escapeSpecialChar"; describe("Escape special characters", () => { test("handles an empty string", () => { const input = ""; const expectedOutput = ""; expect(escapeSpecialChar(input)).toBe(expectedOutput); }); test("returns the same string if no special characters are present", () => { const input = "HelloWorld"; const expectedOutput = "HelloWorld"; expect(escapeSpecialChar(input)).toBe(expectedOutput); }); test("escapes special characters in a string", () => { const input = "Hello. How are you?"; const expectedOutput = "Hello\\. How are you\\?"; expect(escapeSpecialChar(input)).toBe(expectedOutput); }); test("handles strings with only special characters", () => { const input = ".*+?^${}()|[]\\"; const expectedOutput = "\\.\\*\\+\\?\\^\\$\\{\\}\\(\\)\\|\\[\\]\\\\"; expect(escapeSpecialChar(input)).toBe(expectedOutput); }); });