-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwriter.test.ts
40 lines (37 loc) · 1.06 KB
/
writer.test.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
import * as W from 'fp-ts/Writer'
import * as Wri from './writer'
describe.skip('writer', () => {
it('one', () => {
expect(Wri.one(1)()).toEqual([1, []])
})
it('two', () => {
expect(Wri.two(Wri.logWriterM.of(10))()).toEqual([20, []])
expect(Wri.two(() => [10, ['horse']])()).toEqual([20, ['horse']])
})
it('three', () => {
expect(Wri.three(Wri.logWriterM.of(10))).toEqual(10)
expect(Wri.three(() => [10, ['horse']])).toEqual(10)
})
it('four', () => {
expect(Wri.four(Wri.logWriterM.of(10))).toEqual([])
expect(Wri.four(() => [10, ['horse']])).toEqual(['horse'])
})
it('five', () => {
expect(Wri.five('horse')(() => [10, ['mr']])()).toEqual([
10,
['mr', 'horse'],
])
expect(Wri.five('horse')(() => [10, []])()).toEqual([
10,
['horse'],
])
})
it('six', () => {
const wA: W.Writer<string[], number> = () => [10, ['dog']]
const wB: W.Writer<string[], number> = () => [20, ['log']]
expect(Wri.six(a => b => a - b, wA, wB)()).toEqual([
-10,
['dog', 'log'],
])
})
})