"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 VerticalHeadingsTable_1 = __importDefault(require("./VerticalHeadingsTable"));
var setUp = function (props) {
    var containerRef = {
        current: {
            clientHeight: 500,
            clientWidth: 500,
            getBoundingClientRect: function () {
                return {
                    top: 0,
                    left: 0
                };
            }
        }
    };
    return (0, react_2.render)(react_1.default.createElement(VerticalHeadingsTable_1.default, __assign({ containerRef: containerRef }, props)));
};
describe('VerticalHeadingsTable tests', function () {
    var rowsData = [
        {
            id: 'entityCard'
        },
        {
            id: 'entityId'
        },
        {
            id: 'attributes.FirstName'
        },
        {
            id: 'attributes.LastName'
        }
    ];
    var columnsData = [
        {
            'attributes.FirstName': 'attributes.FirstName-value',
            entityCard: 'entityCard-value',
            entityId: '1234',
            'attributes.LastName': 'attributes.LastName-value',
            id: 'entities/1234'
        }
    ];
    var defaultProps = {
        theadRowsNumber: 2,
        rowsData: rowsData,
        columnsData: columnsData,
        onMoveColumn: jest.fn(),
        onDropColumn: jest.fn(),
        onMoveRow: jest.fn(),
        onDropRow: jest.fn()
    };
    it('should render rows correctly if theadRowsNumber === 0', function () {
        var props = __assign(__assign({}, defaultProps), { theadRowsNumber: 0 });
        setUp(props);
        expect(rowsData.length).toBeGreaterThan(1);
        expect(react_2.screen.getByRole('rowgroup').tagName.toLowerCase()).toBe('tbody');
        rowsData.forEach(function (rowData) {
            expect(react_2.screen.getByText(columnsData[0][rowData.id])).toBeInTheDocument();
        });
    });
    it('should render rows correctly if theadRowsNumber is greater than 0', function () {
        setUp(defaultProps);
        var _a = react_2.screen.getAllByRole('rowgroup'), thead = _a[0], tbody = _a[1];
        expect(thead.tagName.toLowerCase()).toBe('thead');
        expect((0, react_2.within)(thead).getByText(columnsData[0].entityCard)).toBeInTheDocument();
        expect((0, react_2.within)(thead).getByText(columnsData[0].entityId)).toBeInTheDocument();
        expect(tbody.tagName.toLowerCase()).toBe('tbody');
        expect((0, react_2.within)(tbody).getByText(columnsData[0]['attributes.FirstName'])).toBeInTheDocument();
        expect((0, react_2.within)(tbody).getByText(columnsData[0]['attributes.LastName'])).toBeInTheDocument();
    });
});
