Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 799a0e3

Browse files
committed
Added a test for the on destroy hook
Should cancel any pending timers
1 parent 185dbe7 commit 799a0e3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

source/behaviors/autosave/autosave.tests.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ describe('AutosaveDirective', () => {
4848
});
4949
});
5050

51+
describe('ngOnDestroy', () => {
52+
it('should cancel the current autosave on destroy', rlFakeAsync((): void => {
53+
const autosaveSpy = sinon.spy();
54+
autosave.autosave = autosaveSpy;
55+
autosave.setDebounce();
56+
57+
autosave.ngOnDestroy();
58+
59+
rlTick(DEFAULT_AUTOSAVE_DEBOUNCE);
60+
flushMicrotasks();
61+
62+
sinon.assert.notCalled(autosaveSpy);
63+
}));
64+
});
65+
5166
describe('setDebounce', () => {
5267
it('should set a timer to autosave after the specified duration', rlFakeAsync((): void => {
5368
const autosaveSpy = sinon.spy();

0 commit comments

Comments
 (0)