refactor(SwipeCell): remove deprecated on-close
This commit is contained in:
@@ -20,9 +20,6 @@ export default createComponent({
|
||||
],
|
||||
|
||||
props: {
|
||||
// @deprecated
|
||||
// should be removed in next major version, use beforeClose instead
|
||||
onClose: Function,
|
||||
disabled: Boolean,
|
||||
leftWidth: [Number, String],
|
||||
rightWidth: [Number, String],
|
||||
@@ -177,8 +174,6 @@ export default createComponent({
|
||||
name: this.name,
|
||||
instance: this,
|
||||
});
|
||||
} else if (this.onClose) {
|
||||
this.onClose(position, this, { name: this.name });
|
||||
} else {
|
||||
this.close(position);
|
||||
}
|
||||
|
||||
@@ -41,43 +41,6 @@ test('drag and show right part', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('on-close prop', () => {
|
||||
let position;
|
||||
let instance;
|
||||
|
||||
const wrapper = mount(SwipeCell, {
|
||||
...defaultProps,
|
||||
propsData: {
|
||||
...defaultProps.propsData,
|
||||
onClose(pos, ins) {
|
||||
position = pos;
|
||||
instance = ins;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
wrapper.trigger('click');
|
||||
expect(position).toEqual(undefined);
|
||||
|
||||
wrapper.vm.open('left');
|
||||
wrapper.trigger('click');
|
||||
expect(position).toEqual('cell');
|
||||
|
||||
wrapper.find('.van-swipe-cell__left').trigger('click');
|
||||
expect(position).toEqual('left');
|
||||
|
||||
wrapper.find('.van-swipe-cell__right').trigger('click');
|
||||
expect(position).toEqual('right');
|
||||
|
||||
instance.close();
|
||||
expect(instance.offset).toEqual(0);
|
||||
|
||||
instance.open('left');
|
||||
wrapper.setData({ onClose: null });
|
||||
wrapper.trigger('click');
|
||||
expect(wrapper.vm.offset).toEqual(0);
|
||||
});
|
||||
|
||||
test('before-close prop', () => {
|
||||
let position;
|
||||
let instance;
|
||||
|
||||
Reference in New Issue
Block a user