-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
test.ts
31 lines (25 loc) · 824 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* eslint-env mocha */
import assert from 'assert'
import isValid from '.'
describe('isValid', function () {
it('returns true if the given date is valid', function () {
const result = isValid(new Date())
assert(result === true)
})
it('returns false if the given date is invalid', function () {
const result = isValid(new Date(''))
assert(result === false)
})
it('accepts a timestamp', function () {
assert(isValid(new Date(2014, 1 /* Feb */, 11).getTime()) === true)
assert(isValid(NaN) === false)
})
it('treats null as an invalid date', function () {
const result = isValid(null)
assert(result === false)
})
it('throws TypeError exception if passed less than 1 argument', function () {
// @ts-expect-error
assert.throws(isValid.bind(null), TypeError)
})
})