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

dropRepeatsWith.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
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import { dropRepeatsWith as dropRepeatsWithRamda, eqProps } from 'ramda'
import { compareCombinations } from './_internals/testUtils.js'import { dropRepeatsWith } from './dropRepeatsWith.js'import { path } from './path.js'import { prop } from './prop.js'
const eqI = eqProps('i')
test('happy', () => { const list = [ { i : 1 }, { i : 2 }, { i : 2 }, { i : 3 } ] const expected = [ { i : 1 }, { i : 2 }, { i : 3 } ] const result = dropRepeatsWith(eqI, list) expect(result).toEqual(expected)})
test('readme example', () => { const list = [ { a : 1, b : 2, }, { a : 1, b : 3, }, { a : 2, b : 4, }, ] const result = dropRepeatsWith(prop('a'), list) expect(result).toEqual([ { a : 1, b : 2, }, ])})
test('keeps elements from the left predicate input', () => { const list = [ { i : 1, n : 1, }, { i : 1, n : 2, }, { i : 1, n : 3, }, { i : 4, n : 1, }, { i : 4, n : 2, }, ] const expected = [ { i : 1, n : 1, }, { i : 4, n : 1, }, ] const result = dropRepeatsWith(eqI)(list) expect(result).toEqual(expected)})
const possiblePredicates = [ null, undefined, x => x + 1, x => true, x => false, x => '', path([ 'a', 'b' ]),]const possibleLists = [ null, undefined, [], [ 1 ], [ { a : { b : 1 } }, { a : { b : 1 } } ], [ /foo/g, /foo/g ],]
describe('brute force', () => { compareCombinations({ firstInput : possiblePredicates, secondInput : possibleLists, callback : errorsCounters => { expect(errorsCounters).toMatchInlineSnapshot(` { "ERRORS_MESSAGE_MISMATCH": 4, "ERRORS_TYPE_MISMATCH": 14, "RESULTS_MISMATCH": 0, "SHOULD_NOT_THROW": 0, "SHOULD_THROW": 0, "TOTAL_TESTS": 42, } `) }, fn : dropRepeatsWith, fnRamda : dropRepeatsWithRamda, })})
rambda

Version Info

Tagged at
2 months ago