vant/test/unit/specs/icon.spec.js
张敏 0f5972e75e 支持SSR、升级Vue版本和增加新的icon (#40)
* search component add new style

* update vue version and support ssr

* unit test

* add new icon

* new icon
2017-06-15 19:46:56 +08:00

36 lines
721 B
JavaScript

import Icon from 'packages/icon';
import { mount } from 'avoriaz';
describe('Icon', () => {
let wrapper;
afterEach(() => {
wrapper && wrapper.destroy();
});
it('create a icon', () => {
wrapper = mount(Icon, {
propsData: {
name: 'arrow'
}
});
expect(wrapper.hasClass('van-icon')).to.be.true;
expect(wrapper.hasClass('van-icon-arrow')).to.be.true;
});
it('emit a click event', () => {
wrapper = mount(Icon, {
propsData: {
name: 'arrow'
}
});
const eventStub = sinon.stub(wrapper.vm, '$emit');
wrapper.trigger('click');
expect(eventStub.calledOnce).to.be.true;
expect(eventStub.calledWith('click')).to.be.true;
});
});