File size: 619 Bytes
eb67da4 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
'use strict';
var intersection = require('../../../src/functions/intersection');
test('it should find intersection between two array', function() {
var actual = intersection([2, 1], [2]);
expect(actual).toStrictEqual([2]);
});
test('it should keep the order of the first array', function() {
expect(intersection([0, 1, 2, 3, 4], [4, 0, 3])).toStrictEqual([0, 3, 4]);
});
test('it should not produce duplicate primitive values', function() {
expect(intersection([0, 0, 1, 2], [0, 2])).toStrictEqual([0, 2]);
expect(intersection(['0', '0', '1', '2'], ['0', '2'])).toStrictEqual([
'0',
'2'
]);
});
|