"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const field_1 = require("../types/field");
const periodOverPeriodComparison_1 = require("../types/periodOverPeriodComparison");
const timeFrames_1 = require("../types/timeFrames");
const additionalMetrics_1 = require("./additionalMetrics");
const baseTable = {
    name: 'orders',
    label: 'Orders',
    database: 'db',
    schema: 'schema',
    sqlTable: 'orders',
    dimensions: {},
    metrics: {},
    lineageGraph: {},
};
describe('convertAdditionalMetric — PoP formatOptions inheritance', () => {
    it('preserves formatOptions when converting a PoP additional metric', () => {
        const baseMetric = {
            table: 'orders',
            name: 'total_revenue',
            label: 'Revenue',
            description: 'Total revenue',
            type: field_1.MetricType.SUM,
            sql: '${TABLE}.amount',
            formatOptions: {
                type: field_1.CustomFormatType.CURRENCY,
                currency: 'USD',
            },
        };
        const { additionalMetric: pop } = (0, periodOverPeriodComparison_1.buildPopAdditionalMetric)({
            metric: baseMetric,
            timeDimensionId: 'orders_order_date_week',
            granularity: timeFrames_1.TimeFrames.WEEK,
            periodOffset: 1,
        });
        expect(pop.formatOptions).toEqual({
            type: field_1.CustomFormatType.CURRENCY,
            currency: 'USD',
        });
        const result = (0, additionalMetrics_1.convertAdditionalMetric)({
            additionalMetric: pop,
            table: baseTable,
        });
        expect(result.formatOptions).toEqual({
            type: field_1.CustomFormatType.CURRENCY,
            currency: 'USD',
        });
    });
});
//# sourceMappingURL=additionalMetrics.test.js.map