From b5897fdb62bb8fb6ef5f4d00459aded4fe21b32e Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Fri, 10 Oct 2014 09:46:25 -0700 Subject: [PATCH] Add more lazy`_.drop`, `_.dropRight`, `_.take`, `_.takeRight` tests. --- test/test.js | 56 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 50 insertions(+), 6 deletions(-) diff --git a/test/test.js b/test/test.js index cb51db138..e3ac7574c 100644 --- a/test/test.js +++ b/test/test.js @@ -3083,13 +3083,19 @@ } }); - test('should work in a lazy chain sequence', 1, function() { + test('should work in a lazy chain sequence', 2, function() { if (!isNpm) { - var actual = _(array).filter(function(value) {return value > 1; }).drop(1).value(); + var array = [1, 2, 3, 4], + predicate = function(value) {return value > 1; }, + actual = _(array).filter(predicate).drop(2).value(); + + deepEqual(actual, [4]); + + actual = _(array).filter(predicate).drop().dropRight().value(); deepEqual(actual, [3]); } else { - skipTest(1); + skipTest(2); } }); }()); @@ -3147,13 +3153,19 @@ } }); - test('should work in a lazy chain sequence', 1, function() { + test('should work in a lazy chain sequence', 2, function() { if (!isNpm) { - var actual = _(array).filter(function(value) {return value < 3; }).dropRight(1).value(); + var array = [1, 2, 3, 4], + predicate = function(value) {return value < 4; }, + actual = _(array).filter(predicate).dropRight(2).value(); + deepEqual(actual, [1]); + + actual = _(array).filter(predicate).dropRight().drop().value(); + deepEqual(actual, [2]); } else { - skipTest(1); + skipTest(2); } }); }()); @@ -3719,6 +3731,22 @@ skipTest(2); } }); + + test('should work in a lazy chain sequence', 2, function() { + if (!isNpm) { + var array = [1, 2, 3, 4], + predicate = function(value) {return value > 1; }, + actual = _(array).filter(predicate).take().value(); + + deepEqual(actual, [2]); + + actual = _(array).filter(predicate).take(2).takeRight().value(); + deepEqual(actual, [3]); + } + else { + skipTest(2); + } + }); }()); /*--------------------------------------------------------------------------*/ @@ -3773,6 +3801,22 @@ skipTest(2); } }); + + test('should work in a lazy chain sequence', 2, function() { + if (!isNpm) { + var array = [1, 2, 3, 4], + predicate = function(value) {return value < 4; }, + actual = _(array).filter(predicate).takeRight().value(); + + deepEqual(actual, [3]); + + actual = _(array).filter(predicate).takeRight(2).take().value(); + deepEqual(actual, [2]); + } + else { + skipTest(2); + } + }); }()); /*--------------------------------------------------------------------------*/