[new feature] Slider: add drag-start、drag-end event

This commit is contained in:
陈嘉涵
2019-05-27 20:34:11 +08:00
parent b02773a455
commit d2a6a692c5
5 changed files with 47 additions and 8 deletions
+8 -1
View File
@@ -1,5 +1,5 @@
import Slider from '..';
import { mount, triggerDrag, trigger } from '../../../test/utils';
import { mount, trigger, triggerDrag } from '../../../test/utils';
function mockGetBoundingClientRect(vertical) {
Element.prototype.getBoundingClientRect = jest.fn(() => ({
@@ -24,13 +24,20 @@ test('drag button', () => {
wrapper.setProps({ value });
});
const button = wrapper.find('.van-slider__button');
triggerDrag(button, 50, 0);
expect(wrapper).toMatchSnapshot();
expect(wrapper.emitted('drag-start')).toBeFalsy();
expect(wrapper.emitted('drag-end')).toBeFalsy();
wrapper.setData({ disabled: false });
trigger(button, 'touchstart', 0, 0);
trigger(button, 'touchend', 0, 0);
triggerDrag(button, 50, 0);
expect(wrapper).toMatchSnapshot();
expect(wrapper.emitted('drag-start')).toBeTruthy();
expect(wrapper.emitted('drag-end')).toBeTruthy();
});
it('click bar', () => {