mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
unit test
This commit is contained in:
parent
7c75f48eaa
commit
5c389968f7
@ -7,7 +7,10 @@
|
|||||||
name: 'zan-icon',
|
name: 'zan-icon',
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
name: String
|
name: {
|
||||||
|
type: String,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
25
test/unit/specs/badge.spec.js
Normal file
25
test/unit/specs/badge.spec.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import Badge from 'packages/badge';
|
||||||
|
import BadgeGroup from 'packages/badge-group';
|
||||||
|
import { mount } from 'avoriaz';
|
||||||
|
|
||||||
|
describe('Badge', () => {
|
||||||
|
let wrapper;
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper && wrapper.destroy();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('BadgeGroup', () => {
|
||||||
|
let wrapper;
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper && wrapper.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a badge-group', () => {
|
||||||
|
wrapper = mount(BadgeGroup);
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-badge-group')).to.be.true;
|
||||||
|
expect(wrapper.instance().activeKey).to.equal(0);
|
||||||
|
expect(wrapper.data().badges.length).to.equal(0);
|
||||||
|
});
|
||||||
|
});
|
@ -1,4 +1,5 @@
|
|||||||
import CellGroup from 'packages/cell-group';
|
import CellGroup from 'packages/cell-group';
|
||||||
|
import Cell from 'packages/cell';
|
||||||
import { mount } from 'avoriaz';
|
import { mount } from 'avoriaz';
|
||||||
|
|
||||||
describe('CellGroup', () => {
|
describe('CellGroup', () => {
|
||||||
@ -7,7 +8,7 @@ describe('CellGroup', () => {
|
|||||||
wrapper && wrapper.destroy();
|
wrapper && wrapper.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('create', () => {
|
it('create a cell-group', () => {
|
||||||
wrapper = mount(CellGroup, {
|
wrapper = mount(CellGroup, {
|
||||||
propsData: {}
|
propsData: {}
|
||||||
});
|
});
|
||||||
@ -15,3 +16,37 @@ describe('CellGroup', () => {
|
|||||||
expect(wrapper.hasClass('zan-cell-group')).to.be.true;
|
expect(wrapper.hasClass('zan-cell-group')).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Cell', () => {
|
||||||
|
let wrapper;
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper && wrapper.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create', () => {
|
||||||
|
wrapper = mount(Cell);
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-cell')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a required cell', () => {
|
||||||
|
wrapper = mount(Cell, {
|
||||||
|
propsData: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-cell')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-cell--required')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('emit a click event', () => {
|
||||||
|
wrapper = mount(Cell);
|
||||||
|
|
||||||
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
|
wrapper.simulate('click');
|
||||||
|
|
||||||
|
expect(eventStub.calledOnce).to.be.true;
|
||||||
|
expect(eventStub.calledWith('click')).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
35
test/unit/specs/icon.spec.js
Normal file
35
test/unit/specs/icon.spec.js
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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('zan-icon')).to.be.true;
|
||||||
|
expect(wrapper.hasClass('zan-icon-arrow')).to.be.true;
|
||||||
|
});
|
||||||
|
|
||||||
|
it('emit a click event', () => {
|
||||||
|
wrapper = mount(Icon, {
|
||||||
|
propsData: {
|
||||||
|
name: 'arrow'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const eventStub = sinon.stub(wrapper.vm, '$emit');
|
||||||
|
wrapper.simulate('click');
|
||||||
|
|
||||||
|
expect(eventStub.calledOnce).to.be.true;
|
||||||
|
expect(eventStub.calledWith('click')).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user