Files
gongxue-base/apps/server/src/database/date-normalization.spec.ts

16 lines
516 B
TypeScript

import { normalizeDateOnly } from './date-normalization';
describe('normalizeDateOnly', () => {
it('keeps date-only values unchanged', () => {
expect(normalizeDateOnly('2026-07-02')).toBe('2026-07-02');
});
it('converts legacy ISO timestamps to their UTC calendar date', () => {
expect(normalizeDateOnly('2026-07-01T16:00:00.000Z')).toBe('2026-07-01');
});
it('rejects unsupported date formats', () => {
expect(() => normalizeDateOnly('07/01/2026')).toThrow('无效日期格式');
});
});