Skip to content

Commit

Permalink
增加单元测试 date.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
penn201500 committed Aug 6, 2024
1 parent 5868087 commit bd660f1
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions lib/is/date.test.js
Original file line number Diff line number Diff line change
@@ -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
});
});

0 comments on commit bd660f1

Please sign in to comment.