fix: allow multi-year income analytics periods

This commit is contained in:
2026-09-09 11:10:11 +03:00
parent de1dab0d47
commit 9fcc0ec010
2 changed files with 12 additions and 2 deletions
+11
View File
@@ -36,6 +36,17 @@ describe('income period planning', () => {
).toHaveLength(7);
});
it('accepts multi-year periods and creates monthly buckets for the entire range', () => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2026-09-09T12:00:00Z'));
const plan = planIncomePeriod('2020-01-01', '2025-12-31');
expect(plan.selected).toEqual({ from: '2020-01-01', to: '2025-12-31' });
expect(plan.granularity).toBe('month');
expect(rangeBuckets(plan.selected, plan.granularity)).toHaveLength(72);
expect(plan.yearAgo).toEqual({ from: '2019-01-01', to: '2024-12-31' });
});
it('does not send the unfinished Moscow day as a future instant', () => {
jest.useFakeTimers();
jest.setSystemTime(new Date('2026-08-27T21:44:18.510Z'));