diff --git a/test/test.js b/test/test.js index 2119e9d00..b5b19ab7d 100644 --- a/test/test.js +++ b/test/test.js @@ -5876,7 +5876,6 @@ }); }()); - /*--------------------------------------------------------------------------*/ QUnit.module('filter methods'); @@ -7119,6 +7118,37 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.debounce and lodash.throttle'); + + _.forEach(['debounce', 'throttle'], function(methodName) { + var func = _[methodName]; + + asyncTest('_.' + methodName + ' should call `func` with the correct `this` binding', 1, function() { + if (!(isRhino && isModularize)) { + var actual = []; + + var object = { + 'func': func(function() { actual.push(this); }, 32) + }; + + object.func(); + if (methodName == 'throttle') { + object.func(); + } + setTimeout(function() { + deepEqual(actual, methodName == 'throttle' ? [object, object] : [object]); + QUnit.start(); + }, 64); + } + else { + skipTest(1); + QUnit.start(); + } + }); + }); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.toArray'); (function() {