moy-fp
Version:
A functional programming library.
32 lines (27 loc) • 714 B
JavaScript
import __ from '../../src/Function/__'
/**
* Functor f => f -> a -> f a
*/
import of from '../../src/Functor/of'
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('of(not using __), array', () => {
expect(
of(Array)(12)
).toEqual([12])
})
test('of(not using __), identity', () => {
expect(
inspect(of(Identity)(12))
).toBe('Identity(12)')
})
test('of(using __), identity', () => {
expect(
inspect(of(__, 12)(Identity))
).toBe('Identity(12)')
})