Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/mutuliaze-unit-conversion-into-o…
Browse files Browse the repository at this point in the history
…ne-file' into mutuliaze-unit-conversion-into-one-file
  • Loading branch information
thangqp committed Dec 18, 2024
2 parents 7a80145 + 35e5bc1 commit 76f1156
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/components/cardErrorBoundary/tests/CardErrorBoundary.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2024, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import { screen } from '@testing-library/react';
import { it } from '@jest/globals';
import { CardErrorBoundary } from '../CardErrorBoundary';
import { RenderBuilder } from '../../../tests/testsUtils.test';

const RenderBuilderInstance = new RenderBuilder().withTrad();

describe('CardErrorBoundary', () => {
it('renders the child component when there is no error', () => {
RenderBuilderInstance.render(
<CardErrorBoundary>
<div>Child Component</div>
</CardErrorBoundary>
);

const childComponent = screen.getByText('Child Component');
expect(childComponent).toBeInTheDocument();
});

it('renders an error message when there is an error', () => {
const errorMessage = 'Something went wrong';
const ErrorComponent = () => {
throw new Error(errorMessage);
};

RenderBuilderInstance.render(
<CardErrorBoundary>
<ErrorComponent />
</CardErrorBoundary>
);

const errorText = screen.getByText(errorMessage);
expect(errorText).toBeInTheDocument();
});
});

0 comments on commit 76f1156

Please sign in to comment.