Files
portal/app/tests/Frontend/leadDate.spec.ts
T
2026-06-22 20:54:28 +03:00

25 lines
1.0 KiB
TypeScript

import { describe, it, expect } from 'vitest';
import { formatLeadDate, firstLeadDate } from '../../resources/js/utils/leadDate';
describe('formatLeadDate', () => {
it('formats ISO to "D MMMM" in Russian', () => {
expect(formatLeadDate('2026-06-23T21:00:00+03:00')).toBe('23 июня');
});
it('returns empty string for null/invalid', () => {
expect(formatLeadDate(null)).toBe('');
expect(formatLeadDate('')).toBe('');
expect(formatLeadDate('not-a-date')).toBe('');
});
});
describe('firstLeadDate (порог 18:00 МСК)', () => {
it('до 18:00 МСК → завтра', () => {
// 2026-06-22 12:00 UTC = 15:00 МСК → завтра 23 июня
expect(firstLeadDate(new Date('2026-06-22T12:00:00Z'))).toBe('23 июня');
});
it('после 18:00 МСК → послезавтра', () => {
// 2026-06-22 16:00 UTC = 19:00 МСК → послезавтра 24 июня
expect(firstLeadDate(new Date('2026-06-22T16:00:00Z'))).toBe('24 июня');
});
});