UNPKG

gather-content-ui

Version:
39 lines (38 loc) 1.97 kB
"use strict"; var _vitest = require("vitest"); var _helpers = require("../helpers"); (0, _vitest.describe)("helpers: toPixels", function () { (0, _vitest.it)("should not convert arguments of type number", function () { (0, _vitest.expect)((0, _helpers.toPixels)(100)).toBe(100); }); (0, _vitest.it)("should convert pixels to number", function () { (0, _vitest.expect)((0, _helpers.toPixels)("100px")).toBe(100); }); (0, _vitest.it)("should convert percentage to number", function () { (0, _vitest.expect)((0, _helpers.toPixels)("100%")).toBe(100); }); (0, _vitest.it)("should convert to a percentage value of the percentageOf arg", function () { (0, _vitest.expect)((0, _helpers.toPixels)("50%", 200)).toBe(100); }); (0, _vitest.it)("should return number and warning for unknown units", function () { var warn = _vitest.vi.spyOn(global.console, "warn"); (0, _vitest.expect)((0, _helpers.toPixels)("123rem")).toBe(123); (0, _vitest.expect)(warn).toHaveBeenCalledOnce(); (0, _vitest.expect)(warn).toHaveBeenCalledWith("Could not interpret a normalised value for: 123rem.\nParsing directly to integer: 123."); }); }); (0, _vitest.describe)("helpers: keepValueWithinRange", function () { (0, _vitest.it)("should return the value if there are no other arguments", function () { (0, _vitest.expect)((0, _helpers.keepValueWithinRange)(50)).toBe(50); }); (0, _vitest.it)("should return the value if it is within the range", function () { (0, _vitest.expect)((0, _helpers.keepValueWithinRange)(50, 33, 77)).toBe(50); }); (0, _vitest.it)("should return the max if the value is above the max", function () { (0, _vitest.expect)((0, _helpers.keepValueWithinRange)(11, 1, 10)).toBe(10); }); (0, _vitest.it)("should return the min if the value is below the min", function () { (0, _vitest.expect)((0, _helpers.keepValueWithinRange)(0, 1, 10)).toBe(1); }); }); //# sourceMappingURL=helpers.spec.js.map