From 01474fed0b430296d9a5c73ae370e8038d9980e4 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 22 May 2016 19:06:29 -0700 Subject: [PATCH] Add `fp.intersectionBy` and `fp.intersectionWith` tests. --- test/test-fp.js | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/test-fp.js b/test/test-fp.js index 776f29d2c..02aeb6cc5 100644 --- a/test/test-fp.js +++ b/test/test-fp.js @@ -1186,6 +1186,56 @@ /*--------------------------------------------------------------------------*/ + QUnit.module('fp.intersectionBy'); + + (function() { + QUnit.test('should have an argument order of `iteratee`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.intersectionBy(Math.floor, [2.1, 1.2], [2.3, 3.4]); + assert.deepEqual(actual, [2.1]); + }); + + QUnit.test('should provide the correct `iteratee` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.intersectionBy(function() { + args || (args = slice.call(arguments)); + })([2.1, 1.2], [2.3, 3.4]); + + assert.deepEqual(args, [2.3]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + + QUnit.module('fp.intersectionWith'); + + (function() { + QUnit.test('should have an argument order of `comparator`, `array`, then `values`', function(assert) { + assert.expect(1); + + var actual = fp.intersectionWith(fp.eq)([2, 1])([2, 3]); + assert.deepEqual(actual, [2]); + }); + + QUnit.test('should provide the correct `comparator` arguments', function(assert) { + assert.expect(1); + + var args; + + fp.intersectionWith(function() { + args || (args = slice.call(arguments)); + })([2, 1])([2, 3]); + + assert.deepEqual(args, [2, 2]); + }); + }()); + + /*--------------------------------------------------------------------------*/ + QUnit.module('fp.invoke'); (function() {