import React from 'react';
import { render, screen } from '@testing-library/react';
import { ErrorBoundary } from './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 () {
        render(React.createElement(ErrorBoundary, { error: React.createElement("div", null, "Something went wrong") }, "Child component"));
        screen.getByText('Child component');
        expect(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');
        };
        render(React.createElement(ErrorBoundary, { error: React.createElement("div", null, "Something went wrong") },
            React.createElement(ThrowError, null)));
        screen.getByText('Something went wrong');
    });
});
