[bugfix] Area: change event values incorrect (#3219)

This commit is contained in:
neverland 2019-04-26 11:36:25 +08:00 committed by GitHub
parent 5ae6d3aabc
commit 377060e11a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -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() {

View File

@ -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', () => {