/
either-spec.ts
44 lines (43 loc) · 1.04 KB
/
either-spec.ts
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
import {either} from 'rambda'
describe('R.either', () => {
it('with passed type', () => {
const fn = either<number>(
x => x > 1,
x => x % 2 === 0
)
fn // $ExpectType Predicate<number>
const result = fn(2) // $ExpectType boolean
result // $ExpectType boolean
})
it('with passed type - curried', () => {
const fn = either<number>(x => x > 1)(x => x % 2 === 0)
fn // $ExpectType Predicate<number>
const result = fn(2)
result // $ExpectType boolean
})
it('no type passed', () => {
const fn = either(
x => {
x // $ExpectType any
return x > 1
},
x => {
x // $ExpectType any
return x % 2 === 0
}
)
const result = fn(2)
result // $ExpectType boolean
})
it('no type passed - curried', () => {
const fn = either((x: number) => {
x // $ExpectType number
return x > 1
})((x: number) => {
x // $ExpectType number
return x % 2 === 0
})
const result = fn(2)
result // $ExpectType boolean
})
})