test(Form): add test cases of all field types

This commit is contained in:
陈嘉涵
2020-02-14 11:11:00 +08:00
parent 6bbeed7dd1
commit 911b6769e4
5 changed files with 216 additions and 29 deletions
+3 -6
View File
@@ -1,5 +1,4 @@
import { later } from '../../../test';
import { mountForm, mountSimpleRulesForm } from './shared';
import { mountForm, submitForm, mountSimpleRulesForm } from './shared';
test('submit event', async () => {
const onSubmit = jest.fn();
@@ -15,9 +14,8 @@ test('submit event', async () => {
},
});
wrapper.find('.van-button').trigger('click');
await submitForm(wrapper);
await later();
expect(onSubmit).toHaveBeenCalledWith({ A: 'bar' });
});
@@ -29,8 +27,7 @@ test('failed event', async () => {
},
});
wrapper.find('.van-button').trigger('click');
await later();
await submitForm(wrapper);
expect(wrapper).toMatchSnapshot();
expect(onFailed).toHaveBeenCalledWith({