[new feature] Slider: add drag-start、drag-end event
This commit is contained in:
@@ -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', () => {
|
||||
|
||||
Reference in New Issue
Block a user