chore: relocate backend into apps/api ahead of monorepo merge

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-24 12:20:40 +08:00
co-authored by Claude Sonnet 5
parent af44598df6
commit eaa6d2276a
388 changed files with 0 additions and 13998 deletions
+74
View File
@@ -0,0 +1,74 @@
'use strict';
const { fmtDate, fmtDateTime, fmtTime } = require('../../utils/datetime.util');
const ISO = '2026-06-20T14:30:00.000Z'; // Saturday, June 20, 2026, 2:30 PM UTC
// ── fmtDate ───────────────────────────────────────────────────────────────────
describe('fmtDate()', () => {
test('null → returns —', () => {
expect(fmtDate(null)).toBe('—');
});
test('empty string → returns —', () => {
expect(fmtDate('')).toBe('—');
});
test('formats year correctly', () => {
expect(fmtDate(ISO)).toContain('2026');
});
test('formats month correctly (June)', () => {
expect(fmtDate(ISO)).toContain('June');
});
test('formats day correctly (20)', () => {
expect(fmtDate(ISO)).toContain('20');
});
test('accepts Date object as well as ISO string', () => {
const d = new Date(ISO);
expect(fmtDate(d)).toContain('2026');
});
});
// ── fmtDateTime ───────────────────────────────────────────────────────────────
describe('fmtDateTime()', () => {
test('null → returns —', () => {
expect(fmtDateTime(null)).toBe('—');
});
test('contains date portion', () => {
expect(fmtDateTime(ISO)).toContain('2026');
expect(fmtDateTime(ISO)).toContain('June');
});
test('contains time portion (2:30 PM UTC)', () => {
const out = fmtDateTime(ISO);
expect(out).toMatch(/2:30/);
expect(out).toContain('UTC');
});
});
// ── fmtTime ───────────────────────────────────────────────────────────────────
describe('fmtTime()', () => {
test('null → returns —', () => {
expect(fmtTime(null)).toBe('—');
});
test('outputs time with AM/PM', () => {
expect(fmtTime(ISO)).toMatch(/\d+:\d{2}\s*(AM|PM)/);
});
test('contains timezone label (UTC)', () => {
expect(fmtTime(ISO)).toContain('UTC');
});
test('locale option changes output', () => {
const en = fmtTime(ISO, { locale: 'en-US' });
expect(en).toBeTruthy();
});
});