fix(amis): 修正range.test.tsx用例

This commit is contained in:
wibetter 2024-05-06 17:20:23 +08:00
parent 03050bb774
commit 2a4ba1e9e6
2 changed files with 5 additions and 4 deletions

View File

@ -382,11 +382,12 @@ export class Range extends React.Component<RangeItemProps, any> {
*/
getStepValue(value: number, step: number) {
const surplus = value % step;
let curValue = value - surplus;
let curValue = 0;
const closeNum = value - surplus;
// 余数 >= 步长一半 -> 向上取value为正值的时候使用 safeAdd否则使用 safeSub
// 余数 < 步长一半 -> 向下取,使用 curValue
// 余数 < 步长一半 -> 向下取,使用 closeNum
if (Math.abs(surplus) >= step / 2) {
curValue = value >= 0 ? safeAdd(curValue, step) : safeSub(curValue, step);
curValue = value >= 0 ? safeAdd(closeNum, step) : safeSub(closeNum, step);
}
/*
let result = 0;

View File

@ -118,7 +118,7 @@ test('EventAction:inputRange', async () => {
});
// 滑动 change
const slider = container.querySelector('.cxd-InputRange-handle')!;
const slider = container.querySelector('.cxd-InputRange-handle-icon')!;
fireEvent.mouseDown(slider);
fireEvent.mouseMove(slider, {
clientX: 0,