Files
magistr/frontend/tests/local-date-format.test.mjs
2026-07-19 14:40:43 +03:00

19 lines
825 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import test from 'node:test';
import assert from 'node:assert/strict';
process.env.TZ = 'Europe/Moscow';
const { formatLocalDate } = await import('../admin/js/utils.js');
test('date-only форматируется по московским компонентам, а не через UTC', () => {
assert.equal(formatLocalDate(new Date('2026-01-01T21:15:00Z')), '2026-01-02');
});
test('date-only сохраняет локальный день до московской полуночи', () => {
assert.equal(formatLocalDate(new Date('2026-01-01T20:59:59Z')), '2026-01-01');
});
test('некорректная дата отклоняется явной русской ошибкой', () => {
assert.throws(() => formatLocalDate(new Date('invalid')), /Ожидалась корректная дата/);
});