Skip to content

Commit 052744e

Browse files
committed
chore(test_helpers): enable DRAG_DELAY for tests and complete event defaults
- configure DRAG_DELAY for tests to the library default of 100ms in order totest delayed dragging. - Ensure Date.now is updated on waitForDragDelay so that time comparisons can be used to test for drag delay constraints
1 parent 2367e2f commit 052744e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

scripts/test/helpers/constants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ export const defaultMouseEventOptions = {
1111
button: 0,
1212
clientX: 0,
1313
clientY: 0,
14+
pageX: 0,
15+
pageY: 0,
1416
};
1517

16-
export const DRAG_DELAY = 0;
18+
export const DRAG_DELAY = 100;

scripts/test/helpers/sensor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ import {DRAG_DELAY, defaultTouchEventOptions, defaultMouseEventOptions} from './
22
import {triggerEvent} from './event';
33

44
export function waitForDragDelay(dragDelay = DRAG_DELAY) {
5+
const next = Date.now() + dragDelay + 1;
6+
const dateMock = jest.spyOn(Date, 'now').mockImplementation(() => {
7+
return next;
8+
});
59
jest.runTimersToTime(dragDelay + 1);
10+
dateMock.mockRestore();
611
}
712

813
export function clickMouse(element, options = {}) {

0 commit comments

Comments
 (0)