From bb187db49d6afba416e08e209e9a014a8afbef58 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 3 Dec 2012 22:32:19 -0800 Subject: [PATCH] Tweak `_.throttle` unit test and add `_.bind` test. Former-commit-id: b863194c661d97177bbcda9676699e9753f0db22 --- test/test.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/test.js b/test/test.js index f3dfb5d3a..e7993f767 100644 --- a/test/test.js +++ b/test/test.js @@ -209,6 +209,13 @@ bound(['b'], 'c'); deepEqual(args, ['a', ['b'], 'c']); }); + + test('ensure `new bound` is an instance of `func`', function() { + var func = function() {}, + bound = _.bind(func, {}); + + ok(new bound instanceof func); + }); }()); /*--------------------------------------------------------------------------*/ @@ -1796,8 +1803,9 @@ }); asyncTest('should trigger a trailing call when invoked in a loop', function() { - var counter = 0, - limit = 90, + var actual, + counter = 0, + limit = 80, throttled = _.throttle(function() { counter++; }, 32), start = new Date; @@ -1805,14 +1813,15 @@ throttled(); } setTimeout(function() { + actual = counter + 2; throttled(); throttled(); }, 64); setTimeout(function() { - ok(counter > 4); + equal(counter, actual); QUnit.start(); - }, 96); + }, 128); ok(counter > 1); });