mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add _.debounce and _.throttle test for the this binding of func.
This commit is contained in:
32
test/test.js
32
test/test.js
@@ -5876,7 +5876,6 @@
|
|||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
|
|
||||||
QUnit.module('filter methods');
|
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');
|
QUnit.module('lodash.toArray');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user