Plato on Github
Report Home
dojo/tests/unit/debounce.js
Maintainability
80.62
Lines of code
52
Difficulty
12.09
Estimated Errors
0.28
Function weight
By Complexity
By SLOC
define([ 'intern!object', 'intern/chai!assert', '../../debounce', 'sinon' ], function (registerSuite, assert, debounce, sinon) { registerSuite({ name: 'dojo/debounce', sync: function () { var spy = sinon.spy(); var debouncer = debounce(spy, 100); debouncer(); debouncer(); debouncer(); setTimeout(this.async().callback(function () { assert.equal(spy.callCount, 1); }), 1000); }, async: function () { var spy = sinon.spy(); var debouncer = sinon.spy(debounce(spy, 100)); debouncer(); setTimeout(function () { debouncer(); }, 40); setTimeout(function () { debouncer(); }, 80); setTimeout(function () { debouncer(); }, 120); setTimeout(function () { debouncer(); }, 180); setTimeout(function () { debouncer(); }, 220); setTimeout(function () { debouncer(); }, 350); setTimeout(this.async().callback(function () { assert.ok(spy.callCount < debouncer.callCount); }), 2000); } }); });