"use strict";
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 ErrorBoundary_1 = require("./ErrorBoundary");
describe('Error boundary tests', function () {
    beforeEach(function () {
        jest.spyOn(console, 'error').mockImplementation(function () { });
    });
    afterEach(function () {
        jest.clearAllMocks();
    });
    it('should render children when no error occurs', function () {
        (0, react_2.render)(react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { error: react_1.default.createElement("div", null, "Something went wrong") }, "Child component"));
        react_2.screen.getByText('Child component');
        expect(react_2.screen.queryByText('Something went wrong')).not.toBeInTheDocument();
    });
    it('should render the error component when an error occurs', function () {
        var ThrowError = function () {
            throw new Error('Test error');
        };
        (0, react_2.render)(react_1.default.createElement(ErrorBoundary_1.ErrorBoundary, { error: react_1.default.createElement("div", null, "Something went wrong") },
            react_1.default.createElement(ThrowError, null)));
        react_2.screen.getByText('Something went wrong');
    });
});
