zarm
Version:
基于 React 的移动端UI库
34 lines (32 loc) • 1.53 kB
JavaScript
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
var _templateObject;
import getClosestPoint from '../../utils/getClosestPoint';
describe('#getClosestPoint', function () {
it.each(_templateObject || (_templateObject = _taggedTemplateLiteral(["\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(getClosestPoint(val, {
marks: marks,
step: step,
min: min,
max: max
})).toEqual(expected);
});
it('should throw error when min > max', function () {
expect(function () {
return getClosestPoint(0, {
marks: {},
step: 1,
min: 6,
max: 4
});
}).toThrowError("\"max\" should be greater than \"min\". Got \"min\" = 6, \"max\" = 4");
});
});