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

allTrue.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
import { allTrue } from './allTrue.js'
test('with functions', () => { const foo = () => 1 const bar = () => false const baz = () => JSON.parse('{sda') const result = allTrue( foo, bar, baz ) expect(result).toBeFalse()})
test('usage with non boolean', () => { const foo = { a : 1 } const baz = [ 1, 2, 3 ]
const result = allTrue( foo, foo, baz ) expect(result).toBeTrue()})
test('usage with boolean', () => { const foo = 4 const baz = [ 1, 2, 3 ]
const result = allTrue(foo > 2, baz.length === 3) expect(result).toBeTrue()})
test('escapes early - case 0', () => { const foo = undefined const result = allTrue(foo, () => foo.a) expect(result).toBeFalse()})
test('escapes early - case 1', () => { const foo = null const result = allTrue(foo, () => foo.a) expect(result).toBeFalse()})
test('escapes early - case 2', () => { const foo = { a : 'bar' } const result = allTrue( foo, foo.a, foo.a.b ) expect(result).toBeFalse()})
test('escapes early - case 3', () => { const foo = { a : { b : 'foo' } } const result = allTrue( foo, () => foo.a, () => foo.a.b ) expect(result).toBeTrue()})
rambda

Version Info

Tagged at
2 months ago