mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
test: Raise coverage (#32182)
* chore: rm useless code * test: Coverage of warningOnly * test: 100% coverage
This commit is contained in:
parent
968590e8d0
commit
bc9c2734dd
@ -873,4 +873,61 @@ describe('Form', () => {
|
||||
expect(tooltipProps.title).toEqual('Bamboo');
|
||||
});
|
||||
});
|
||||
|
||||
it('warningOnly validate', async () => {
|
||||
jest.useFakeTimers();
|
||||
|
||||
const wrapper = mount(
|
||||
<Form>
|
||||
<Form.Item>
|
||||
<Form.Item name="test" rules={[{ required: true, warningOnly: true }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form.Item>
|
||||
</Form>,
|
||||
);
|
||||
|
||||
await change(wrapper, 0, '', true);
|
||||
expect(wrapper.find('.ant-form-item-with-help').length).toBeTruthy();
|
||||
expect(wrapper.find('.ant-form-item-has-warning').length).toBeTruthy();
|
||||
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('not warning when remove on validate', async () => {
|
||||
jest.useFakeTimers();
|
||||
let rejectFn = null;
|
||||
|
||||
const wrapper = mount(
|
||||
<Form>
|
||||
<Form.Item>
|
||||
<Form.Item
|
||||
noStyle
|
||||
name="test"
|
||||
rules={[
|
||||
{
|
||||
validator: () =>
|
||||
new Promise((_, reject) => {
|
||||
rejectFn = reject;
|
||||
}),
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Form.Item>
|
||||
</Form>,
|
||||
);
|
||||
|
||||
await change(wrapper, 0, '', true);
|
||||
|
||||
wrapper.unmount();
|
||||
|
||||
// Delay validate failed
|
||||
rejectFn(new Error('delay failed'));
|
||||
|
||||
expect(errorSpy).not.toHaveBeenCalled();
|
||||
|
||||
jest.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
@ -122,7 +122,7 @@ const Col = React.forwardRef<HTMLDivElement, ColProps>((props, ref) => {
|
||||
|
||||
// Hack for Firefox to avoid size issue
|
||||
// https://github.com/ant-design/ant-design/pull/20023#issuecomment-564389553
|
||||
if (flex && wrap === false && !mergedStyle.minWidth) {
|
||||
if (wrap === false && !mergedStyle.minWidth) {
|
||||
mergedStyle.minWidth = 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user