Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate isValid function to TS (#2308)
Co-authored-by: Tetiana <ttobin@protonmail.ch> Co-authored-by: Sasha Koss <koss@nocorp.me>
- Loading branch information
1 parent
0e5d948
commit 237f831
Showing
3 changed files
with
41 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) | ||
}) | ||
}) |