forked from eighttrigrams/tsfun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
intersection.spec.ts
56 lines (31 loc) · 965 Bytes
/
intersection.spec.ts
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {intersection} from '../../src/set'
import {equal} from '../../src/comparator'
/**
* tsfun | intersection
*/
describe('intersection', () => {
it('what remove duplicates',() =>
expect(
intersection([[1,2,2,3],[2,3,4,5]]))
.toEqual([2,3]))
it('intersection',() =>
expect(
intersection([[1,2],[2,3],[2,4]]))
.toEqual([2]))
it('no intersection',() =>
expect(
intersection([[1,2],[3,4],[5,6]]))
.toEqual([]))
it('no intersection where only partial intersection',() =>
expect(
intersection([[1,2],[2,3],[3,4]]))
.toEqual([]))
it('empty array',() =>
expect(
intersection([]))
.toEqual([]))
it('intersectionBy', () =>
expect(
intersection<any>(equal, [[{a: 'a'}, {c: 'c'}], [{c: 'c'}, {d: 'd'}]]))
.toEqual([{c: 'c'}]))
})