diff --git a/examples/docs/zh-cn/input.md b/examples/docs/zh-cn/input.md index da3a3290b..de011f010 100644 --- a/examples/docs/zh-cn/input.md +++ b/examples/docs/zh-cn/input.md @@ -244,8 +244,8 @@ ```html ``` diff --git a/packages/input/src/input.vue b/packages/input/src/input.vue index 99473ff84..8a67475bb 100644 --- a/packages/input/src/input.vue +++ b/packages/input/src/input.vue @@ -120,7 +120,6 @@ this.$emit('onblur', this.currentValue); this.dispatch('form-item', 'el.form.blur', [this.currentValue]); }, - inputSelect() { this.$refs.input.select(); }, @@ -169,7 +168,6 @@ 'value'(val, oldValue) { this.currentValue = val; }, - 'currentValue'(val) { this.$nextTick(_ => { this.resizeTextarea(); diff --git a/packages/theme-default/src/input.css b/packages/theme-default/src/input.css index e3915be5f..e5e2ef22f 100644 --- a/packages/theme-default/src/input.css +++ b/packages/theme-default/src/input.css @@ -50,7 +50,6 @@ vertical-align: middle; } - & + .el-input__inner { padding-right: 35px; } diff --git a/src/index.js b/src/index.js index 67d807009..24b2d527e 100644 --- a/src/index.js +++ b/src/index.js @@ -55,7 +55,7 @@ import Steps from '../packages/steps/index.js'; import Step from '../packages/step/index.js'; const install = function(Vue) { - /* istanbul ignore next */ + /* istanbul ignore if */ if (install.installed) return; Vue.component(Pagination.name, Pagination); @@ -120,7 +120,7 @@ const install = function(Vue) { Vue.prototype.$message = Message; }; -/* istanbul ignore next */ +/* istanbul ignore if */ if (typeof window !== 'undefined' && window.Vue) { install(window.Vue); }; diff --git a/test/unit/specs/input.spec.js b/test/unit/specs/input.spec.js new file mode 100644 index 000000000..f312e52f2 --- /dev/null +++ b/test/unit/specs/input.spec.js @@ -0,0 +1,99 @@ +import { createVue } from '../util'; + +describe('Input', () => { + it('create', () => { + const vm = createVue({ + template: ` + + + ` + }, 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: ` + + + ` + }, true); + expect(vm.$el.querySelector('input').getAttribute('disabled')).to.ok; + }); + + it('icon', () => { + const vm = createVue({ + template: ` + + + ` + }, true); + expect(vm.$el.querySelector('.el-input__icon').classList.contains('el-icon-time')).to.true; + }); + + it('size', () => { + const vm = createVue({ + template: ` + + + ` + }, true); + + expect(vm.$el.classList.contains('el-input-large')).to.true; + }); + + it('type', () => { + const vm = createVue({ + template: ` + + + ` + }, true); + + expect(vm.$el.classList.contains('el-textarea')).to.true; + }); + + it('rows', () => { + const vm = createVue({ + template: ` + + + ` + }, true); + expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3'); + }); + it('autosize', done => { + const vm = createVue({ + template: ` + + + `, + 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); + }); +});