Skip to content

Commit

Permalink
Add empty state component unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anjula-sack committed Jul 12, 2023
1 parent 62cd51b commit 9818dd9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/views/empty-state/empty-state.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { EmptyState } from "./empty-state.component";

describe("EmptyState Component", () => {
const headerTitle = "This is a header";
const displayText = "example display text";

test("renders header title", () => {
render(<EmptyState headerTitle={headerTitle} displayText={displayText} />);
const headerElement = screen.getByText(headerTitle);
expect(headerElement).toBeInTheDocument();
});

test("renders display text", () => {
render(<EmptyState headerTitle={headerTitle} displayText={displayText} />);
const displayTextElement = screen.getByText(
`There are no ${displayText} to display for this patient`
);
expect(displayTextElement).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion src/views/error-state/error-state.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const ErrorState: React.FC<ErrorStateProps> = ({
const { t } = useTranslation();

return (
<Tile light className={styles.tile}>
<Tile className={styles.tile}>
<h1 className={styles.heading}>{headerTitle}</h1>
<p className={styles.errorMessage}>
{t("error", "Error")} {`${error?.response?.status}: `}
Expand Down

0 comments on commit 9818dd9

Please sign in to comment.