From bd660f115401579a8351ab5bcd3f15fb06e068ba Mon Sep 17 00:00:00 2001 From: penn Date: Tue, 6 Aug 2024 12:35:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8D=95=E5=85=83=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=20date.test.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/is/date.test.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/is/date.test.js diff --git a/lib/is/date.test.js b/lib/is/date.test.js new file mode 100644 index 0000000..dfa130b --- /dev/null +++ b/lib/is/date.test.js @@ -0,0 +1,19 @@ +import { it, expect, describe } from 'vitest'; +import yd_is_date from './date.js'; + +describe('yd_is_date', () => { + it('should return true for Date objects', () => { + expect(yd_is_date(new Date())).toBe(true); + }); + + it('should return false for objects that are not Date', () => { + expect(yd_is_date({})).toBe(false); + expect(yd_is_date([])).toBe(false); + expect(yd_is_date('2024-01-01')).toBe(false); // string + expect(yd_is_date('2024-01-01T00:00:00Z')).toBe(false); + expect(yd_is_date(1)).toBe(false); + expect(yd_is_date(null)).toBe(false); + expect(yd_is_date(undefined)).toBe(false); + expect(yd_is_date(true)).toBe(false); // boolean + }); +});