"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const timeFrames_1 = require("../types/timeFrames");
const bigNumber_1 = require("./bigNumber");
describe('resolveGranularityInLabel', () => {
    it('replaces ${field.granularity} with lowercase granularity value', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('compared to last ${events_date.granularity}', { events_date: timeFrames_1.DateGranularity.WEEK })).toBe('compared to last week');
    });
    it('replaces multiple different field references', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('${events_date.granularity} and ${orders_created.granularity}', {
            events_date: timeFrames_1.DateGranularity.MONTH,
            orders_created: timeFrames_1.DateGranularity.WEEK,
        })).toBe('month and week');
    });
    it('replaces multiple occurrences of the same field', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('${events_date.granularity} over ${events_date.granularity}', { events_date: timeFrames_1.DateGranularity.MONTH })).toBe('month over month');
    });
    it('returns label unchanged when no placeholders present', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('static label', {
            events_date: timeFrames_1.DateGranularity.DAY,
        })).toBe('static label');
    });
    it('returns label unchanged when granularity map is empty', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('compared to last ${events_date.granularity}', {})).toBe('compared to last ${events_date.granularity}');
    });
    it('leaves unmatched placeholders as-is', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)('${events_date.granularity} vs ${unknown_field.granularity}', { events_date: timeFrames_1.DateGranularity.DAY })).toBe('day vs ${unknown_field.granularity}');
    });
    it('returns undefined when label is undefined', () => {
        expect((0, bigNumber_1.resolveGranularityInLabel)(undefined, {
            events_date: timeFrames_1.DateGranularity.WEEK,
        })).toBeUndefined();
    });
    it('works with all DateGranularity values', () => {
        const map = { d: timeFrames_1.DateGranularity.DAY };
        expect((0, bigNumber_1.resolveGranularityInLabel)('${d.granularity}', map)).toBe('day');
        map.d = timeFrames_1.DateGranularity.WEEK;
        expect((0, bigNumber_1.resolveGranularityInLabel)('${d.granularity}', map)).toBe('week');
        map.d = timeFrames_1.DateGranularity.MONTH;
        expect((0, bigNumber_1.resolveGranularityInLabel)('${d.granularity}', map)).toBe('month');
        map.d = timeFrames_1.DateGranularity.QUARTER;
        expect((0, bigNumber_1.resolveGranularityInLabel)('${d.granularity}', map)).toBe('quarter');
        map.d = timeFrames_1.DateGranularity.YEAR;
        expect((0, bigNumber_1.resolveGranularityInLabel)('${d.granularity}', map)).toBe('year');
    });
});
//# sourceMappingURL=bigNumber.test.js.map