Files
Maurice 724c88c201 style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
2026-10-10 21:23:37 +02:00

24 lines
917 B
TypeScript

import { appClock } from '../../../src/nest/common/timezoneService';
import { afterEach, describe, expect, it } from 'vitest';
describe('appClock', () => {
const realTz = process.env.TZ;
afterEach(() => {
process.env.TZ = realTz;
});
it('APPCLOCK-001: reads the date and time where the instance runs, not in UTC', () => {
process.env.TZ = 'Australia/Sydney';
// 23:30 UTC on the 6th is 10:30 on the 7th in Sydney.
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-07', time: '10:30' });
});
it('APPCLOCK-002: falls back to UTC without a TZ, and for one Intl does not know', () => {
delete process.env.TZ;
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-06', time: '23:30' });
process.env.TZ = 'Not/AZone';
expect(appClock(new Date('2026-10-06T23:30:00Z'))).toEqual({ date: '2026-10-06', time: '23:30' });
});
});