mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +00:00
add unit test
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<van-tabs>
|
||||
<van-tabs :active="active">
|
||||
<van-tab title="选项一">内容一</van-tab>
|
||||
<van-tab title="选项二" disabled>内容二</van-tab>
|
||||
<van-tab title="选项三">内容三</van-tab>
|
||||
<van-tab title="选项二">内容二</van-tab>
|
||||
<van-tab title="选项三" disabled>内容三</van-tab>
|
||||
<van-tab title="选项四">内容四</van-tab>
|
||||
<van-tab title="选项五">内容五</van-tab>
|
||||
</van-tabs>
|
||||
@@ -16,6 +16,12 @@ export default {
|
||||
components: {
|
||||
'van-tab': Tab,
|
||||
'van-tabs': Tabs
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
active: 0
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
@@ -16,7 +16,6 @@ describe('Field', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.hasClass('van-field')).to.be.true;
|
||||
expect(wrapper.propsData().type).to.equal('text');
|
||||
});
|
||||
|
||||
it('create a text field with initialize value', (done) => {
|
||||
|
@@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -15,13 +15,7 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
describe('Uploader', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [] }})).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('disabled', () => {
|
||||
@@ -32,13 +26,7 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
describe('Uploader', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [] }})).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('before read', () => {
|
||||
@@ -52,13 +40,7 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '')] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
describe('Uploader', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '')] }})).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('read text', () => {
|
||||
@@ -73,13 +55,7 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
describe('Uploader', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('read text no after hook', () => {
|
||||
@@ -91,13 +67,7 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
describe('Uploader', () => {
|
||||
let wrapper;
|
||||
afterEach(() => {
|
||||
wrapper && wrapper.destroy();
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
});
|
||||
|
||||
it('read dataUrl', () => {
|
||||
@@ -112,6 +82,6 @@ describe('Uploader', () => {
|
||||
});
|
||||
|
||||
expect(wrapper.contains('input')).to.equal(true);
|
||||
expect(wrapper.methods().onValueChange.call(wrapper.vm, { target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
expect(wrapper.vm.onValueChange({ target: { files: [new File([], '/Users')] }})).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user