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

takeWhile.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
import { takeWhile as takeWhileRamda } from 'ramda'
import { compareCombinations } from './_internals/testUtils.js'import { takeWhile } from './takeWhile.js'
const list = [ 1, 2, 3, 4, 5 ]
test('happy', () => { const result = takeWhile(x => x < 3, list) expect(result).toEqual([ 1, 2 ])})
test('always true', () => { const result = takeWhile(x => true)(list) expect(result).toEqual(list)})
test('always false', () => { const result = takeWhile(x => 0, list) expect(result).toEqual([])})
test('with string', () => { const result = takeWhile(x => x !== 'b', 'foobar') expect(result).toBe('foo')})
const possiblePredicates = [ null, undefined, () => 0, () => true, x => x !== 'b', /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": 16, "RESULTS_MISMATCH": 0, "SHOULD_NOT_THROW": 16, "SHOULD_THROW": 0, "TOTAL_TESTS": 72, } `) }, secondInput : possibleIterables, fn : takeWhile, fnRamda : takeWhileRamda, })})
rambda

Version Info

Tagged at
2 months ago