mirror of https://github.com/ElemeFE/element
unit test of input
parent
8199c6ce76
commit
b63cb5e066
|
@ -244,8 +244,8 @@
|
||||||
```html
|
```html
|
||||||
<el-input
|
<el-input
|
||||||
type="textarea"
|
type="textarea"
|
||||||
|
autosize
|
||||||
placeholder="请输入内容"
|
placeholder="请输入内容"
|
||||||
:autosize="{minRows: 2, maxRows: 5}"
|
|
||||||
v-model="textarea">
|
v-model="textarea">
|
||||||
</el-input>
|
</el-input>
|
||||||
```
|
```
|
||||||
|
|
|
@ -120,7 +120,6 @@
|
||||||
this.$emit('onblur', this.currentValue);
|
this.$emit('onblur', this.currentValue);
|
||||||
this.dispatch('form-item', 'el.form.blur', [this.currentValue]);
|
this.dispatch('form-item', 'el.form.blur', [this.currentValue]);
|
||||||
},
|
},
|
||||||
|
|
||||||
inputSelect() {
|
inputSelect() {
|
||||||
this.$refs.input.select();
|
this.$refs.input.select();
|
||||||
},
|
},
|
||||||
|
@ -169,7 +168,6 @@
|
||||||
'value'(val, oldValue) {
|
'value'(val, oldValue) {
|
||||||
this.currentValue = val;
|
this.currentValue = val;
|
||||||
},
|
},
|
||||||
|
|
||||||
'currentValue'(val) {
|
'currentValue'(val) {
|
||||||
this.$nextTick(_ => {
|
this.$nextTick(_ => {
|
||||||
this.resizeTextarea();
|
this.resizeTextarea();
|
||||||
|
|
|
@ -50,7 +50,6 @@
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
& + .el-input__inner {
|
& + .el-input__inner {
|
||||||
padding-right: 35px;
|
padding-right: 35px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ import Steps from '../packages/steps/index.js';
|
||||||
import Step from '../packages/step/index.js';
|
import Step from '../packages/step/index.js';
|
||||||
|
|
||||||
const install = function(Vue) {
|
const install = function(Vue) {
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore if */
|
||||||
if (install.installed) return;
|
if (install.installed) return;
|
||||||
|
|
||||||
Vue.component(Pagination.name, Pagination);
|
Vue.component(Pagination.name, Pagination);
|
||||||
|
@ -120,7 +120,7 @@ const install = function(Vue) {
|
||||||
Vue.prototype.$message = Message;
|
Vue.prototype.$message = Message;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore if */
|
||||||
if (typeof window !== 'undefined' && window.Vue) {
|
if (typeof window !== 'undefined' && window.Vue) {
|
||||||
install(window.Vue);
|
install(window.Vue);
|
||||||
};
|
};
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
import { createVue } from '../util';
|
||||||
|
|
||||||
|
describe('Input', () => {
|
||||||
|
it('create', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input
|
||||||
|
minlength="3"
|
||||||
|
maxlength="5"
|
||||||
|
placeholder="请输入内容"
|
||||||
|
value="input">
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
let inputElm = vm.$el.querySelector('input');
|
||||||
|
expect(inputElm.getAttribute('placeholder')).to.equal('请输入内容');
|
||||||
|
expect(inputElm.value).to.equal('input');
|
||||||
|
expect(inputElm.getAttribute('minlength')).to.equal('3');
|
||||||
|
expect(inputElm.getAttribute('maxlength')).to.equal('5');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('disabled', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input disabled>
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
expect(vm.$el.querySelector('input').getAttribute('disabled')).to.ok;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('icon', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input icon="time">
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
expect(vm.$el.querySelector('.el-input__icon').classList.contains('el-icon-time')).to.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('size', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input size="large">
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
expect(vm.$el.classList.contains('el-input-large')).to.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('type', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input type="textarea">
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
|
||||||
|
expect(vm.$el.classList.contains('el-textarea')).to.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('rows', () => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input type="textarea" :rows="3">
|
||||||
|
</el-input>
|
||||||
|
`
|
||||||
|
}, true);
|
||||||
|
expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3');
|
||||||
|
});
|
||||||
|
it('autosize', done => {
|
||||||
|
const vm = createVue({
|
||||||
|
template: `
|
||||||
|
<el-input
|
||||||
|
type="textarea"
|
||||||
|
autosize="{minRows: 3, maxRows: 5}"
|
||||||
|
v-model="textareaValue"
|
||||||
|
>
|
||||||
|
</el-input>
|
||||||
|
`,
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
textareaValue: 'sda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasd'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}, true).$children[0];
|
||||||
|
|
||||||
|
var originHeight = vm.textareaStyle.height;
|
||||||
|
expect(originHeight).to.be.not.equal('117px');
|
||||||
|
|
||||||
|
vm.$parent.textareaValue = '';
|
||||||
|
setTimeout(_ => {
|
||||||
|
expect(vm.textareaStyle.height).to.be.not.equal('54px');
|
||||||
|
done();
|
||||||
|
}, 200);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue