UNPKG

moy-fp

Version:
30 lines (25 loc) 909 B
import __ from '../../src/Function/__' /** * (a -> String) -> [a] -> [a] -> [a] */ import intersectionBy from '../../src/Relation/intersectionBy' test('intersectionBy(not using __), first empty array', () => { expect( intersectionBy(x => '' + x.id)([])([{id: 1}, {id: 2}, {id: 3}, {id: 4}]) ).toEqual([]) }) test('intersectionBy(not using __), second empty array', () => { expect( intersectionBy(x => '' + x.id)([{id: 1}, {id: 2}, {id: 3}, {id: 4}])([]) ).toEqual([]) }) test('intersectionBy(not using __), no empty array', () => { expect( intersectionBy(x => '' + x.id)([{id: 1}, {id: 3}, {id: 5}])([{id: 1}, {id: 2}, {id: 3}, {id: 4}]) ).toEqual([{id: 1}, {id: 3}]) }) test('intersectionBy(using __), no empty array', () => { expect( intersectionBy(x => '' + x.id, __, [{id: 1}, {id: 2}, {id: 3}, {id: 4}])([{id: 1}, {id: 3}, {id: 5}]) ).toEqual([{id: 1}, {id: 3}]) })