2022-02-11 17:24:33 +00:00
|
|
|
import { expect } from 'chai'
|
2024-02-22 04:03:58 +00:00
|
|
|
import 'mocha'
|
2022-02-11 17:24:33 +00:00
|
|
|
import { validatedDate } from '../../src/utils/helpers'
|
|
|
|
|
|
|
|
|
|
describe('validatedDate', () => {
|
|
|
|
|
it('doesnt fail if the date is undefined', () => {
|
|
|
|
|
const result = validatedDate(undefined)
|
|
|
|
|
expect(result).to.be.undefined
|
|
|
|
|
})
|
|
|
|
|
it('returns a correct date if the date is in range', () => {
|
|
|
|
|
const d = new Date('2021-09-01')
|
|
|
|
|
const result = validatedDate(d)
|
|
|
|
|
expect(result).to.eql(d)
|
|
|
|
|
})
|
|
|
|
|
it('returns undefined if the date is out of range', () => {
|
|
|
|
|
const d = new Date('10001-09-01')
|
|
|
|
|
const result = validatedDate(d)
|
|
|
|
|
expect(result).to.be.undefined
|
|
|
|
|
})
|
|
|
|
|
})
|