From d3f2cd53213b153997b5a9175148b9a874a89160 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Wed, 16 Apr 2014 00:25:36 -0700 Subject: [PATCH] Add `_.intersection` and `_.union` tests. --- test/test.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/test/test.js b/test/test.js index e8518d88f..6c6c2ddd5 100644 --- a/test/test.js +++ b/test/test.js @@ -3878,6 +3878,8 @@ QUnit.module('lodash.intersection'); (function() { + var args = arguments; + test('should return the intersection of the given arrays', 1, function() { var actual = _.intersection([1, 3, 2], [5, 2, 1, 4], [2, 1]); deepEqual(actual, [1, 2]); @@ -3915,15 +3917,13 @@ } }); - test('should work with only secondary arguments', 1, function() { - deepEqual(_.intersection(null, [1, 3, 2], [2, 1]), [1, 2]); - }); - - test('should ignore individual secondary arguments', 1, function() { + test('should ignore values that are not arrays or `arguments` objects', 3, function() { var array = [0, 1, null, 3]; deepEqual(_.intersection(array, 3, null, { '0': 1 }), array); + deepEqual(_.intersection(null, array, null, [1, 2]), [1]); + deepEqual(_.intersection(null, array, null, args), [1, 3]); }); - }()); + }(1, 2, 3)); /*--------------------------------------------------------------------------*/ @@ -9407,6 +9407,8 @@ QUnit.module('lodash.union'); (function() { + var args = arguments; + test('should return the union of the given arrays', 1, function() { var actual = _.union([1, 3, 2], [5, 2, 1, 4], [2, 1]); deepEqual(actual, [1, 3, 2, 5, 4]); @@ -9417,16 +9419,13 @@ deepEqual(actual, [1, 3, 2, [5], [4]]); }); - test('should work with only secondary arguments', 1, function() { - var actual = _.union(null, [1, 3, 2], [5, 4]); - deepEqual(actual, [1, 3, 2, 5, 4]); - }); - - test('should ignore individual secondary arguments', 1, function() { + test('should ignore values that are not arrays or `arguments` objects', 3, function() { var array = [0]; deepEqual(_.union(array, 3, null, { '0': 1 }), array); + deepEqual(_.union(null, array, null, [2, 1]), [0, 2, 1]); + deepEqual(_.union(null, array, null, args), [0, 1, 2, 3]); }); - }()); + }(1, 2, 3)); /*--------------------------------------------------------------------------*/