Skip to content

Commit

Permalink
test(ScrollInertia): on shift + wheel horizontal scroll is performed #…
Browse files Browse the repository at this point in the history
  • Loading branch information
ddincheva committed Jan 18, 2021
1 parent 4106e6b commit 93ee5e8
Showing 1 changed file with 49 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,55 @@ describe('Scroll Inertia Directive - Scrolling', () => {
expect (() => scrollInertiaDir.onWheel(evt)).not.toThrow();
});


it('should change scroll left when shift + wheel is triggered' , () => {
scrollInertiaDir.IgxScrollInertiaDirection = 'horizontal';
const evt = {shiftKey: true, wheelDeltaY: -240, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(2 * scrollInertiaDir.wheelStep);
});

it('should be able to scroll to left/right when shift + wheel is triggered' , () => {
scrollInertiaDir.IgxScrollInertiaDirection = 'horizontal';
let evt = {shiftKey: true, wheelDeltaY: -240, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(2 * scrollInertiaDir.wheelStep);

evt = {shiftKey: true, wheelDeltaY: 120, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(-1 * scrollInertiaDir.wheelStep);
});

it('should change scroll left when shift + wheel is called with with deltaY' , () => {
scrollInertiaDir.IgxScrollInertiaDirection = 'horizontal';
const evt = {shiftKey: true, deltaY: 1, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(scrollInertiaDir.wheelStep);
});

it('should be able to scroll to left/right when shift + wheel is called with with deltaY' , () => {
scrollInertiaDir.IgxScrollInertiaDirection = 'horizontal';
let evt = {shiftKey: true, deltaY: 1, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(scrollInertiaDir.wheelStep);

evt = {shiftKey: true, deltaY: -1, preventDefault: () => {}};
scrollInertiaDir.onWheel(evt);

expect(scrollContainerMock.scrollTop).toEqual(0);
expect(scrollContainerMock.scrollLeft).toEqual(-1 * scrollInertiaDir.wheelStep);
});

// Unit tests for touch events with inertia - Chrome, FireFox, Safari.
it('should change scroll top for related scrollbar on touch start/move/end', fakeAsync(() => {
let evt = {
Expand Down

0 comments on commit 93ee5e8

Please sign in to comment.