"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 TableRow_1 = require("./TableRow");
var react_2 = require("@testing-library/react");
var core_1 = require("@dnd-kit/core");
var test_utils_1 = require("../../../test-utils");
var columnsData = [
    { 'attributes.FirstName': 'FirstNameValue1', isDraggable: false, id: 'entities/123' },
    { 'attributes.FirstName': 'FirstNameValue2', isDraggable: true, id: 'entities/234' }
];
var rowData = { id: 'attributes.FirstName', label: 'FirstName' };
var defaultProps = {
    rowData: rowData,
    columnsData: columnsData,
    index: 0
};
var setUp = function (props) {
    if (props === void 0) { props = defaultProps; }
    var Providers = function (_a) {
        var children = _a.children;
        return (react_1.default.createElement(core_1.DndContext, null,
            react_1.default.createElement("table", null,
                react_1.default.createElement("tbody", null, children))));
    };
    return (0, react_2.render)(react_1.default.createElement(TableRow_1.TableRow, __assign({}, props)), { wrapper: Providers });
};
describe('TableRow tests', function () {
    it('should render TableHeadCell correctly', function () {
        setUp();
        expect(react_2.screen.getByText(rowData.label)).toBeInTheDocument();
        expect(react_2.screen.getByText(columnsData[0]['attributes.FirstName'])).toBeInTheDocument();
        expect(react_2.screen.getByText(columnsData[1]['attributes.FirstName'])).toBeInTheDocument();
    });
    it('should render "TableCellWithDnd" cells correctly if "isMoveColumnEnabled" is true in props', function () {
        setUp(__assign(__assign({}, defaultProps), { isMoveColumnEnabled: true }));
        expect(react_2.screen.getByText(rowData.label)).toBeInTheDocument();
        expect(react_2.screen.getByText(columnsData[0]['attributes.FirstName'])).toBeInTheDocument();
        expect(react_2.screen.getByText(columnsData[1]['attributes.FirstName'])).toBeInTheDocument();
        expect((0, test_utils_1.getMuiIconByName)('DragIndicator')).toBeInTheDocument();
    });
    it('should pass "shouldRenderDragIndicator" prop correctly to "TableCellWithDnd" cells if index not 0', function () {
        setUp(__assign(__assign({}, defaultProps), { isMoveColumnEnabled: true, index: 1 }));
        expect((0, test_utils_1.getMuiIconByName)('DragIndicator')).not.toBeInTheDocument();
    });
    it('should add rowClassName to tr element', function () {
        var rowClassName = 'class1';
        setUp(__assign(__assign({}, defaultProps), { rowData: __assign(__assign({}, rowData), { rowClassName: rowClassName }) }));
        expect(react_2.screen.getByRole('row')).toHaveClass(rowClassName);
    });
});
