1
Fork 0

typescript(option): test: wrote tests for the 'withDefault' helper

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-26 16:04:36 +02:00 committed by prescientmoon
parent 089ba6148f
commit 6f36c3d826
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View 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)
})
})