feat(Steps): add click-step event (#5937)

This commit is contained in:
neverland
2020-03-28 15:57:24 +08:00
committed by GitHub
parent ac3c77c17f
commit 5bbe5608ce
4 changed files with 62 additions and 16 deletions
+37 -14
View File
@@ -1,29 +1,52 @@
import { mount } from '../../../test';
import Steps from '..';
import Step from '../../step';
test('icon slot', () => {
const wrapper = mount({
template: `
<steps :active="1">
<step>
<van-steps :active="1">
<van-step>
<template v-slot:inactive-icon>Custim Inactive Icon</template>
A
</step>
<step>
</van-step>
<van-step>
<template v-slot:active-icon>Custim Active Icon</template>
B
</step>
<step>
</van-step>
<van-step>
<template v-slot:inactive-icon>Custim Inactive Icon</template>
C
</step>
</steps>
</van-step>
</van-steps>
`,
components: {
Steps,
Step,
},
});
expect(wrapper).toMatchSnapshot();
});
test('click-step event', () => {
const onClickStep = jest.fn();
const wrapper = mount({
template: `
<van-steps :active="1" @click-step="onClickStep">
<van-step>A</van-step>
<van-step>B</van-step>
<van-step>C</van-step>
</van-steps>
`,
methods: {
onClickStep,
},
});
wrapper.find('.van-step').trigger('click');
expect(onClickStep).toHaveBeenCalledTimes(0);
wrapper.find('.van-step__title').trigger('click');
expect(onClickStep).toHaveBeenCalledWith(0);
wrapper
.findAll('.van-step__circle-container')
.at(2)
.trigger('click');
expect(onClickStep).toHaveBeenCalledTimes(2);
expect(onClickStep).toHaveBeenLastCalledWith(2);
});