mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-23 06:59:15 +08:00
steps test
This commit is contained in:
parent
75542374de
commit
b68740a39b
@ -24,9 +24,7 @@ export default {
|
|||||||
const index = this.$parent.steps.indexOf(this);
|
const index = this.$parent.steps.indexOf(this);
|
||||||
const active = this.$parent.active;
|
const active = this.$parent.active;
|
||||||
|
|
||||||
if (index === -1) {
|
if (index < active) {
|
||||||
return '';
|
|
||||||
} else if (index < active) {
|
|
||||||
return 'finish';
|
return 'finish';
|
||||||
} else if (index === active) {
|
} else if (index === active) {
|
||||||
return 'process';
|
return 'process';
|
||||||
|
26
test/unit/components/steps.vue
Normal file
26
test/unit/components/steps.vue
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<template>
|
||||||
|
<zan-steps :active="active">
|
||||||
|
<zan-step>买家下单</zan-step>
|
||||||
|
<zan-step>商家接单</zan-step>
|
||||||
|
<zan-step>买家提货</zan-step>
|
||||||
|
<zan-step>交易完成</zan-step>
|
||||||
|
</zan-steps>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Steps from 'packages/steps';
|
||||||
|
import Step from 'packages/step';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
'zan-step': Step,
|
||||||
|
'zan-steps': Steps
|
||||||
|
},
|
||||||
|
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
active: 1
|
||||||
|
};
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
28
test/unit/specs/steps.spec.js
Normal file
28
test/unit/specs/steps.spec.js
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
import Steps from 'packages/steps';
|
||||||
|
import { mount } from 'avoriaz';
|
||||||
|
import StepsTestComponent from '../components/steps';
|
||||||
|
|
||||||
|
describe('Steps', () => {
|
||||||
|
let wrapper;
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
wrapper && wrapper.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a steps', () => {
|
||||||
|
wrapper = mount(Steps);
|
||||||
|
|
||||||
|
expect(wrapper.hasClass('zan-steps')).to.be.true;
|
||||||
|
expect(wrapper.data().steps.length).to.equal(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('create a steps with step', () => {
|
||||||
|
wrapper = mount(StepsTestComponent);
|
||||||
|
|
||||||
|
const finishStep = wrapper.find('.zan-step')[0];
|
||||||
|
expect(finishStep.hasClass('zan-step--finish')).to.be.true;
|
||||||
|
|
||||||
|
const proccessStep = wrapper.find('.zan-step')[1];
|
||||||
|
expect(proccessStep.hasClass('zan-step--process')).to.be.true;
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user