Skip to content

Commit 3222517

Browse files
test: set explicit deltaX and cover horizontal wheel delta normalization
1 parent 9c66147 commit 3222517

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

tests/scroll.test.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,7 @@ describe('List.Scroll', () => {
341341
const ulElement = container.querySelector('ul');
342342
act(() => {
343343
const wheelEvent = new Event('wheel');
344+
wheelEvent.deltaX = 0;
344345
wheelEvent.deltaY = 3;
345346
wheelEvent.deltaMode = 1;
346347
wheelEvent.preventDefault = () => {};
@@ -355,6 +356,7 @@ describe('List.Scroll', () => {
355356
const ulElement = container.querySelector('ul');
356357
act(() => {
357358
const wheelEvent = new Event('wheel');
359+
wheelEvent.deltaX = 0;
358360
wheelEvent.deltaY = 1;
359361
wheelEvent.deltaMode = 2;
360362
wheelEvent.preventDefault = () => {};
@@ -364,6 +366,24 @@ describe('List.Scroll', () => {
364366
expect(getScrollOffset(container)).toBe(100);
365367
});
366368

369+
it('normalizes line-mode wheel delta to pixels horizontally', () => {
370+
const { container } = genList({
371+
itemHeight: 20,
372+
height: 100,
373+
data: genData(100),
374+
scrollWidth: 1000,
375+
});
376+
const holder = container.querySelector('ul');
377+
const event = createEvent.wheel(holder, {
378+
deltaX: 3,
379+
deltaY: 0,
380+
deltaMode: 1,
381+
});
382+
const spyPreventDefault = jest.spyOn(event, 'preventDefault');
383+
fireEvent(holder, event);
384+
expect(spyPreventDefault).toHaveBeenCalled();
385+
});
386+
367387
describe('scrollbar', () => {
368388
it('moving', () => {
369389
const listRef = React.createRef();

0 commit comments

Comments
 (0)