UNPKG

@renderlesskit/react

Version:

Collection of headless components/hooks that are accessible, composable, customizable from low level to build your own UI & Design System powered by Reakit

45 lines (42 loc) 1.45 kB
"use strict"; var _ = require("."); describe("Utils", function () { test("clampValue", function () { expect((0, _.clampValue)(5, 1, 8)).toEqual(5); expect((0, _.clampValue)(5, 1, 3)).toEqual(3); expect((0, _.clampValue)(5, 6, 8)).toEqual(6); }); test("valueToPercent", function () { expect((0, _.valueToPercent)(10, 0, 100)).toEqual(10); expect((0, _.valueToPercent)(10, 0, 50)).toEqual(20); expect((0, _.valueToPercent)(10, 0, 1)).toEqual(1000); expect((0, _.valueToPercent)(10, 0, 1000)).toEqual(1); expect((0, _.valueToPercent)(0.5, 0, 100)).toEqual(0.5); }); test("getOptimumValue", function () { expect((0, _.getOptimumValue)(0, 100)).toBe(50); expect((0, _.getOptimumValue)(100, 0)).toBe(100); expect((0, _.getOptimumValue)(100, 500)).toBe(300); }); }); // Error logs are not for PRO devs 😎 // we can debug without it var oldLog = console.error; beforeAll(function () { console.error = function () {}; }); afterAll(function () { console.error = oldLog; }); // class ErrorBoundary extends React.Component<any, { hasError: boolean }> { // constructor(props: any) { // super(props); // this.state = { hasError: false }; // } // componentDidCatch(error: any, info: any) { // this.setState({ hasError: true }); // } // render() { // if (this.state.hasError) return null; // return this.props.children; // } // } //# sourceMappingURL=utils.test.js.map