fix input value binding bug (#1998)

* fix input value binding bug

* improve input test & docs
This commit is contained in:
baiyaaaaa
2016-12-26 23:01:46 +08:00
committed by cinwell.li
parent 441f4c31a9
commit 6e428ffcc7
4 changed files with 94 additions and 33 deletions

View File

@@ -104,6 +104,7 @@ describe('Input', () => {
}, true);
expect(vm.$el.querySelector('.el-textarea__inner').getAttribute('rows')).to.be.equal('3');
});
it('autosize', done => {
vm = createVue({
template: `
@@ -143,4 +144,57 @@ describe('Input', () => {
done();
}, 200);
});
describe('Input Events', () => {
it('event:focus & blur', done => {
vm = createVue({
template: `
<el-input
ref="input"
placeholder="请输入内容"
value="input">
</el-input>
`
}, true);
const spyFocus = sinon.spy();
const spyBlur = sinon.spy();
vm.$refs.input.$on('focus', spyFocus);
vm.$refs.input.$on('blur', spyBlur);
vm.$el.querySelector('input').focus();
vm.$el.querySelector('input').blur();
vm.$nextTick(_ => {
expect(spyFocus.calledOnce).to.be.true;
expect(spyBlur.calledOnce).to.be.true;
done();
});
});
it('event:change', done => {
vm = createVue({
template: `
<el-input
ref="input"
placeholder="请输入内容"
:value="input">
</el-input>
`,
data() {
return {
input: 'a'
};
}
}, true);
const spy = sinon.spy();
vm.$refs.input.$on('change', spy);
vm.input = 'b';
vm.$nextTick(_ => {
expect(spy.withArgs('b').calledOnce).to.be.true;
done();
});
});
});
});