message: search unit test
diff: @@ -38,4 +38,58 @@ describe('Search', () => {
  done();
  });
  });
  +
  + it('handle clean click', () => {
  + wrapper = mount(Search);
  +
  + wrapper.setData({ value: 'test' });
  + expect(wrapper.data().value).to.be.equal('test');
  +
  + const input = wrapper.find('.zan-search__input')[0];
  + input.simulate('focus');
  +
  + const cleanBtn = wrapper.find('.zan-icon-clear')[0];
  + cleanBtn.simulate('click');
  + expect(wrapper.data().value).to.equal('');
  + expect(wrapper.data().focusStatus).to.be.true;
  + });
  +
  + it('handle cancel click', (done) => {
  + wrapper = mount(Search);
  +
  + wrapper.setData({ value: 'test' });
  + expect(wrapper.data().value).to.be.equal('test');
  +
  + const eventStub = sinon.stub(wrapper.vm, '$emit');
  +
  + const input = wrapper.find('.zan-search__input')[0];
  + input.simulate('focus');
  +
  + const cancelBtn = wrapper.find('.zan-search__cancel')[0];
  + cancelBtn.simulate('click');
  +
  + wrapper.vm.$nextTick(() => {
  + expect(wrapper.data().value).to.be.equal('');
  + expect(wrapper.data().focusStatus).to.be.false;
  + expect(wrapper.data().isFocus).to.be.false;
  + expect(eventStub.calledOnce).to.be.true;
  + expect(eventStub.calledWith('change'));
  + done();
  + });
  + });
  +
  + it('emit a search event', (done) => {
  + wrapper = mount(Search);
  +
  + const eventStub = sinon.stub(wrapper.vm, '$emit');
  +
  + const input = wrapper.find('.zan-search__input')[0];
  + input.simulate('keyup.enter');
  +
  + wrapper.vm.$nextTick(() => {
  + expect(eventStub.calledOnce).to.be.true;
  + expect(eventStub.calledWith('search'));
  + done();
  + });
  + });
  });
  