"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const field_1 = require("../types/field");
const CartesianChartDataModel_1 = require("./CartesianChartDataModel");
const types_1 = require("./types");
describe('CartesianChartDataModel formatters', () => {
    test('formats SI tooltip values dynamically', () => {
        const formatter = CartesianChartDataModel_1.CartesianChartDataModel.getTooltipFormatter(field_1.Format.SI);
        expect(formatter?.(999)).toEqual('999');
        expect(formatter?.(1200)).toEqual('1.2K');
        expect(formatter?.(1200000)).toEqual('1.2M');
    });
    test('formats SI value labels dynamically', () => {
        const formatter = CartesianChartDataModel_1.CartesianChartDataModel.getValueFormatter(field_1.Format.SI);
        expect(formatter?.({
            dimensionNames: ['category', 'value'],
            encode: { y: [1] },
            value: { category: 'Jan', value: 1200000 },
        })).toEqual('1.2M');
    });
});
describe('CartesianChartDataModel getSpec', () => {
    const pivotChartData = {
        queryUuid: undefined,
        fileUrl: undefined,
        results: [
            { month: '2026-04-01T00:00:00.000Z', month_count: '1' },
            { month: '2026-05-01T00:00:00.000Z', month_count: '2' },
        ],
        indexColumn: { reference: 'month', type: types_1.VizIndexType.TIME },
        valuesColumns: [
            {
                referenceField: 'month_count',
                pivotColumnName: 'month_count',
                aggregation: types_1.VizAggregationOptions.COUNT,
                pivotValues: [],
            },
        ],
        columns: [
            { reference: 'month', type: field_1.DimensionType.TIMESTAMP },
            { reference: 'month_count', type: field_1.DimensionType.NUMBER },
        ],
        columnCount: 2,
    };
    const resultsRunner = {
        getPivotedVisualizationData: async () => pivotChartData,
        getColumnNames: () => ['month', 'month_count'],
        getRows: () => [],
        getPivotQueryDimensions: () => [
            {
                reference: 'month',
                axisType: types_1.VizIndexType.TIME,
                dimensionType: field_1.DimensionType.TIMESTAMP,
            },
        ],
        getPivotQueryMetrics: () => [],
        getPivotQueryCustomMetrics: () => [],
    };
    test('renders time axis in UTC so tick placement matches the UTC label formatter', async () => {
        const model = new CartesianChartDataModel_1.CartesianChartDataModel({
            resultsRunner,
            fieldConfig: {
                x: { reference: 'month', type: types_1.VizIndexType.TIME },
                y: [
                    {
                        reference: 'month_count',
                        aggregation: types_1.VizAggregationOptions.COUNT,
                    },
                ],
                groupBy: undefined,
            },
        });
        await model.getPivotedChartData({
            sql: 'SELECT 1',
            limit: 500,
            sortBy: [],
            filters: [],
        });
        const spec = model.getSpec();
        expect(spec.useUTC).toBe(true);
        expect(spec.xAxis.type).toBe(types_1.VizIndexType.TIME);
    });
});
//# sourceMappingURL=CartesianChartDataModel.test.js.map