Commit 5d925ed6 authored by baiyaaaaa's avatar baiyaaaaa Committed by FuryBean

Test/component/form (#687)

Form: add test
parent 14495f61
...@@ -792,8 +792,8 @@ ...@@ -792,8 +792,8 @@
|---------- |-------------- |---------- |-------------------------------- |-------- | |---------- |-------------- |---------- |-------------------------------- |-------- |
| model | 表单数据对象 | object | — | — | | model | 表单数据对象 | object | — | — |
| rules | 表单验证规则 | object | — | — | | rules | 表单验证规则 | object | — | — |
| type | 表单类型 | string | stacked, inline, horizontal | horizontal | | inline | 行内表单模式 | boolean | — | false |
| label-align | 表单域标签的水平对齐位置 | string | right,left | right | | label-position | 表单域标签的位置 | string | right/left/top | right |
| label-width | 表单域标签的宽度,所有的 form-item 都会继承 form 组件的 labelWidth 的值 | string | — | — | | label-width | 表单域标签的宽度,所有的 form-item 都会继承 form 组件的 labelWidth 的值 | string | — | — |
| label-suffix | 表单域标签的后缀 | string | — | — | | label-suffix | 表单域标签的后缀 | string | — | — |
......
...@@ -85,7 +85,6 @@ ...@@ -85,7 +85,6 @@
methods: { methods: {
validate(trigger, cb) { validate(trigger, cb) {
var rules = this.getFilteredRule(trigger); var rules = this.getFilteredRule(trigger);
if (!rules || rules.length === 0) { if (!rules || rules.length === 0) {
cb && cb(); cb && cb();
return true; return true;
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
props: { props: {
model: Object, model: Object,
rules: Object, rules: Object,
type: String,
labelPosition: String, labelPosition: String,
labelWidth: String, labelWidth: String,
labelSuffix: { labelSuffix: {
...@@ -35,6 +34,7 @@ ...@@ -35,6 +34,7 @@
this.fields[field.prop] = field; this.fields[field.prop] = field;
this.fieldLength++; this.fieldLength++;
}); });
/* istanbul ignore next */
this.$on('el.form.removeField', (field) => { this.$on('el.form.removeField', (field) => {
delete this.fields[field.prop]; delete this.fields[field.prop];
this.fieldLength--; this.fieldLength--;
......
...@@ -4,7 +4,7 @@ describe('Dropdown', () => { ...@@ -4,7 +4,7 @@ describe('Dropdown', () => {
it('create', done => { it('create', done => {
const vm = createVue({ const vm = createVue({
template: ` template: `
<el-dropdown> <el-dropdown ref="dropdown">
<span class="el-dropdown-link"> <span class="el-dropdown-link">
下拉菜单<i class="el-icon-caret-bottom el-icon-right"></i> 下拉菜单<i class="el-icon-caret-bottom el-icon-right"></i>
</span> </span>
...@@ -18,19 +18,19 @@ describe('Dropdown', () => { ...@@ -18,19 +18,19 @@ describe('Dropdown', () => {
</el-dropdown> </el-dropdown>
` `
}, true); }, true);
let dropdownElm = vm.$el; let dropdown = vm.$refs.dropdown;
let dropdownElm = dropdown.$el;
let triggerElm = dropdownElm.children[0]; let triggerElm = dropdownElm.children[0];
triggerEvent(triggerElm, 'mouseenter'); triggerEvent(triggerElm, 'mouseenter');
setTimeout(_ => { setTimeout(_ => {
var dropdownMenu = document.querySelector('.dropdown-test-creat'); expect(dropdown.visible).to.be.true;
expect(dropdownMenu.style.display).to.not.ok;
triggerEvent(triggerElm, 'mouseleave'); triggerEvent(triggerElm, 'mouseleave');
setTimeout(_ => { setTimeout(_ => {
expect(dropdownMenu.style.display).to.be.equal('none'); expect(dropdown.visible).to.not.true;
done(); done();
}, 600); }, 300);
}, 400); }, 400);
}); });
it('menu click', done => { it('menu click', done => {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment