fix: 修复inputnumber测试用例

This commit is contained in:
wutong25 2022-02-14 20:20:21 +08:00
parent b00f746372
commit 75e8e57620
2 changed files with 5 additions and 3 deletions

View File

@ -2,7 +2,7 @@ import React = require('react');
import {render, fireEvent} from '@testing-library/react';
import '../../../src/themes/default';
import {render as amisRender} from '../../../src/index';
import {makeEnv} from '../../helper';
import {makeEnv, wait} from '../../helper';
test('Renderer:number', async () => {
const {container} = render(
@ -33,6 +33,7 @@ test('Renderer:number', async () => {
value: '456'
}
});
await wait(100);
expect(input?.value).toEqual('456');
expect(container).toMatchSnapshot();

View File

@ -176,14 +176,15 @@ export default class NumberControl extends React.Component<
if (inputValue !== null && unitOptions && this.state.unit) {
inputValue = inputValue + this.state.unit;
}
const value = inputValue === null ? resetValue ?? null : inputValue;
const rendererEvent = await dispatchEvent('change', createObject(data, {
value: inputValue,
value,
}));
if (rendererEvent?.prevented) {
return;
}
onChange(value);
onChange(inputValue === null ? resetValue ?? null : inputValue);
}
filterNum(value: number | string | undefined) {