"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../types");
const tooltipFormatter_1 = require("./tooltipFormatter");
describe('translatePivotRef', () => {
    const pivotValuesColumnsMap = {
        orders_unique_order_count_any_completed: {
            referenceField: 'orders_unique_order_count',
            pivotColumnName: 'orders_unique_order_count_any_completed',
            aggregation: types_1.VizAggregationOptions.ANY,
            pivotValues: [
                {
                    referenceField: 'orders_status',
                    value: 'completed',
                    formatted: 'completed',
                },
            ],
        },
        orders_unique_order_count_any_shipped: {
            referenceField: 'orders_unique_order_count',
            pivotColumnName: 'orders_unique_order_count_any_shipped',
            aggregation: types_1.VizAggregationOptions.ANY,
            pivotValues: [
                {
                    referenceField: 'orders_status',
                    value: 'shipped',
                    formatted: 'shipped',
                },
            ],
        },
    };
    it('returns undefined when pivotValuesColumnsMap is undefined', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('metric.dim.val', undefined)).toBeUndefined();
    });
    it('returns undefined for invalid ref format (less than 3 parts)', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('metric', pivotValuesColumnsMap)).toBeUndefined();
        expect((0, tooltipFormatter_1.translatePivotRef)('metric.dim', pivotValuesColumnsMap)).toBeUndefined();
    });
    it('returns undefined for invalid ref format (even number of parts)', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('metric.dim.val.extra', pivotValuesColumnsMap)).toBeUndefined();
    });
    it('translates pivot ref to SQL pivot column name', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('orders_unique_order_count.orders_status.completed', pivotValuesColumnsMap)).toBe('orders_unique_order_count_any_completed');
        expect((0, tooltipFormatter_1.translatePivotRef)('orders_unique_order_count.orders_status.shipped', pivotValuesColumnsMap)).toBe('orders_unique_order_count_any_shipped');
    });
    it('returns undefined when metric does not match', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('unknown_metric.orders_status.completed', pivotValuesColumnsMap)).toBeUndefined();
    });
    it('returns undefined when pivot value does not match', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('orders_unique_order_count.orders_status.pending', pivotValuesColumnsMap)).toBeUndefined();
    });
    it('returns undefined when pivot dimension does not match', () => {
        expect((0, tooltipFormatter_1.translatePivotRef)('orders_unique_order_count.wrong_dimension.completed', pivotValuesColumnsMap)).toBeUndefined();
    });
});
//# sourceMappingURL=tooltipFormatter.test.js.map