typescript(option): test: added tests for bindAsync
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
1fc2ef32e4
commit
1a443ee349
|
@ -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)
|
||||
|
||||
|
|
32
typescript/option/src/helpers/bindAsync.test.ts
Normal file
32
typescript/option/src/helpers/bindAsync.test.ts
Normal 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))
|
||||
})
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue