add unit test

This commit is contained in:
cookfront
2017-04-20 18:11:05 +08:00
parent 1b90609fc6
commit efd24b0680
8 changed files with 33 additions and 59 deletions
+13 -15
View File
@@ -1,6 +1,6 @@
import Tabs from 'packages/tabs';
import { mount } from 'avoriaz';
// import TabsTestComponent from '../components/tabs';
import TabsTestComponent from '../components/tabs';
describe('Tabs', () => {
let wrapper;
@@ -20,22 +20,20 @@ describe('Tabs', () => {
expect(wrapper.hasClass('van-tabs--card')).to.be.true;
});
it('create a tabs with four tab', () => {
// wrapper = mount(TabsTestComponent);
it('create a tabs with four tab', (done) => {
wrapper = mount(TabsTestComponent);
// expect(wrapper.hasClass('van-tabs')).to.be.true;
// expect(wrapper.hasClass('van-tabs--line')).to.be.true;
expect(wrapper.hasClass('van-tabs')).to.be.true;
expect(wrapper.hasClass('van-tabs--line')).to.be.true;
// const eventStub = sinon.stub(wrapper.vNode.child, '$emit');
const tabsContainer = wrapper.find('.van-tabs')[0];
expect(tabsContainer.vNode.child.curActive).to.equal(0);
// const tabTitle = wrapper.find('.van-tab__pane')[2];
// tabTitle.simulate('click');
// wrapper.vm.$nextTick(() => {
// // expect(.curActive).to.equal(2);
// console.log(wrapper.vNode.child);
// expect(eventStub.calledWith('click'));
// done();
// });
wrapper.vm.active = 1;
wrapper.update();
wrapper.vm.$nextTick(() => {
expect(tabsContainer.vNode.child.curActive).to.equal(1);
done();
});
});
});