"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 user_event_1 = __importDefault(require("@testing-library/user-event"));
var react_router_dom_1 = require("react-router-dom");
var InternalLink_1 = require("./InternalLink");
describe('InternalLink tests', function () {
    var setUp = function (props) {
        if (props === void 0) { props = {}; }
        var user = user_event_1.default.setup();
        var Providers = function (_a) {
            var children = _a.children;
            return react_1.default.createElement(react_router_dom_1.BrowserRouter, null, children);
        };
        return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(InternalLink_1.InternalLink, __assign({}, props)), { wrapper: Providers }));
    };
    it('should render router link in router context', function () {
        window.location.assign('https://tst-01.reltio.com/nui/uitest1');
        setUp({ href: 'https://tst-01.reltio.com/nui/uitest1/search' });
        var link = react_2.screen.getByRole('link');
        expect(link).toHaveAttribute('href', '/nui/uitest1/search');
    });
    it('should render html link outside router context', function () {
        window.location.assign('https://tst-01.reltio.com/ui/uitest1');
        (0, react_2.render)(react_1.default.createElement(InternalLink_1.InternalLink, { href: 'https://tst-01.reltio.com/ui/uitest1/search' }));
        var link = react_2.screen.getByRole('link');
        expect(link).toHaveAttribute('href', 'https://tst-01.reltio.com/ui/uitest1/search');
    });
    it('should not render Link if href is undefined', function () {
        window.location.assign('https://tst-01.reltio.com/nui/uitest1');
        setUp();
        expect(react_2.screen.queryByRole('link')).not.toBeInTheDocument();
    });
    it('should apply custom class name', function () {
        setUp({ href: 'https://tst-01.reltio.com/nui/uitest1/search', className: 'custom-class' });
        var link = react_2.screen.getByRole('link');
        expect(link).toHaveClass('custom-class');
    });
    it('should pass other props to the link', function () {
        setUp({ href: 'https://tst-01.reltio.com/nui/uitest1/search', 'data-reltio-id': 'internal-link' });
        var link = react_2.screen.getByTestId('internal-link');
        expect(link).toBeInTheDocument();
    });
});
