feat(Form): add scrollToField method (#5680)

This commit is contained in:
陈嘉涵
2020-02-20 16:32:14 +08:00
parent 871398b223
commit 3f14795387
4 changed files with 26 additions and 1 deletions
+15 -1
View File
@@ -1,4 +1,4 @@
import { later } from '../../../test';
import { later, mockScrollIntoView } from '../../../test';
import { mountForm, mountSimpleRulesForm, getSimpleRules } from './shared';
test('submit method', async () => {
@@ -96,3 +96,17 @@ test('resetValidation method - reset one field', done => {
},
});
});
test('scrollToField method', done => {
const fn = mockScrollIntoView();
mountSimpleRulesForm({
mounted() {
this.$refs.form.scrollToField('unknown');
expect(fn).toHaveBeenCalledTimes(0);
this.$refs.form.scrollToField('A');
expect(fn).toHaveBeenCalledTimes(1);
done();
},
});
});