mirror of
https://github.com/tenrok/OverlayScrollbars.git
synced 2026-06-20 20:50:36 +03:00
improve event listener test
This commit is contained in:
@@ -349,6 +349,7 @@ describe('overlayscrollbars', () => {
|
|||||||
const onUpdated = jest.fn();
|
const onUpdated = jest.fn();
|
||||||
const onUpdated2 = jest.fn();
|
const onUpdated2 = jest.fn();
|
||||||
const onDestroyed = jest.fn();
|
const onDestroyed = jest.fn();
|
||||||
|
const onScroll = jest.fn();
|
||||||
|
|
||||||
expect(onInitialized).not.toHaveBeenCalled();
|
expect(onInitialized).not.toHaveBeenCalled();
|
||||||
const osInstance = OverlayScrollbars(
|
const osInstance = OverlayScrollbars(
|
||||||
@@ -358,6 +359,7 @@ describe('overlayscrollbars', () => {
|
|||||||
initialized: onInitialized,
|
initialized: onInitialized,
|
||||||
updated: [onUpdated, onUpdated, onUpdated2],
|
updated: [onUpdated, onUpdated, onUpdated2],
|
||||||
destroyed: onDestroyed,
|
destroyed: onDestroyed,
|
||||||
|
scroll: onScroll,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -367,6 +369,14 @@ describe('overlayscrollbars', () => {
|
|||||||
expect(onUpdated).toHaveBeenCalledTimes(1);
|
expect(onUpdated).toHaveBeenCalledTimes(1);
|
||||||
expect(onUpdated2).toHaveBeenCalledTimes(1);
|
expect(onUpdated2).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
expect(onScroll).not.toHaveBeenCalled();
|
||||||
|
osInstance.elements().scrollEventElement.dispatchEvent(new Event('scroll'));
|
||||||
|
expect(onUpdated).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
osInstance.off('scroll', onScroll);
|
||||||
|
osInstance.elements().scrollEventElement.dispatchEvent(new Event('scroll'));
|
||||||
|
expect(onUpdated).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
osInstance.update(true);
|
osInstance.update(true);
|
||||||
|
|
||||||
expect(onUpdated).toHaveBeenCalledTimes(2);
|
expect(onUpdated).toHaveBeenCalledTimes(2);
|
||||||
|
|||||||
Reference in New Issue
Block a user