diff --git a/packages/common/src/services/__tests__/resizer.service.spec.ts b/packages/common/src/services/__tests__/resizer.service.spec.ts index 9d026873c..62e7ca0c8 100644 --- a/packages/common/src/services/__tests__/resizer.service.spec.ts +++ b/packages/common/src/services/__tests__/resizer.service.spec.ts @@ -127,6 +127,21 @@ describe('Resizer Service', () => { }); }); + describe('dispose method', () => { + it('should clear resizeGrid timeout', (done) => { + service.init(gridStub, divContainer); + + const resizeGridWithDimensionsSpy = jest.spyOn(service, 'resizeGridWithDimensions'); + service.resizeGrid(1); + service.dispose(); + + setTimeout(() => { + expect(resizeGridWithDimensionsSpy).not.toHaveBeenCalled(); + done(); + }, 2); + }); + }); + describe('resizeGrid method', () => { beforeEach(() => { // @ts-ignore diff --git a/packages/common/src/services/resizer.service.ts b/packages/common/src/services/resizer.service.ts index 9418d4dbe..e16e52af2 100644 --- a/packages/common/src/services/resizer.service.ts +++ b/packages/common/src/services/resizer.service.ts @@ -87,6 +87,7 @@ export class ResizerService { if (this._intervalId) { clearInterval(this._intervalId); } + clearTimeout(this._timer); $(window).off(`resize.grid${this.gridUidSelector}`); }