-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/mutuliaze-unit-conversion-into-o…
…ne-file' into mutuliaze-unit-conversion-into-one-file
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
src/components/cardErrorBoundary/tests/CardErrorBoundary.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |