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 { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { BrowserRouter } from 'react-router-dom';
import { InternalLink } from './InternalLink';
describe('InternalLink tests', function () {
    var setUp = function (props) {
        if (props === void 0) { props = {}; }
        var user = userEvent.setup();
        var Providers = function (_a) {
            var children = _a.children;
            return React.createElement(BrowserRouter, null, children);
        };
        return __assign({ user: user }, render(React.createElement(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 = 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');
        render(React.createElement(InternalLink, { href: 'https://tst-01.reltio.com/ui/uitest1/search' }));
        var link = 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(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 = 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 = screen.getByTestId('internal-link');
        expect(link).toBeInTheDocument();
    });
});
