mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bugfix] Area: change event values incorrect (#3219)
This commit is contained in:
parent
5ae6d3aabc
commit
377060e11a
@ -110,7 +110,7 @@ export default sfc({
|
||||
onChange(picker, values, index) {
|
||||
this.code = values[index].code;
|
||||
this.setValues();
|
||||
this.$emit('change', picker, values, index);
|
||||
this.$emit('change', picker, picker.getValues(), index);
|
||||
},
|
||||
|
||||
setValues() {
|
||||
|
@ -8,6 +8,12 @@ const firstOption = [
|
||||
{ code: '110101', name: '东城区' }
|
||||
];
|
||||
|
||||
const secondOption = [
|
||||
{ code: '120000', name: '天津市' },
|
||||
{ code: '120100', name: '天津市' },
|
||||
{ code: '120101', name: '和平区' }
|
||||
];
|
||||
|
||||
test('confirm & cancel event', async () => {
|
||||
const onConfirm = jest.fn();
|
||||
const onCancel = jest.fn();
|
||||
@ -50,9 +56,13 @@ test('watch areaList & code', async () => {
|
||||
});
|
||||
|
||||
test('change option', () => {
|
||||
const onChange = jest.fn();
|
||||
const wrapper = mount(Area, {
|
||||
propsData: {
|
||||
areaList
|
||||
},
|
||||
listeners: {
|
||||
change: onChange
|
||||
}
|
||||
});
|
||||
|
||||
@ -62,6 +72,7 @@ test('change option', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
triggerDrag(columns.at(2), 0, -100);
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(onChange.mock.calls[0][1]).toEqual(secondOption);
|
||||
});
|
||||
|
||||
test('getValues method', () => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user