test: fix some test case (#2301)

This commit is contained in:
Richer 2024-10-13 13:33:47 +08:00 committed by GitHub
parent 7ef54f413b
commit 7881069894
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -95,21 +95,21 @@ test('should validate boolean value', (t) => {
})
test('should validate date', (t) => {
if (Number(process.versions.napi) >= 5) {
if (Number(process.versions.napi) < 5) {
return t.pass()
}
const fx = new Date('2016-12-24')
t.is(validateDate(new Date()), fx.valueOf())
t.is(validateDate(fx), fx.valueOf())
t.is(validateDateTime(fx), 1)
// @ts-expect-error
t.throws(() => validateDate(1), {
code: 'InvalidArg',
message: 'Expected a Date value',
message: 'Expected a Date object',
})
// @ts-expect-error
t.throws(() => validateDateTime(2), {
code: 'InvalidArg',
message: 'Expected a Date value',
message: 'Expected a Date object',
})
})