Skip to content

Commit

Permalink
test: update test case for form
Browse files Browse the repository at this point in the history
  • Loading branch information
ziyoung committed Sep 26, 2018
1 parent 44a85b8 commit b2dd209
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/unit/specs/form.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ describe('Form', () => {
name: null,
addr: null
},
error: {
name: null,
addr: null
},
rules: {
name: [
{ required: true, message: '请输入活动名称', trigger: 'change', min: 3, max: 6 }
Expand All @@ -923,8 +927,9 @@ describe('Form', () => {
};
},
methods: {
onValidate(prop, valid) {
onValidate(prop, valid, msg) {
this.valid[prop] = valid;
this.error[prop] = msg;
},
setValue(prop, value) {
this.form[prop] = value;
Expand All @@ -934,12 +939,15 @@ describe('Form', () => {
vm.setValue('name', '1');
setTimeout(() => {
expect(vm.valid.name).to.equal(false);
expect(vm.error.name).to.equal('请输入活动名称');
vm.setValue('addr', '1');
setTimeout(() => {
expect(vm.valid.addr).to.equal(true);
expect(vm.error.addr).to.equal(null);
vm.setValue('name', '111');
setTimeout(() => {
expect(vm.valid.name).to.equal(true);
expect(vm.error.name).to.equal(null);
done();
}, DELAY);
}, DELAY);
Expand Down

0 comments on commit b2dd209

Please sign in to comment.