1
0
mirror of https://gitee.com/vant-contrib/vant.git synced 2025-04-06 03:57:59 +08:00

fix(PickerGroup): confirm event missing params ()

This commit is contained in:
neverland 2023-02-11 16:46:55 +08:00 committed by GitHub
parent a2ab97f328
commit 4bd7e85b5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 0 deletions
packages/vant/src/picker-group

@ -85,6 +85,7 @@ export default defineComponent({
class={bem('tabs')}
shrink
animated
lazyRender={false}
>
{props.tabs.map((title, index) => (
<Tab title={title} titleClass={bem('tab-title')}>

@ -6,6 +6,62 @@ import { PickerGroup } from '..';
test('should emit confirm event after clicking the confirm button', async () => {
const value1 = ref(['1']);
const value2 = ref(['2']);
const value3 = ref(['3']);
const wrapper = mount({
setup(props, { emit }) {
const onConfirm = (params: PickerConfirmEventParams) => {
emit('confirm', params);
};
return () => (
<PickerGroup
title="Title"
tabs={['Tab1', 'Tab2', 'Tab3']}
onConfirm={onConfirm}
>
<Picker
v-model={value1.value}
columns={[{ text: '1', value: '1' }]}
/>
<Picker
v-model={value2.value}
columns={[{ text: '2', value: '2' }]}
/>
<Picker
v-model={value3.value}
columns={[{ text: '3', value: '3' }]}
/>
</PickerGroup>
);
},
});
await wrapper.find('.van-picker__confirm').trigger('click');
expect(wrapper.emitted('confirm')![0]).toEqual([
[
{
selectedIndexes: [0],
selectedOptions: [{ text: '1', value: '1' }],
selectedValues: ['1'],
},
{
selectedIndexes: [0],
selectedOptions: [{ text: '2', value: '2' }],
selectedValues: ['2'],
},
{
selectedIndexes: [0],
selectedOptions: [{ text: '3', value: '3' }],
selectedValues: ['3'],
},
],
]);
});
test('should switch to next step when click confirm button', async () => {
const value1 = ref(['1']);
const value2 = ref(['2']);
const wrapper = mount({
setup(props, { emit }) {