From a210377f35b6cc6117a4c5ba50cf92b65ba8a114 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 3 Oct 2012 20:12:03 -0700 Subject: [PATCH] Add unit tests for passing falsey values to `_.initial` and `_.rest`. Former-commit-id: 9d5d4960c175a3dd90af977b605ce309bc6446d3 --- test/test.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/test/test.js b/test/test.js index 9fdc99b15..2a4e02a8e 100644 --- a/test/test.js +++ b/test/test.js @@ -646,6 +646,15 @@ var array = [1, 2, 3]; deepEqual(_.initial(array, 0), []); }); + + test('should allow a falsey `array` argument', function() { + _.each(falsey, function(index, value) { + try { + var actual = index ? _.initial(value) : _.initial(); + } catch(e) { } + deepEqual(actual, []); + }) + }); }()); /*--------------------------------------------------------------------------*/ @@ -1291,6 +1300,21 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.rest'); + + (function() { + test('should allow a falsey `array` argument', function() { + _.each(falsey, function(index, value) { + try { + var actual = index ? _.rest(value) : _.rest(); + } catch(e) { } + deepEqual(actual, []); + }) + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('lodash.size'); (function() {