"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const dayjs_1 = tslib_1.__importDefault(require("dayjs"));
const timeFrames_1 = require("../types/timeFrames");
const metricsExplorer_1 = require("./metricsExplorer");
const formatDate = (date) => (0, dayjs_1.default)(date).format('YYYY-MM-DD');
describe('getDateCalcUtils', () => {
    test('day shift', () => {
        const { back, forward } = (0, metricsExplorer_1.getDateCalcUtils)(timeFrames_1.TimeFrames.DAY, timeFrames_1.TimeFrames.DAY);
        const base = new Date('2026-03-31T00:00:00Z');
        expect(formatDate(back(base))).toBe('2026-03-30');
        expect(formatDate(forward(base))).toBe('2026-04-01');
    });
    test('week shift', () => {
        const { back, forward } = (0, metricsExplorer_1.getDateCalcUtils)(timeFrames_1.TimeFrames.WEEK, timeFrames_1.TimeFrames.WEEK);
        const base = new Date('2026-03-31T00:00:00Z');
        expect(formatDate(back(base))).toBe('2026-03-24');
        expect(formatDate(forward(base))).toBe('2026-04-07');
    });
    test('month shift clamps end of month', () => {
        const { back, forward } = (0, metricsExplorer_1.getDateCalcUtils)(timeFrames_1.TimeFrames.MONTH, timeFrames_1.TimeFrames.MONTH);
        const base = new Date('2026-03-31T00:00:00Z');
        expect(formatDate(back(base))).toBe('2026-02-28');
        expect(formatDate(forward(new Date('2026-01-31T00:00:00Z')))).toBe('2026-02-28');
    });
    test('year shift clamps leap day', () => {
        const { back } = (0, metricsExplorer_1.getDateCalcUtils)(timeFrames_1.TimeFrames.YEAR, timeFrames_1.TimeFrames.YEAR);
        const leap = new Date('2024-02-29T00:00:00Z');
        expect(formatDate(back(leap))).toBe('2023-02-28');
    });
});
//# sourceMappingURL=metricsExplorer.test.js.map