Skip to content

Commit

Permalink
Merge pull request #24 from fhlavac/main
Browse files Browse the repository at this point in the history
fix(tests): Add ErrorState tests
  • Loading branch information
dlabaj authored Jun 15, 2023
2 parents 4fd4a44 + 39a5bae commit a4ac29f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable react/jsx-props-no-spreading */
import { render, screen, fireEvent } from '@testing-library/react';
import React from 'react';
import { MemoryRouter, Routes, Route } from 'react-router-dom';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import ErrorBoundaryPage from '../ErrorBoundaryPage';
import ErrorBoundaryPage from './ErrorBoundaryPage';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

Expand Down
22 changes: 22 additions & 0 deletions packages/module/src/ErrorState/ErrorState.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import ErrorState from './ErrorState';
import { render, screen } from '@testing-library/react';

describe('ErrorState component', () => {

it('should render correctly', () => {
render(<ErrorState errorTitle='A Basic Error' errorDescription='The following is an example of a basic error' />);

expect(screen.getByText('A Basic Error')).toBeVisible();
expect(screen.getByText('The following is an example of a basic error')).toBeVisible();
expect(screen.getByText('Go to home page')).toBeVisible();
});

it('should render correctly with default props', () => {
render(<ErrorState />);

expect(screen.getByText('Something went wrong')).toBeVisible();
expect(screen.getByText('Go to home page')).toBeVisible();
});

});
2 changes: 1 addition & 1 deletion packages/module/src/ErrorState/ErrorState.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export interface ErrorStateProps extends Omit<EmptyStateProps, 'children'> {
defaulErrorDescription?: React.ReactNode;
}

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

0 comments on commit a4ac29f

Please sign in to comment.