UNPKG

moy-fp

Version:
59 lines (50 loc) 1.03 kB
import IO from '../../../src/Functor/IO/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 => `IO(${x.unsafePerformIO()})` test('test IO', () => { expect( inspect(IO(() => 12)) ).toBe('IO(12)') }) test('test of', () => { expect( inspect(IO.of(12)) ).toBe('IO(12)') }) test('test map', () => { expect( inspect(IO.of(12).map(x => x + 1)) ).toBe('IO(13)') }) test('test join', () => { expect( inspect(IO.of( IO.of(12) ).join()) ).toBe('IO(12)') }) test('test chain', () => { expect( inspect(IO.of(12).chain( x => IO.of(x + 1) )) ).toBe('IO(13)') }) test('test ap', () => { expect( inspect(IO.of(x => x + 1).ap( IO.of(12) )) ).toBe('IO(13)') }) test('test Object.prototype.toString.call',() => { expect( Object.prototype.toString.call( IO.of(12) ) ).toBe('[object IO]') })