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);
};
import React from 'react';
import { TableRow } from './TableRow';
import { render, screen } from '@testing-library/react';
import { DndContext } from '@dnd-kit/core';
import { getMuiIconByName } from '../../../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.createElement(DndContext, null,
            React.createElement("table", null,
                React.createElement("tbody", null, children))));
    };
    return render(React.createElement(TableRow, __assign({}, props)), { wrapper: Providers });
};
describe('TableRow tests', function () {
    it('should render TableHeadCell correctly', function () {
        setUp();
        expect(screen.getByText(rowData.label)).toBeInTheDocument();
        expect(screen.getByText(columnsData[0]['attributes.FirstName'])).toBeInTheDocument();
        expect(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(screen.getByText(rowData.label)).toBeInTheDocument();
        expect(screen.getByText(columnsData[0]['attributes.FirstName'])).toBeInTheDocument();
        expect(screen.getByText(columnsData[1]['attributes.FirstName'])).toBeInTheDocument();
        expect(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(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(screen.getByRole('row')).toHaveClass(rowClassName);
    });
});
