1
Fork 0

typescript(option): test: added tests for exists

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-12-23 16:11:20 +02:00 committed by prescientmoon
parent ca91cd20f8
commit 2b681bfa7f
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4

View file

@ -0,0 +1,33 @@
import { expect } from 'chai'
import { exists } from './exists'
import { constantly } from '@thi.ng/compose'
import { None, Some } from '../types'
import { x } from '../../test/constants'
describe('The exists helper', () => {
it('should return false when given None', () => {
// act
const result = exists(constantly(true), None)
// assert
expect(result).to.equal(false)
})
describe('When given Some', () => {
it('should return true if the callback returns true', () => {
// act
const result = exists(constantly(true), Some(x))
// assert
expect(result).to.equal(true)
})
it('should return false if the callback returns false', () => {
// act
const result = exists(constantly(false), Some(x))
// assert
expect(result).to.equal(false)
})
})
})