1
Fork 0

typescript(option): test: added tests for bind

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-23 15:59:19 +02:00 committed by prescientmoon
parent dcd55c5047
commit 1fc2ef32e4
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
4 changed files with 498 additions and 2 deletions
typescript/option/src/helpers

View file

@ -0,0 +1,32 @@
import { expect } from 'chai'
import { bind } from './bind'
import { Some, None } from '../types'
import { constantly } from '@thi.ng/compose'
describe('The bind helper', () => {
it('should return none for any callback when given None', () => {
// act
const result = bind(Some, None)
// assert
expect(result).to.equal(None)
})
describe('When given Some', () => {
it('should return None if the callback returns None', () => {
// act
const result = bind(constantly(None), Some(3))
// assert
expect(result).to.equal(None)
})
it('should return Some if the callback returns Some', () => {
// act
const result = bind(x => Some(x + 1), Some(3))
// assert
expect(result).to.equal(Some(4))
})
})
})