"use strict";
var __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var react_2 = require("@testing-library/react");
var QueryBuilderRow_1 = __importDefault(require("./QueryBuilderRow"));
var LogicOperatorComponent = function () { return react_1.default.createElement("div", null, "Logic Operator Component"); };
var AttributeSelectorComponent = function () { return react_1.default.createElement("div", null, "Attribute Selector Component"); };
var FilterSelectorComponent = function () { return react_1.default.createElement("div", null, "Filter Selector Component"); };
var ValuesEditorComponent = function () { return react_1.default.createElement("div", null, "Values Editor Component"); };
var ActionsComponent = function () { return react_1.default.createElement("div", null, "Actions Component"); };
var rowData = { data: {}, operator: 'and', filter: 'not equals', id: 'nanoid1' };
var previousRowData = { data: { a: 2 }, operator: 'or', filter: 'equals', id: 'nanoid0' };
var classes = {
    root: 'root',
    logicOperatorContainer: 'logicOperatorContainer',
    attributeSelectorContainer: 'attributeSelectorContainer',
    filterSelectorContainer: 'filterSelectorContainer',
    valuesEditorContainer: 'valuesEditorContainer',
    actionsContainer: 'actionsContainer'
};
var defaultProps = {
    rowData: rowData,
    previousRowData: previousRowData,
    filterSelectorRef: react_1.default.createRef(),
    classes: classes,
    LogicOperatorComponent: LogicOperatorComponent,
    AttributeSelectorComponent: AttributeSelectorComponent,
    FilterSelectorComponent: FilterSelectorComponent,
    ValuesEditorComponent: ValuesEditorComponent,
    ActionsComponent: ActionsComponent
};
var setUp = function (props) {
    if (props === void 0) { props = defaultProps; }
    return (0, react_2.render)(react_1.default.createElement(QueryBuilderRow_1.default, __assign({}, props)));
};
describe('Query builder row tests', function () {
    it('should render provided row components correctly', function () {
        setUp();
        var row = react_2.screen.getByTestId('query-builder-row');
        expect(row).toHaveClass('root');
        expect(row).toHaveTextContent('Logic Operator Component');
        var attributeSelector = react_2.screen.getByTestId('query-builder-row-attribute-selector');
        expect(attributeSelector).toHaveClass('attributeSelectorContainer');
        expect(attributeSelector).toHaveTextContent('Attribute Selector Component');
        var filterSelector = react_2.screen.getByTestId('query-builder-row-filter-selector');
        expect(filterSelector).toHaveClass('filterSelectorContainer');
        expect(filterSelector).toHaveTextContent('Filter Selector Component');
        var valuesEditor = react_2.screen.getByTestId('query-builder-row-values-editor');
        expect(valuesEditor).toHaveClass('valuesEditorContainer');
        expect(valuesEditor).toHaveTextContent('Values Editor Component');
        var actions = react_2.screen.getByTestId('query-builder-row-actions');
        expect(actions).toHaveClass('actionsContainer');
        expect(actions).toHaveTextContent('Actions Component');
    });
    it('should render actions as hidden if rowData is not provided', function () {
        var props = __assign(__assign({}, defaultProps), { rowData: undefined });
        setUp(props);
        expect(react_2.screen.getByTestId('query-builder-row-actions')).toHaveClass('hidden');
    });
    it('should render read only filter correctly if FilterSelectorComponent are not provided', function () {
        var props = __assign(__assign({}, defaultProps), { FilterSelectorComponent: undefined });
        setUp(props);
        expect(react_2.screen.getByTestId('query-builder-row-filter-selector')).toHaveTextContent('not');
    });
    it('should render read only filter correctly if FilterSelectorComponent and rowData are not provided', function () {
        var props = __assign(__assign({}, defaultProps), { FilterSelectorComponent: undefined, rowData: undefined });
        setUp(props);
        expect(react_2.screen.getByTestId('query-builder-row-filter-selector')).toHaveTextContent('equals');
    });
    it('should render read only logic operator correctly if LogicOperatorComponent are not provided', function () {
        var props = __assign(__assign({}, defaultProps), { LogicOperatorComponent: undefined });
        setUp(props);
        expect(react_2.screen.getByTestId('query-builder-row')).toHaveTextContent('Or');
    });
    it('should render read only logic operator correctly if LogicOperatorComponent and previousRowData are not provided', function () {
        var props = __assign(__assign({}, defaultProps), { LogicOperatorComponent: undefined, previousRowData: undefined });
        setUp(props);
        expect(react_2.screen.getByTestId('query-builder-row')).toHaveTextContent('Where');
    });
});
