deno.land / x / rambda@v9.1.1 / source / over.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
import { assoc } from './assoc.js'import { lens } from './lens.js'import { lensIndex } from './lensIndex.js'import { lensPath } from './lensPath.js'import { over } from './over.js'import { prop } from './prop.js'import { toUpper } from './toUpper.js'
const testObject = { foo : 'bar', baz : { a : 'x', b : 'y', },}
test('assoc lens', () => { const assocLens = lens(prop('foo'), assoc('foo')) const result = over( assocLens, toUpper, testObject ) const expected = { ...testObject, foo : 'BAR', } expect(result).toEqual(expected)})
test('path lens', () => { const pathLens = lensPath('baz.a') const result = over( pathLens, toUpper, testObject ) const expected = { ...testObject, baz : { a : 'X', b : 'y', }, } expect(result).toEqual(expected)})
test('index lens', () => { const indexLens = lensIndex(0) const result = over(indexLens, toUpper)([ 'foo', 'bar' ]) expect(result).toEqual([ 'FOO', 'bar' ])})
rambda

Version Info

Tagged at
2 months ago