mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
field unit test
This commit is contained in:
parent
cd049aa2a1
commit
e94edd480e
@ -16,9 +16,7 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
onItemClick() {
|
onItemClick() {}
|
||||||
console.log('click');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
@ -19,65 +19,64 @@ describe('Field', () => {
|
|||||||
expect(wrapper.propsData().type).to.equal('text');
|
expect(wrapper.propsData().type).to.equal('text');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a text field with initialize value', () => {
|
it('create a text field with initialize value', (done) => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {
|
propsData: {
|
||||||
// value: 'test'
|
value: 'test'
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// expect(wrapper.hasClass('zan-field')).to.be.true;
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
// expect(wrapper.data().currentValue).to.equal('test');
|
expect(wrapper.data().currentValue).to.equal('test');
|
||||||
|
|
||||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
|
|
||||||
// wrapper.vm.value = 'test2';
|
wrapper.vm.value = 'test2';
|
||||||
// wrapper.update();
|
wrapper.update();
|
||||||
// wrapper.vm.$nextTick(() => {
|
wrapper.vm.$nextTick(() => {
|
||||||
// expect(wrapper.data().currentValue).to.equal('test2');
|
expect(wrapper.data().currentValue).to.equal('test2');
|
||||||
// expect(eventStub.calledOnce).to.be.true;
|
expect(eventStub.calledWith('input'));
|
||||||
// expect(eventStub.calledWith('input'));
|
done();
|
||||||
// done();
|
});
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('emit a focus event', () => {
|
it('input some value to filed', (done) => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {}
|
propsData: {}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// const input = wrapper.find('.zan-field__control')[0];
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
// const eventStub = sinon.stub(wrapper.vm, '$emit');
|
const input = wrapper.find('.zan-field__control')[0];
|
||||||
|
input.element.focus();
|
||||||
|
|
||||||
// input.simulate('focus');
|
wrapper.update();
|
||||||
|
wrapper.vm.$nextTick(() => {
|
||||||
// expect(eventStub.calledOnce).to.be.true;
|
expect(eventStub.calledWith('focus'));
|
||||||
// expect(eventStub.calledWith('focus')).to.be.true;
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('input some value to filed', () => {
|
|
||||||
// wrapper = mount(Field, {
|
|
||||||
// propsData: {}
|
|
||||||
// });
|
|
||||||
|
|
||||||
// const input = wrapper.find('.zan-field__control')[0];
|
|
||||||
// input.element.value = 'test';
|
|
||||||
|
|
||||||
// wrapper.update();
|
|
||||||
// wrapper.vm.$nextTick(() => {
|
|
||||||
// expect(wrapper.data().currentValue).to.equal('test');
|
|
||||||
// done();
|
|
||||||
// });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create a textarea field', () => {
|
it('create a textarea field', () => {
|
||||||
// wrapper = mount(Field, {
|
wrapper = mount(Field, {
|
||||||
// propsData: {
|
propsData: {
|
||||||
// type: 'textarea',
|
type: 'textarea',
|
||||||
// autosize: false
|
autosize: false
|
||||||
// }
|
}
|
||||||
// });
|
});
|
||||||
|
|
||||||
// expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a autosize textarea field', () => {
|
||||||
|
wrapper = mount(Field, {
|
||||||
|
propsData: {
|
||||||
|
type: 'textarea',
|
||||||
|
autosize: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-field')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-field--autosize')).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user