Skip to content

Commit

Permalink
fix(resizer): clear pending resizeGrid on dispose
Browse files Browse the repository at this point in the history
  • Loading branch information
jr01 committed Sep 21, 2021
1 parent ca894c0 commit 07ed6a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/common/src/services/__tests__/resizer.service.spec.ts
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions packages/common/src/services/resizer.service.ts
Expand Up @@ -87,6 +87,7 @@ export class ResizerService {
if (this._intervalId) {
clearInterval(this._intervalId);
}
clearTimeout(this._timer);

$(window).off(`resize.grid${this.gridUidSelector}`);
}
Expand Down

0 comments on commit 07ed6a0

Please sign in to comment.