Skip to main content
Module

x/rambda/over.spec.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { assoc } from './assoc'import { lens } from './lens'import { lensIndex } from './lensIndex'import { lensPath } from './lensPath'import { over } from './over'import { prop } from './prop'import { toUpper } from './toUpper'
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' ])})