Skip to content

Commit 40e01c7

Browse files
authored
Merge pull request #315 from rwjblue/regression-test-for-debounce-within-debounce
Add test for canceling debounce inside debounce.
2 parents d663494 + 37ca725 commit 40e01c7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

tests/debounce-test.ts

+23
Original file line numberDiff line numberDiff line change
@@ -538,3 +538,26 @@ QUnit.test('onError', function(assert) {
538538

539539
bb.debounce(null, () => { throw new Error('QUnit.test error'); }, 20);
540540
});
541+
542+
QUnit.test('debounce within a debounce can be canceled GH#183', function(assert) {
543+
assert.expect(3);
544+
545+
let done = assert.async();
546+
let bb = new Backburner(['zomg']);
547+
548+
let steps: string[] = [];
549+
let foo = () => {
550+
assert.ok(true, 'foo called');
551+
return bb.debounce(bar, 10);
552+
};
553+
554+
let bar = () => {
555+
assert.ok(true, 'bar called');
556+
let timer = foo();
557+
bb.cancel(timer);
558+
559+
setTimeout(done, 10);
560+
};
561+
562+
foo();
563+
});

0 commit comments

Comments
 (0)