Skip to content

Commit

Permalink
Add failing test case for current _.debounce patch.
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Nov 6, 2013
1 parent 3f0abe7 commit 496add1
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1530,6 +1530,34 @@
QUnit.start();
}
});

asyncTest('should call `trailing` with the correct `arguments` and `this` binding', 1, function() {
if (!(isRhino && isModularize)) {
var args,
count = 0,
object = {};

var debounced = _.debounce(function(value) {
args = [this];
push.apply(args, arguments);
return ++count != 2;
}, 32, { 'leading': true, 'maxWait': 64 });

while (true) {
if (!debounced.call(object, 'a')) {
break;
}
}
setTimeout(function() {
deepEqual(args, [object, 'a']);
QUnit.start();
}, 256);
}
else {
skipTest(1);
QUnit.start();
}
});
}());

/*--------------------------------------------------------------------------*/
Expand Down

0 comments on commit 496add1

Please sign in to comment.