UNPKG

@activecollab/components

Version:

ActiveCollab Components

22 lines 958 B
import { sanitizeAndTrim } from "./stringUtils"; describe("sanitizeAndTrim", () => { it("should trim standard whitespace", () => { expect(sanitizeAndTrim(" hello ")).toBe("hello"); }); it("should replace non-breaking spaces (\u00a0) with standard spaces", () => { // \u00a0 is   expect(sanitizeAndTrim("hello\u00a0world")).toBe("hello world"); }); it("should replace multiple whitespaces with a single space", () => { expect(sanitizeAndTrim("hello world")).toBe("hello world"); expect(sanitizeAndTrim("hello \u00a0 world")).toBe("hello world"); }); it("should trim after replacing non-breaking spaces", () => { expect(sanitizeAndTrim("\u00a0hello\u00a0")).toBe("hello"); }); it("should return an empty string if input is only whitespace", () => { expect(sanitizeAndTrim(" ")).toBe(""); expect(sanitizeAndTrim("\u00a0\u00a0\u00a0")).toBe(""); }); }); //# sourceMappingURL=stringUtils.test.js.map