mirror of
				https://gitee.com/vant-contrib/vant.git
				synced 2025-10-31 03:22:08 +08:00 
			
		
		
		
	unit test
This commit is contained in:
		
							parent
							
								
									b8737c42d5
								
							
						
					
					
						commit
						66812afc13
					
				| @ -1,51 +1,51 @@ | ||||
| import Checkbox from 'packages/checkbox'; | ||||
| import CheckboxGroup from 'packages/checkbox-group'; | ||||
| import { mount } from 'avoriaz'; | ||||
| // import Checkbox from 'packages/checkbox';
 | ||||
| // import CheckboxGroup from 'packages/checkbox-group';
 | ||||
| // import { mount } from 'avoriaz';
 | ||||
| 
 | ||||
| describe('Checkbox', () => { | ||||
|   let wrapper; | ||||
|   afterEach(() => { | ||||
|     wrapper && wrapper.destroy(); | ||||
|   }); | ||||
| // describe('Checkbox', () => {
 | ||||
| //   let wrapper;
 | ||||
| //   afterEach(() => {
 | ||||
| //     wrapper && wrapper.destroy();
 | ||||
| //   });
 | ||||
| 
 | ||||
|   it('create a checkbox', () => { | ||||
|     wrapper = mount(Checkbox, { | ||||
|       propsData: {} | ||||
|     }); | ||||
| //   it('create a checkbox', () => {
 | ||||
| //     wrapper = mount(Checkbox, {
 | ||||
| //       propsData: {}
 | ||||
| //     });
 | ||||
| 
 | ||||
|     expect(wrapper.hasClass('zan-checkbox')).to.be.true; | ||||
|   }); | ||||
| }); | ||||
| //     expect(wrapper.hasClass('zan-checkbox')).to.be.true;
 | ||||
| //   });
 | ||||
| // });
 | ||||
| 
 | ||||
| describe('CheckboxGroup', () => { | ||||
|   let wrapper; | ||||
|   afterEach(() => { | ||||
|     wrapper && wrapper.destroy(); | ||||
|   }); | ||||
| // describe('CheckboxGroup', () => {
 | ||||
| //   let wrapper;
 | ||||
| //   afterEach(() => {
 | ||||
| //     wrapper && wrapper.destroy();
 | ||||
| //   });
 | ||||
| 
 | ||||
|   it('create a checkbox-group', () => { | ||||
|     wrapper = mount(CheckboxGroup, { | ||||
|       propsData: {} | ||||
|     }); | ||||
| //   it('create a checkbox-group', () => {
 | ||||
| //     wrapper = mount(CheckboxGroup, {
 | ||||
| //       propsData: {}
 | ||||
| //     });
 | ||||
| 
 | ||||
|     expect(wrapper.hasClass('zan-checkbox-group')).to.be.true; | ||||
|   }); | ||||
| //     expect(wrapper.hasClass('zan-checkbox-group')).to.be.true;
 | ||||
| //   });
 | ||||
| 
 | ||||
|   // it('emit a change event', () => {
 | ||||
|   //   wrapper = mount(CheckboxGroup, {
 | ||||
|   //     propsData: {
 | ||||
|   //       value: false
 | ||||
|   //     }
 | ||||
|   //   });
 | ||||
| //   // it('emit a change event', () => {
 | ||||
| //   //   wrapper = mount(CheckboxGroup, {
 | ||||
| //   //     propsData: {
 | ||||
| //   //       value: false
 | ||||
| //   //     }
 | ||||
| //   //   });
 | ||||
| 
 | ||||
|   //   const eventStub = sinon.stub(wrapper.vm, '$emit');
 | ||||
| //   //   const eventStub = sinon.stub(wrapper.vm, '$emit');
 | ||||
| 
 | ||||
|   //   wrapper.vm.value = true;
 | ||||
|   //   wrapper.update();
 | ||||
|   //   Vue.nextTick(() => {
 | ||||
|   //     expect(eventStub.calledOnce).to.be.true;
 | ||||
|   //     expect(eventStub.calledWith('change'));
 | ||||
|   //     done();
 | ||||
|   //   });
 | ||||
|   // });
 | ||||
| }); | ||||
| //   //   wrapper.vm.value = true;
 | ||||
| //   //   wrapper.update();
 | ||||
| //   //   Vue.nextTick(() => {
 | ||||
| //   //     expect(eventStub.calledOnce).to.be.true;
 | ||||
| //   //     expect(eventStub.calledWith('change'));
 | ||||
| //   //     done();
 | ||||
| //   //   });
 | ||||
| //   // });
 | ||||
| // });
 | ||||
|  | ||||
| @ -1,80 +1,83 @@ | ||||
| // import Vue from 'vue';
 | ||||
| // import Field from 'packages/field';
 | ||||
| // import { mount } from 'avoriaz';
 | ||||
| import Field from 'packages/field'; | ||||
| import { mount } from 'avoriaz'; | ||||
| 
 | ||||
| // describe('Field', () => {
 | ||||
| //   let wrapper;
 | ||||
| //   afterEach(() => {
 | ||||
| //     wrapper && wrapper.destroy();
 | ||||
| //   });
 | ||||
