diff --git a/src/utils/debounce.html b/src/utils/debounce.html index dec1366aa3..744a5dfec9 100644 --- a/src/utils/debounce.html +++ b/src/utils/debounce.html @@ -36,7 +36,7 @@ setConfig(asyncModule, cb) { this._asyncModule = asyncModule; this._callback = cb; - this._timer = this._asyncModule.run(this._callback); + this._timer = this._asyncModule.run(this.flush); }, /** diff --git a/test/unit/debounce.html b/test/unit/debounce.html index 25fa255aeb..1a8aa83d55 100644 --- a/test/unit/debounce.html +++ b/test/unit/debounce.html @@ -113,6 +113,17 @@ }); }); + test('flush debouncer', function(done) { + var callback = sinon.spy(); + var job = Polymer.Debouncer.debounce(null, Polymer.Async.microTask, callback); + + setTimeout(function() { + job.flush(); + assert.isTrue(callback.calledOnce, 'callback should be called once'); + done(); + }); + }); + test('different debouncers and multiple micro tasks', function(done) { var callback = sinon.spy(); var job1 = Polymer.Debouncer.debounce(null, Polymer.Async.microTask, callback);