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