mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 21:08:55 +08:00
fix: 修复inputnumber测试用例
This commit is contained in:
parent
b00f746372
commit
75e8e57620
@ -2,7 +2,7 @@ import React = require('react');
|
|||||||
import {render, fireEvent} from '@testing-library/react';
|
import {render, fireEvent} from '@testing-library/react';
|
||||||
import '../../../src/themes/default';
|
import '../../../src/themes/default';
|
||||||
import {render as amisRender} from '../../../src/index';
|
import {render as amisRender} from '../../../src/index';
|
||||||
import {makeEnv} from '../../helper';
|
import {makeEnv, wait} from '../../helper';
|
||||||
|
|
||||||
test('Renderer:number', async () => {
|
test('Renderer:number', async () => {
|
||||||
const {container} = render(
|
const {container} = render(
|
||||||
@ -33,6 +33,7 @@ test('Renderer:number', async () => {
|
|||||||
value: '456'
|
value: '456'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
await wait(100);
|
||||||
expect(input?.value).toEqual('456');
|
expect(input?.value).toEqual('456');
|
||||||
|
|
||||||
expect(container).toMatchSnapshot();
|
expect(container).toMatchSnapshot();
|
||||||
|
@ -176,14 +176,15 @@ export default class NumberControl extends React.Component<
|
|||||||
if (inputValue !== null && unitOptions && this.state.unit) {
|
if (inputValue !== null && unitOptions && this.state.unit) {
|
||||||
inputValue = inputValue + this.state.unit;
|
inputValue = inputValue + this.state.unit;
|
||||||
}
|
}
|
||||||
|
const value = inputValue === null ? resetValue ?? null : inputValue;
|
||||||
const rendererEvent = await dispatchEvent('change', createObject(data, {
|
const rendererEvent = await dispatchEvent('change', createObject(data, {
|
||||||
value: inputValue,
|
value,
|
||||||
}));
|
}));
|
||||||
if (rendererEvent?.prevented) {
|
if (rendererEvent?.prevented) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
onChange(value);
|
||||||
|
|
||||||
onChange(inputValue === null ? resetValue ?? null : inputValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
filterNum(value: number | string | undefined) {
|
filterNum(value: number | string | undefined) {
|
||||||
|
Loading…
Reference in New Issue
Block a user