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

anyPass.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
import { anyPass } from './anyPass.js'
test('happy', () => { const rules = [ x => typeof x === 'string', x => x > 10 ] const predicate = anyPass(rules) expect(predicate('foo')).toBeTrue() expect(predicate(6)).toBeFalse()})
test('happy', () => { const rules = [ x => typeof x === 'string', x => x > 10 ]
expect(anyPass(rules)(11)).toBeTrue() expect(anyPass(rules)(undefined)).toBeFalse()})
const obj = { a : 1, b : 2,}
test('when returns true', () => { const conditionArr = [ val => val.a === 1, val => val.a === 2 ]
expect(anyPass(conditionArr)(obj)).toBeTrue()})
test('when returns false + curry', () => { const conditionArr = [ val => val.a === 2, val => val.b === 3 ]
expect(anyPass(conditionArr)(obj)).toBeFalse()})
test('with empty predicates list', () => { expect(anyPass([])(3)).toBeFalse()})
test('works with multiple inputs', () => { const fn = function ( w, x, y, z ){ console.log( w, x, y, z )
return w + x === y + z } expect(anyPass([ fn ])( 3, 3, 3, 3 )).toBeTrue()})
rambda

Version Info

Tagged at
2 months ago