"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tableCalculationFunctions_1 = require("./tableCalculationFunctions");
describe('tableCalculationFunctions utility functions', () => {
    describe('isPivotFunction', () => {
        it('should return true for pivot functions', () => {
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_OFFSET)).toBe(true);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_COLUMN)).toBe(true);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_INDEX)).toBe(true);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_ROW)).toBe(true);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_WHERE)).toBe(true);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_OFFSET_LIST)).toBe(true);
        });
        it('should return false for row functions', () => {
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.ROW)).toBe(false);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.INDEX)).toBe(false);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.OFFSET)).toBe(false);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.OFFSET_LIST)).toBe(false);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.LOOKUP)).toBe(false);
            expect((0, tableCalculationFunctions_1.isPivotFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.LIST)).toBe(false);
        });
    });
    describe('isRowFunction', () => {
        it('should return true for row functions', () => {
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.ROW)).toBe(true);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.INDEX)).toBe(true);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.OFFSET)).toBe(true);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.OFFSET_LIST)).toBe(true);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.LOOKUP)).toBe(true);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.LIST)).toBe(true);
        });
        it('should return false for pivot functions', () => {
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_OFFSET)).toBe(false);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_COLUMN)).toBe(false);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_INDEX)).toBe(false);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_ROW)).toBe(false);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_WHERE)).toBe(false);
            expect((0, tableCalculationFunctions_1.isRowFunction)(tableCalculationFunctions_1.TableCalculationFunctionType.PIVOT_OFFSET_LIST)).toBe(false);
        });
    });
    describe('hasPivotFunctions', () => {
        it('should return true when array contains pivot functions', () => {
            const sql1 = 'pivot_offset(revenue, 1)';
            const functions1 = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql1);
            expect((0, tableCalculationFunctions_1.hasPivotFunctions)(functions1)).toBe(true);
            const sql2 = 'pivot_column() + pivot_index(sales, 1)';
            const functions2 = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql2);
            expect((0, tableCalculationFunctions_1.hasPivotFunctions)(functions2)).toBe(true);
        });
        it('should return false when array contains only row functions', () => {
            const sql = 'offset(revenue, 1) + row()';
            const functions = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql);
            expect((0, tableCalculationFunctions_1.hasPivotFunctions)(functions)).toBe(false);
        });
        it('should return false for empty array', () => {
            expect((0, tableCalculationFunctions_1.hasPivotFunctions)([])).toBe(false);
        });
    });
    describe('hasRowFunctions', () => {
        it('should return true when array contains row functions', () => {
            const sql1 = 'offset(revenue, 1)';
            const functions1 = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql1);
            expect((0, tableCalculationFunctions_1.hasRowFunctions)(functions1)).toBe(true);
            const sql2 = 'row() + index(sales, 1)';
            const functions2 = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql2);
            expect((0, tableCalculationFunctions_1.hasRowFunctions)(functions2)).toBe(true);
        });
        it('should return false when array contains only pivot functions', () => {
            const sql = 'pivot_offset(revenue, 1) + pivot_column()';
            const functions = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql);
            expect((0, tableCalculationFunctions_1.hasRowFunctions)(functions)).toBe(false);
        });
        it('should return false for empty array', () => {
            expect((0, tableCalculationFunctions_1.hasRowFunctions)([])).toBe(false);
        });
    });
    describe('mixed functions', () => {
        it('should correctly identify mixed function usage', () => {
            const sql = 'pivot_offset(revenue, 1) + offset(cost, -1)';
            const functions = (0, tableCalculationFunctions_1.parseTableCalculationFunctions)(sql);
            expect((0, tableCalculationFunctions_1.hasPivotFunctions)(functions)).toBe(true);
            expect((0, tableCalculationFunctions_1.hasRowFunctions)(functions)).toBe(true);
        });
    });
});
//# sourceMappingURL=tableCalculationFunctions.utility.test.js.map