deno.land / x / rambda@v9.1.1 / source / intersection.spec.js

intersection.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { intersection as intersectionRamda } from 'ramda'
import { intersection } from './intersection.js'
test('intersection', () => { const list1 = [ 1, 2, 3, 4 ] const list2 = [ 3, 4, 5, 6 ] expect(intersection(list1)(list2)).toEqual([ 3, 4 ])
expect(intersection([], [])).toEqual([])})
test('intersection with objects', () => { const list1 = [ { id : 1 }, { id : 2 }, { id : 3 }, { id : 4 } ] const list2 = [ { id : 3 }, { id : 4 }, { id : 5 }, { id : 6 } ] expect(intersection(list1)(list2)).toEqual([ { id : 3 }, { id : 4 } ])})
test('order is the same as in Ramda', () => { const list = [ 'a', 'b', 'c', 'd' ]
expect(intersectionRamda(list, [ 'b', 'c' ])).toEqual([ 'b', 'c' ]) expect(intersection(list, [ 'b', 'c' ])).toEqual([ 'b', 'c' ])
expect(intersection(list, [ 'c', 'b' ])).toEqual([ 'c', 'b' ]) expect(intersectionRamda(list, [ 'c', 'b' ])).toEqual([ 'c', 'b' ])})
rambda

Version Info

Tagged at
2 months ago