import assert from 'node:assert/strict'; import test from 'node:test'; import { formatDeadline } from './deadlineFormat.js'; test('ISO closes_at is formatted as "до DD.MM HH:mm" in local time', () => { const closesAt = new Date(2026, 9, 31, 18, 0, 0); // 31 октября, 18:00, локальное время assert.equal(formatDeadline(closesAt.toISOString()), 'до 31.10 18:00'); }); test('single-digit day/month/hour/minute are zero-padded', () => { const closesAt = new Date(2026, 0, 5, 9, 3, 0); // 5 января, 09:03 assert.equal(formatDeadline(closesAt.toISOString()), 'до 05.01 09:03'); }); test('a Date instance is accepted directly, not only an ISO string', () => { const closesAt = new Date(2026, 11, 1, 0, 0, 0); assert.equal(formatDeadline(closesAt), 'до 01.12 00:00'); }); test('falsy or invalid input returns null instead of throwing', () => { assert.equal(formatDeadline(null), null); assert.equal(formatDeadline(undefined), null); assert.equal(formatDeadline(''), null); assert.equal(formatDeadline('not-a-date'), null); });