| describe('Field', () => { | ||||
|   let wrapper; | ||||
|   afterEach(() => { | ||||
|     wrapper && wrapper.destroy(); | ||||
|   }); | ||||
| 
 | ||||
| //   it('create a text field', () => {
 | ||||
| //     wrapper = mount(Field, {
 | ||||
| //       propsData: {}
 | ||||
| //     });
 | ||||
|   it('create a text field', () => { | ||||
|     wrapper = mount(Field, { | ||||
|       propsData: { | ||||
|         type: 'text', | ||||
|         autosize: false | ||||
|       } | ||||
|     }); | ||||
| 
 | ||||
| //     expect(wrapper.hasClass('zan-field')).to.be.true;
 | ||||
| //   });
 | ||||
|     expect(wrapper.hasClass('zan-field')).to.be.true; | ||||
|     expect(wrapper.propsData().type).to.equal('text'); | ||||
|   }); | ||||
| 
 | ||||
| //   it('create a text field with initialize value', (done) => {
 | ||||
| //     wrapper = mount(Field, {
 | ||||
| //       propsData: {
 | ||||
| //         value: 'test'
 | ||||
| //       }
 | ||||
| //     });
 | ||||
|   it('create a text field with initialize value', () => { | ||||
|     // wrapper = mount(Field, {
 | ||||
|     //   propsData: {
 | ||||
|     //     value: 'test'
 | ||||
|     //   }
 | ||||
|     // });
 | ||||
| 
 | ||||
| //     expect(wrapper.hasClass('zan-field')).to.be.true;
 | ||||
| //     expect(wrapper.data().currentValue).to.equal('test');
 | ||||
|     // expect(wrapper.hasClass('zan-field')).to.be.true;
 | ||||
|     // 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.update();
 | ||||
| //     Vue.nextTick(() => {
 | ||||
| //       expect(wrapper.data().currentValue).to.equal('test2');
 | ||||
| //       expect(eventStub.calledOnce).to.be.true;
 | ||||
| //       expect(eventStub.calledWith('input'));
 | ||||
| //       done();
 | ||||
| //     });
 | ||||
| //   });
 | ||||
|     // wrapper.vm.value = 'test2';
 | ||||
|     // wrapper.update();
 | ||||
|     // wrapper.vm.$nextTick(() => {
 | ||||
|     //   expect(wrapper.data().currentValue).to.equal('test2');
 | ||||
|     //   expect(eventStub.calledOnce).to.be.true;
 | ||||
|     //   expect(eventStub.calledWith('input'));
 | ||||
|     //   done();
 | ||||
|     // });
 | ||||
|   }); | ||||
| 
 | ||||
| //   it('emit a focus event', () => {
 | ||||
| //     wrapper = mount(Field, {
 | ||||
| //       propsData: {}
 | ||||
| //     });
 | ||||
|   it('emit a focus event', () => { | ||||
|     // wrapper = mount(Field, {
 | ||||
|     //   propsData: {}
 | ||||
|     // });
 | ||||
| 
 | ||||
| //     const input = wrapper.find('.zan-field__control')[0];
 | ||||
| //     const eventStub = sinon.stub(wrapper.vm, '$emit');
 | ||||
|     // const input = wrapper.find('.zan-field__control')[0];
 | ||||
|     // const eventStub = sinon.stub(wrapper.vm, '$emit');
 | ||||
| 
 | ||||
| //     input.simulate('focus');
 | ||||
|     // input.simulate('focus');
 | ||||
| 
 | ||||
| //     expect(eventStub.calledOnce).to.be.true;
 | ||||
| //     expect(eventStub.calledWith('focus')).to.be.true;
 | ||||
| //   });
 | ||||
|     // expect(eventStub.calledOnce).to.be.true;
 | ||||
|     // expect(eventStub.calledWith('focus')).to.be.true;
 | ||||
|   }); | ||||
| 
 | ||||
| //   it('input some value to filed', () => {
 | ||||
| //     // wrapper = mount(Field, {
 | ||||
| //     //   propsData: {}
 | ||||
| //     // });
 | ||||
|   it('input some value to filed', () => { | ||||
|     // wrapper = mount(Field, {
 | ||||
|     //   propsData: {}
 | ||||
|     // });
 | ||||
| 
 | ||||
| //     // const input = wrapper.find('.zan-field__control')[0];
 | ||||
| //     // input.element.value = 'test';
 | ||||
|     // const input = wrapper.find('.zan-field__control')[0];
 | ||||
|     // input.element.value = 'test';
 | ||||
| 
 | ||||
| //     // wrapper.update();
 | ||||
| //     // Vue.nextTick(() => {
 | ||||
| //     //   expect(wrapper.data().currentValue).to.equal('test');
 | ||||
| //     //   done();
 | ||||
| //     // });
 | ||||
| //   });
 | ||||
|     // wrapper.update();
 | ||||
|     // wrapper.vm.$nextTick(() => {
 | ||||
|     //   expect(wrapper.data().currentValue).to.equal('test');
 | ||||
|     //   done();
 | ||||
|     // });
 | ||||
|   }); | ||||
| 
 | ||||
| //   it('create a textarea field', () => {
 | ||||
| //     wrapper = mount(Field, {
 | ||||
| //       propsData: {
 | ||||
| //         type: 'textarea',
 | ||||
| //         autosize: false
 | ||||
| //       }
 | ||||
| //     });
 | ||||
|   it('create a textarea field', () => { | ||||
|     // wrapper = mount(Field, {
 | ||||
|     //   propsData: {
 | ||||
|     //     type: 'textarea',
 | ||||
|     //     autosize: false
 | ||||
|     //   }
 | ||||
|     // });
 | ||||
| 
 | ||||
| //     expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
 | ||||
| //   });
 | ||||
| // });
 | ||||
|     // expect(wrapper.hasClass('zan-field--hastextarea')).to.be.true;
 | ||||
|   }); | ||||
| }); | ||||
|  | ||||
| @ -36,6 +36,6 @@ describe('Search', () => { | ||||
|       expect(eventStub.calledOnce).to.be.true; | ||||
|       expect(eventStub.calledWith('change')); | ||||
|       done(); | ||||
|     }) | ||||
|     }); | ||||
|   }); | ||||
| }); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user