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