UNPKG

zarm

Version:

基于 React 的移动端UI库

39 lines (34 loc) 1.73 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral")); var _getClosestPoint = _interopRequireDefault(require("../../utils/getClosestPoint")); var _templateObject; describe('#getClosestPoint', function () { it.each(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n val | marks | step | min | max | expected\n ", " | ", " | ", " | ", " | ", " | ", "\n ", " | ", " | ", " | ", " | ", " | ", "\n ", " | ", " | ", " | ", " | ", " | ", "\n ", " | ", " | ", " | ", " | ", " | ", "\n ", " | ", " | ", " | ", " | ", " | ", "\n "])), 10, { '1.2': '', '3': '' }, 1, 3, 4, 4, 10, {}, 1, 3, 4, 4, 10, null, 1, 3, 4, 4, 0, null, 1, 3, 4, 0, 10, null, 2, 4, 100, 10)('closest point should be $expected when val is $val, marks is $marks, step is $step, min is $min, max is $max', function (_ref) { var val = _ref.val, marks = _ref.marks, step = _ref.step, min = _ref.min, max = _ref.max, expected = _ref.expected; expect((0, _getClosestPoint.default)(val, { marks: marks, step: step, min: min, max: max })).toEqual(expected); }); it('should throw error when min > max', function () { expect(function () { return (0, _getClosestPoint.default)(0, { marks: {}, step: 1, min: 6, max: 4 }); }).toThrowError("\"max\" should be greater than \"min\". Got \"min\" = 6, \"max\" = 4"); }); });