From 4bd7e85b5d5963e88c120f72a7f703f84af7e7f0 Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 11 Feb 2023 16:46:55 +0800 Subject: [PATCH] fix(PickerGroup): confirm event missing params (#11566) --- .../vant/src/picker-group/PickerGroup.tsx | 1 + .../vant/src/picker-group/test/index.spec.tsx | 56 +++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/packages/vant/src/picker-group/PickerGroup.tsx b/packages/vant/src/picker-group/PickerGroup.tsx index 3e373d98f..2d3d19bd9 100644 --- a/packages/vant/src/picker-group/PickerGroup.tsx +++ b/packages/vant/src/picker-group/PickerGroup.tsx @@ -85,6 +85,7 @@ export default defineComponent({ class={bem('tabs')} shrink animated + lazyRender={false} > {props.tabs.map((title, index) => ( diff --git a/packages/vant/src/picker-group/test/index.spec.tsx b/packages/vant/src/picker-group/test/index.spec.tsx index 5db7db7ff..cb0033971 100644 --- a/packages/vant/src/picker-group/test/index.spec.tsx +++ b/packages/vant/src/picker-group/test/index.spec.tsx @@ -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 () => ( + + + + + + ); + }, + }); + + 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 }) {