"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 constants_1 = require("./constants");
var HistoryCircle_1 = require("./HistoryCircle");
describe('HistoryCircle tests', function () {
    var defaultProps = {
        x: 10,
        y: 15,
        color: '#FFFAAA',
        isDashed: false,
        isCollapsed: false,
        showCollapseIcon: false,
        showLine: false
    };
    var setUp = function (props) {
        if (props === void 0) { props = defaultProps; }
        return (0, react_2.render)(react_1.default.createElement(HistoryCircle_1.HistoryCircle, __assign({}, props)));
    };
    it('should render correctly', function () {
        var container = setUp().container;
        expect(container.querySelectorAll('g')).toHaveLength(1);
        expect(container.querySelector('#line')).not.toBeInTheDocument();
        expect(container.querySelector('#icon')).not.toBeInTheDocument();
        var circle = container.querySelector('circle');
        expect(circle).toHaveAttribute('cx', "".concat(defaultProps.x));
        expect(circle).toHaveAttribute('cy', "".concat(defaultProps.y));
        expect(circle).toHaveAttribute('r', "".concat(constants_1.BUMP_RADIUS));
        expect(circle).toHaveAttribute('fill', defaultProps.color);
        expect(circle).toHaveAttribute('stroke-width', '2');
        expect(circle).not.toHaveAttribute('stroke-dasharray');
    });
    it('should render line above circle if showLine === true', function () {
        var container = setUp(__assign(__assign({}, defaultProps), { showLine: true })).container;
        var line = container.querySelector('#line');
        expect(line).toHaveAttribute('x', "".concat(defaultProps.x - constants_1.BUMP_RADIUS - constants_1.LINE_MARGIN));
        expect(line).toHaveAttribute('y', "".concat(defaultProps.y - constants_1.BUMP_RADIUS - constants_1.LINE_MARGIN));
        expect(line).toHaveAttribute('width', "".concat(constants_1.BUMP_RADIUS * 2 + constants_1.LINE_MARGIN * 2));
        expect(line).toHaveAttribute('height', '2');
        expect(line).toHaveAttribute('fill', defaultProps.color);
    });
    it('should render dashed circle if isDashed === true', function () {
        var container = setUp(__assign(__assign({}, defaultProps), { isDashed: true })).container;
        var circle = container.querySelector('circle');
        expect(circle).toHaveAttribute('fill', '#fff');
        expect(circle).toHaveAttribute('stroke-dasharray', '1,1');
    });
    it('should render collapse icon if showCollapseIcon === true', function () {
        var container = setUp(__assign(__assign({}, defaultProps), { showCollapseIcon: true })).container;
        var icon = container.querySelector('#icon');
        expect(icon).toBeInTheDocument();
        expect(icon.querySelectorAll('rect')).toHaveLength(1);
    });
    it('should render expand icon if showCollapseIcon === true and isCollapsed === true', function () {
        var container = setUp(__assign(__assign({}, defaultProps), { showCollapseIcon: true, isCollapsed: true })).container;
        var icon = container.querySelector('#icon');
        expect(icon).toBeInTheDocument();
        expect(icon.querySelectorAll('rect')).toHaveLength(2);
    });
    it('should pass rest props to root element', function () {
        var svgProps = { className: 'history-circle' };
        setUp(__assign(__assign({}, defaultProps), svgProps));
        expect(react_2.screen.getByTestId('history-circle')).toHaveAttribute('class', svgProps.className);
    });
});
