moy-fp
Version:
A functional programming library.
36 lines (30 loc) • 921 B
JavaScript
import __ from '../../src/Function/__'
/**
* [a] -> [a] -> [a]
*/
import intersection from '../../src/Relation/intersection'
test('intersection(not using __), first empty array', () => {
expect(
intersection([])([{a: 1}, {a: 2}, {a: 3}])
).toEqual([])
})
test('intersection(not using __), second empty array', () => {
expect(
intersection([{a: 1}, {a: 2}, {a: 3}])([])
).toEqual([])
})
test('intersection(not using __), no empty array', () => {
expect(
intersection([{a: 2}, {a: 4}])([{a: 1}, {a: 2}, {a: 3}])
).toEqual([{a: 2}])
})
test('intersection(not using __), no empty array and mix item type', () => {
expect(
intersection([false, 2, {a: 2}, [2], {a: 4}])(['false', {a: 1}, '2', {a: 3}, {a: 2}])
).toEqual([{a: 2}])
})
test('intersection(using __), no empty array', () => {
expect(
intersection(__, [{a: 1}, {a: 2}, {a: 3}])([{a: 2}, {a: 4}])
).toEqual([{a: 2}])
})