typescript(option): test: wrote tests for flat
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
f8e501b876
commit
e241784601
25
typescript/option/src/helpers/flat.test.ts
Normal file
25
typescript/option/src/helpers/flat.test.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { expect } from 'chai'
|
||||
import { flat } from './flat'
|
||||
import { None, Some } from '../types'
|
||||
import { someX } from '../../test/constants'
|
||||
|
||||
describe('The flat helper', () => {
|
||||
it('should return None when given None', () => {
|
||||
// act
|
||||
const result = flat(None)
|
||||
|
||||
// assert
|
||||
expect(result).to.equal(None)
|
||||
})
|
||||
|
||||
it('should return the inner Some(x) when given Some(Some(x))', () => {
|
||||
// arrange
|
||||
const value = Some(someX)
|
||||
|
||||
// act
|
||||
const result = flat(value)
|
||||
|
||||
// assert
|
||||
expect(result).to.equal(someX)
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue