[Doc] optimzie router & remove unused code (#640)
This commit is contained in:
@@ -43,6 +43,17 @@ describe('ContactCard', () => {
|
||||
expect(wrapper.hasClass('van-contact-card')).to.be.true;
|
||||
expect(wrapper.find('.van-contact-card__text div')[0].text()).to.equal('联系人:测试姓名');
|
||||
expect(wrapper.find('.van-contact-card__text div')[1].text()).to.equal('联系电话:13000000000');
|
||||
|
||||
const spy = sinon.spy();
|
||||
wrapper.vm.$on('click', spy);
|
||||
wrapper.trigger('click');
|
||||
expect(spy.calledOnce).to.be.true;
|
||||
|
||||
wrapper.vm.editable = false;
|
||||
const spy2 = sinon.spy();
|
||||
wrapper.vm.$on('click', spy2);
|
||||
wrapper.trigger('click');
|
||||
expect(spy2.calledOnce).to.be.false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -121,6 +121,33 @@ describe('Field', () => {
|
||||
expect(wrapper.find('.van-field__icon').length).to.equal(1);
|
||||
});
|
||||
|
||||
it('keypress event', () => {
|
||||
wrapper = mount(Field, {
|
||||
propsData: {
|
||||
value: '',
|
||||
type: 'number'
|
||||
}
|
||||
});
|
||||
|
||||
const spy1 = sinon.spy();
|
||||
wrapper.vm.onKeypress({ keyCode: 0, preventDefault: spy1 });
|
||||
expect(spy1.calledOnce).to.be.true;
|
||||
|
||||
const spy2 = sinon.spy();
|
||||
wrapper.vm.onKeypress({ keyCode: 50, preventDefault: spy2 });
|
||||
expect(spy2.calledOnce).to.be.false;
|
||||
|
||||
const spy3 = sinon.spy();
|
||||
wrapper.vm.value = '0.1';
|
||||
wrapper.vm.onKeypress({ keyCode: 46, preventDefault: spy3 });
|
||||
expect(spy3.calledOnce).to.be.true;
|
||||
|
||||
wrapper.vm.type = 'text';
|
||||
const spy4 = sinon.spy();
|
||||
wrapper.vm.onKeypress({ keyCode: 0, preventDefault: spy4 });
|
||||
expect(spy4.calledOnce).to.be.false;
|
||||
});
|
||||
|
||||
it('create a field with icon slot', () => {
|
||||
const fn = sinon.spy();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user