|
@@ -8,11 +8,24 @@ describe('Input', () => {
|
|
|
minlength="3"
|
|
|
maxlength="5"
|
|
|
placeholder="请输入内容"
|
|
|
+ @focus="handleFocus"
|
|
|
value="input">
|
|
|
</el-input>
|
|
|
- `
|
|
|
+ `,
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ inputFocus: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleFocus() {
|
|
|
+ this.inputFocus = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}, true);
|
|
|
let inputElm = vm.$el.querySelector('input');
|
|
|
+ inputElm.focus();
|
|
|
+ expect(vm.inputFocus).to.be.true;
|
|
|
expect(inputElm.getAttribute('placeholder')).to.equal('请输入内容');
|
|
|
expect(inputElm.value).to.equal('input');
|
|
|
expect(inputElm.getAttribute('minlength')).to.equal('3');
|
|
@@ -32,11 +45,27 @@ describe('Input', () => {
|
|
|
it('icon', () => {
|
|
|
const vm = createVue({
|
|
|
template: `
|
|
|
- <el-input icon="time">
|
|
|
+ <el-input
|
|
|
+ icon="time"
|
|
|
+ @click="handleIconClick"
|
|
|
+ >
|
|
|
</el-input>
|
|
|
- `
|
|
|
+ `,
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ iconClicked: false
|
|
|
+ };
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleIconClick(ev) {
|
|
|
+ this.iconClicked = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
}, true);
|
|
|
- expect(vm.$el.querySelector('.el-input__icon').classList.contains('el-icon-time')).to.true;
|
|
|
+ var icon = vm.$el.querySelector('.el-input__icon');
|
|
|
+ icon.click();
|
|
|
+ expect(icon.classList.contains('el-icon-time')).to.true;
|
|
|
+ expect(vm.iconClicked).to.true;
|
|
|
});
|
|
|
|
|
|
it('size', () => {
|
|
@@ -73,26 +102,39 @@ describe('Input', () => {
|
|
|
it('autosize', done => {
|
|
|
const vm = createVue({
|
|
|
template: `
|
|
|
- <el-input
|
|
|
- type="textarea"
|
|
|
- autosize="{minRows: 3, maxRows: 5}"
|
|
|
- v-model="textareaValue"
|
|
|
- >
|
|
|
- </el-input>
|
|
|
+ <div>
|
|
|
+ <el-input
|
|
|
+ ref="limitSize"
|
|
|
+ type="textarea"
|
|
|
+ :autosize="{minRows: 3, maxRows: 5}"
|
|
|
+ v-model="textareaValue"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ <el-input
|
|
|
+ ref="limitlessSize"
|
|
|
+ type="textarea"
|
|
|
+ autosize
|
|
|
+ v-model="textareaValue"
|
|
|
+ >
|
|
|
+ </el-input>
|
|
|
+ </div>
|
|
|
`,
|
|
|
data() {
|
|
|
return {
|
|
|
textareaValue: 'sda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasdsda\ndasd\nddasd'
|
|
|
};
|
|
|
}
|
|
|
- }, true).$children[0];
|
|
|
+ }, true);
|
|
|
|
|
|
- var originHeight = vm.textareaStyle.height;
|
|
|
- expect(originHeight).to.be.not.equal('117px');
|
|
|
+ var limitSizeInput = vm.$refs.limitSize;
|
|
|
+ var limitlessSizeInput = vm.$refs.limitlessSize;
|
|
|
+ expect(limitSizeInput.textareaStyle.height).to.be.equal('117px');
|
|
|
+ expect(limitlessSizeInput.textareaStyle.height).to.be.equal('201px');
|
|
|
|
|
|
- vm.$parent.textareaValue = '';
|
|
|
+ vm.textareaValue = '';
|
|
|
setTimeout(_ => {
|
|
|
- expect(vm.textareaStyle.height).to.be.not.equal('54px');
|
|
|
+ expect(limitSizeInput.textareaStyle.height).to.be.equal('75px');
|
|
|
+ expect(limitlessSizeInput.textareaStyle.height).to.be.equal('33px');
|
|
|
done();
|
|
|
}, 200);
|
|
|
});
|