moy-fp
Version:
A functional programming library.
26 lines (22 loc) • 655 B
JavaScript
import __ from '../../src/Function/__'
/**
* Functor f => (a -> b) -> f a -> f b
*/
import map from '../../src/Functor/map'
import Identity from '../../src/Functor/Identity/index'
/**
* 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(${x.value})`
test('map(not using __), array', () => {
expect(
map(x => x + 1)([1, 2, 3, 4])
).toEqual([2, 3, 4, 5])
})
test('map(not using __), identity', () => {
expect(
inspect(map(x => x + 1)(Identity.of(12)))
).toBe('Identity(13)')
})