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

lenses.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
import { compose } from './compose.js'import { lensIndex } from './lensIndex.js'import { lensPath } from './lensPath.js'import { lensProp } from './lensProp.js'import { over } from './over.js'import { toUpper } from './toUpper.js'import { view } from './view.js'
test('composed lenses', () => { const testObject = { foo : [ 'a', 'b', 'c' ], baz : { a : 'x', b : 'y', }, } const propLens = lensProp('foo') const indexLens = lensIndex(2) const composedLens = compose(propLens, indexLens)
const pathLens = lensPath('baz.a') const composedPathLens = compose(lensPath('baz'), lensPath('a')) expect(view(composedPathLens, testObject)).toEqual(view(pathLens, testObject))
expect(view(composedLens)(testObject)).toBe('c')
expect(over( composedLens, toUpper, testObject )).toEqual({ ...testObject, foo : [ 'a', 'b', 'C' ], })})
rambda

Version Info

Tagged at
2 months ago