UNPKG

@activecollab/components

Version:

ActiveCollab Components

24 lines (23 loc) 1.13 kB
"use strict"; var _stringUtils = require("./stringUtils"); describe("sanitizeAndTrim", function () { it("should trim standard whitespace", function () { expect((0, _stringUtils.sanitizeAndTrim)(" hello ")).toBe("hello"); }); it("should replace non-breaking spaces (\u00a0) with standard spaces", function () { // \u00a0 is   expect((0, _stringUtils.sanitizeAndTrim)("hello\u00a0world")).toBe("hello world"); }); it("should replace multiple whitespaces with a single space", function () { expect((0, _stringUtils.sanitizeAndTrim)("hello world")).toBe("hello world"); expect((0, _stringUtils.sanitizeAndTrim)("hello \u00a0 world")).toBe("hello world"); }); it("should trim after replacing non-breaking spaces", function () { expect((0, _stringUtils.sanitizeAndTrim)("\u00a0hello\u00a0")).toBe("hello"); }); it("should return an empty string if input is only whitespace", function () { expect((0, _stringUtils.sanitizeAndTrim)(" ")).toBe(""); expect((0, _stringUtils.sanitizeAndTrim)("\u00a0\u00a0\u00a0")).toBe(""); }); }); //# sourceMappingURL=stringUtils.test.js.map