moy-fp
Version:
A functional programming library.
34 lines (28 loc) • 857 B
JavaScript
import __ from '../../src/Function/__'
import Identity from '../../src/Functor/Identity/index'
/**
* Number -> Lens s a
* Lens s a = Functor f => (a -> f a) -> s -> f s
*/
import lensIndex from '../../src/Object/lensIndex'
/**
* 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('lensIndex(not using __), not execute', () => {
expect(
lensIndex(-1)
).toEqual(expect.any(Function))
})
test('lensIndex(not using __), execute', () => {
expect(
inspect(lensIndex(-1)(Identity)([1, 2, 3, 4]))
).toBe('Identity([1,2,3,4])')
})
test('lensIndex(using __), not execute', () => {
expect(
lensIndex(__)(-1)
).toEqual(expect.any(Function))
})