Skip to content

Commit a4ac29f

Browse files
authored
Merge pull request #24 from fhlavac/main
fix(tests): Add ErrorState tests
2 parents 4fd4a44 + 39a5bae commit a4ac29f

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

packages/module/src/DetailsPageHeader/DetailsPageHeader.test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable react/jsx-props-no-spreading */
21
import { render, screen, fireEvent } from '@testing-library/react';
32
import React from 'react';
43
import { MemoryRouter, Routes, Route } from 'react-router-dom';

packages/module/src/ErrorBoundaryPage/__tests__/ErrorBoundaryPage.test.tsx renamed to packages/module/src/ErrorBoundaryPage/ErrorBoundaryPage.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import ErrorBoundaryPage from '../ErrorBoundaryPage';
2+
import ErrorBoundaryPage from './ErrorBoundaryPage';
33
import { render, screen } from '@testing-library/react';
44
import userEvent from '@testing-library/user-event';
55

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import * as React from 'react';
2+
import ErrorState from './ErrorState';
3+
import { render, screen } from '@testing-library/react';
4+
5+
describe('ErrorState component', () => {
6+
7+
it('should render correctly', () => {
8+
render(<ErrorState errorTitle='A Basic Error' errorDescription='The following is an example of a basic error' />);
9+
10+
expect(screen.getByText('A Basic Error')).toBeVisible();
11+
expect(screen.getByText('The following is an example of a basic error')).toBeVisible();
12+
expect(screen.getByText('Go to home page')).toBeVisible();
13+
});
14+
15+
it('should render correctly with default props', () => {
16+
render(<ErrorState />);
17+
18+
expect(screen.getByText('Something went wrong')).toBeVisible();
19+
expect(screen.getByText('Go to home page')).toBeVisible();
20+
});
21+
22+
});

packages/module/src/ErrorState/ErrorState.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface ErrorStateProps extends Omit<EmptyStateProps, 'children'> {
2828
defaulErrorDescription?: React.ReactNode;
2929
}
3030

31-
const ErrorState: React.FunctionComponent<ErrorStateProps> = ({ errorTitle = 'Something went wrong', errorDescription, defaulErrorDescription = null, ...props }: ErrorStateProps) => {
31+
const ErrorState: React.FunctionComponent<ErrorStateProps> = ({ errorTitle = 'Something went wrong', errorDescription, defaulErrorDescription, ...props }: ErrorStateProps) => {
3232
const classes = useStyles();
3333
return (
3434
<EmptyState variant={EmptyStateVariant.large} {...props}>

0 commit comments

Comments
 (0)