unit test

This commit is contained in:
cookfront
2017-04-13 15:34:29 +08:00
parent 5a63e79ca7
commit 7ae82872e1
7 changed files with 85 additions and 65 deletions

View File

@@ -1,4 +1,3 @@
import Vue from 'vue';
import ActionSheet from 'packages/actionsheet';
import { mount } from 'avoriaz';
@@ -8,7 +7,7 @@ describe('ActionSheet', () => {
wrapper && wrapper.destroy();
});
it('create', () => {
it('create a actionsheet', () => {
wrapper = mount(ActionSheet, {
propsData: {}
});
@@ -98,21 +97,20 @@ describe('ActionSheet', () => {
expect(cancelButton.text()).to.equal('cancel');
});
it('toggle actionsheet value', () => {
it('toggle actionsheet value from v-model', (done) => {
wrapper = mount(ActionSheet, {
propsData: {
value: false
}
});
expect(wrapper.data().currentValue).to.be.false;
const eventStub = sinon.stub(wrapper.vm, '$emit');
expect(wrapper.data().currentValue).to.be.false;
wrapper.vm.value = true;
wrapper.update();
Vue.nextTick(() => {
wrapper.vm.$nextTick(() => {
expect(wrapper.data().currentValue).to.be.true;
expect(eventStub.calledOnce).to.be.true;
expect(eventStub.calledWith('input'));
done();
});