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