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

dropWhile.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
import { dropWhile as dropWhileRamda } from 'ramda'
import { compareCombinations } from './_internals/testUtils.js'import { dropWhile } from './dropWhile.js'
const list = [ 1, 2, 3, 4 ]
test('happy', () => { const predicate = x => x < 3 const result = dropWhile(predicate, list) expect(result).toEqual([ 3, 4 ])})
test('always true', () => { const predicate = () => true const result = dropWhileRamda(predicate, list) expect(result).toEqual([])})
test('always false', () => { const predicate = () => 0 const result = dropWhile(predicate)(list) expect(result).toEqual(list)})
test('works with string as iterable', () => { const iterable = 'foobar' const predicate = x => x !== 'b' const result = dropWhile(predicate, iterable) expect(result).toBe('bar')})
const possiblePredicates = [ null, undefined, () => 0, () => true, /foo/g, {}, [],]
const possibleIterables = [ null, undefined, [], {}, 1, '', 'foobar', [ '' ], [ 1, 2, 3, 4, 5 ],]
describe('brute force', () => { compareCombinations({ firstInput : possiblePredicates, callback : errorsCounters => { expect(errorsCounters).toMatchInlineSnapshot(` { "ERRORS_MESSAGE_MISMATCH": 15, "ERRORS_TYPE_MISMATCH": 14, "RESULTS_MISMATCH": 0, "SHOULD_NOT_THROW": 14, "SHOULD_THROW": 0, "TOTAL_TESTS": 63, } `) }, secondInput : possibleIterables, fn : dropWhile, fnRamda : dropWhileRamda, })})
rambda

Version Info

Tagged at
2 months ago