mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-05-28 22:44:06 +03:00
add scroll event listener test
This commit is contained in:
@@ -302,17 +302,25 @@ describe('overlayscrollbars', () => {
|
||||
const onUpdated = jest.fn();
|
||||
const onUpdated2 = jest.fn();
|
||||
const onDestroyed = jest.fn();
|
||||
const onScroll = jest.fn();
|
||||
const osInstance = OverlayScrollbars(div, {});
|
||||
|
||||
osInstance.on('initialized', onInitialized);
|
||||
osInstance.on('updated', [onUpdated, onUpdated, onUpdated2]);
|
||||
osInstance.on('destroyed', onDestroyed);
|
||||
osInstance.on('scroll', onScroll);
|
||||
|
||||
expect(onInitialized).not.toHaveBeenCalled();
|
||||
|
||||
expect(onUpdated).not.toHaveBeenCalled();
|
||||
expect(onUpdated2).not.toHaveBeenCalled();
|
||||
|
||||
expect(onScroll).not.toHaveBeenCalled();
|
||||
|
||||
osInstance.elements().scrollEventElement.dispatchEvent(new Event('scroll'));
|
||||
expect(onScroll).toHaveBeenCalledTimes(1);
|
||||
expect(onScroll).toHaveBeenLastCalledWith(osInstance, expect.any(Object));
|
||||
|
||||
osInstance.update();
|
||||
expect(onUpdated).not.toHaveBeenCalled();
|
||||
expect(onUpdated2).not.toHaveBeenCalled();
|
||||
@@ -330,8 +338,10 @@ describe('overlayscrollbars', () => {
|
||||
|
||||
// after destruction no further events are triggered
|
||||
osInstance.update(true);
|
||||
osInstance.elements().scrollEventElement.dispatchEvent(new Event('scroll'));
|
||||
expect(onUpdated).toHaveBeenCalledTimes(1);
|
||||
expect(onUpdated2).toHaveBeenCalledTimes(1);
|
||||
expect(onScroll).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
test('off', () => {
|
||||
|
||||
Reference in New Issue
Block a user