Add _.debounce and _.throttle test for the this binding of func.

This commit is contained in:
John-David Dalton
2013-11-19 23:20:08 -08:00
parent 568af27be4
commit bf006473c0

View File

@@ -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() {