moy-fp
Version:
A functional programming library.
33 lines (28 loc) • 841 B
JavaScript
import __ from '../../src/Function/__'
import Identity from '../../src/Functor/Identity/index'
/**
* k -> Lens s a
* Lens s a = Functor f => (a -> f a) -> s -> f s
*/
import lensProp from '../../src/Object/lensProp'
/**
* you should not use this similar funciton to get value anywhere in your application
* if you must need the inner value, you may need Comonad
* here is just simple for test
*/
const inspect = x => `Identity(${JSON.stringify(x.value)})`
test('lensProp(not using __), not execute', () => {
expect(
lensProp('a')
).toEqual(expect.any(Function))
})
test('lensProp(not using __), execute', () => {
expect(
inspect(lensProp('a')(Identity)({a: 1}))
).toEqual('Identity({"a":1})')
})
test('lensProp(using __), not execute', () => {
expect(
lensProp(__)('a')
).toEqual(expect.any(Function))
})