forked from eighttrigrams/tsfun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
subset_of.spec.ts
62 lines (34 loc) · 1.05 KB
/
subset_of.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
57
58
59
60
61
62
import {on, subsetOf} from '../../../src/comparator'
/**
* tsfun | subsetOf
*/
describe('subsetOf', () => {
it('subsetOf', () => {
expect(subsetOf([3, 2, 7])([2, 7])).toEqual(true)
expect(subsetOf([3, 2, 7], [2, 7])).toEqual(true)
});
it('not subsetOf', () =>
expect(
subsetOf([3, 2, 7])([2, 7, 1])
).toEqual(false));
it('same set - subset - elements duplicated', () =>
expect(
subsetOf([3, 1, 2])([1, 1])
).toEqual(true));
it('same set - same elements - different order', () =>
expect(
subsetOf([3, 3, 2, 2])([3, 2, 3, 2])
).toEqual(true));
it('length does not matter', () =>
expect(
subsetOf([1])([1, 1, 1])
).toEqual(true))
it('comparator', () =>
expect(
subsetOf(on('a'), [{a: 3}, {a: 4}], [{a: 4}])
).toEqual(true))
it('comparator - 2 param lists', () =>
expect(
subsetOf(on('a'), [{a: 3}, {a: 4}])([{a: 4}])
).toEqual(true))
})