1
Fork 0

typescript(option): test: added tests for bindAsync

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-23 16:01:51 +02:00 committed by prescientmoon
parent 1fc2ef32e4
commit 1a443ee349
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
2 changed files with 33 additions and 1 deletions

View file

@ -4,7 +4,7 @@ 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', () => {
it('should return None for any callback when given None', () => {
// act
const result = bind(Some, None)

View file

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