diff --git a/react-web/src/components/Button/Button.test.tsx b/react-web/src/components/Button/Button.test.tsx
index 2a9b17bb..2569badd 100644
--- a/react-web/src/components/Button/Button.test.tsx
+++ b/react-web/src/components/Button/Button.test.tsx
@@ -2,34 +2,15 @@ import { fireEvent, render, screen } from "@testing-library/react";
import Button from "./Button";
describe("renders the Button component with defaults", () => {
- it("renders without a class name", () => {
+ it("renders with default properties", () => {
render();
- expect(screen.getAllByRole("button")[0]).toHaveClass("btn");
- });
-
- it("renders without a type", () => {
- render();
- expect(screen.getAllByRole("button")[0]).toHaveAttribute("type", "submit");
- });
-
- it("renders without a size", () => {
- render();
- expect(screen.getAllByRole("button")[0]).toHaveClass("btn-medium");
- });
-
- it("renders without a displayStyle", () => {
- render();
- expect(screen.getAllByRole("button")[0]).toHaveClass("btn-primary");
- });
-
- it("renders without a label", () => {
- render();
- expect(screen.getAllByRole("button")[0]).toHaveTextContent("Submit");
- });
-
- it("renders without class is-loading", () => {
- render();
- expect(screen.getAllByRole("button")[0]).not.toHaveClass("is-loading");
+ const button = screen.getAllByRole("button")[0];
+ expect(button).toHaveClass("btn");
+ expect(button).toHaveAttribute("type", "submit");
+ expect(button).toHaveClass("btn-medium");
+ expect(button).toHaveClass("btn-primary");
+ expect(button).toHaveTextContent("Submit");
+ expect(button).not.toHaveClass("is-loading");
});
});
@@ -63,7 +44,7 @@ describe("renders the Button component", () => {
it("successful button click", () => {
const mockOnClick = jest.fn();
- render();
+ render();
const clickIndicator = screen.getByRole("button");
fireEvent.click(clickIndicator);
expect(mockOnClick).toHaveBeenCalledTimes(1);
diff --git a/react-web/src/components/HelperText/HelperText.test.tsx b/react-web/src/components/HelperText/HelperText.test.tsx
index 25a89840..0e366711 100644
--- a/react-web/src/components/HelperText/HelperText.test.tsx
+++ b/react-web/src/components/HelperText/HelperText.test.tsx
@@ -4,28 +4,28 @@ import HelperText, { fetchHelperTextColor } from "./HelperText";
describe("HelperText", () => {
test("renders the text with correct class name when type=info", () => {
- const value = "This is an info message";
+ const value = "This is a info message";
render();
const textElement = screen.getByText(value);
expect(textElement).toHaveClass(fetchHelperTextColor("info"));
});
test("renders the text with correct class name when type=warning", () => {
- const value = "This is an warning message";
+ const value = "This is a warning message";
render();
const textElement = screen.getByText(value);
expect(textElement).toHaveClass(fetchHelperTextColor("warning"));
});
test("renders the text with correct class name when type=success", () => {
- const value = "This is an success message";
+ const value = "This is a success message";
render();
const textElement = screen.getByText(value);
expect(textElement).toHaveClass(fetchHelperTextColor("success"));
});
test("renders the text with correct class name when type=error", () => {
- const value = "This is an error message";
+ const value = "This is a error message";
render();
const textElement = screen.getByText(value);
expect(textElement).toHaveClass(fetchHelperTextColor("error"));
@@ -42,7 +42,7 @@ describe("HelperText", () => {
});
test("renders the text with an info icon when showInfoIcon is true", () => {
- const value = "This is an info message";
+ const value = "This is a info message";
render(
);
diff --git a/react-web/src/components/Icons/Icons.test.tsx b/react-web/src/components/Icons/Icons.test.tsx
index 78e41e33..82e7fd5d 100644
--- a/react-web/src/components/Icons/Icons.test.tsx
+++ b/react-web/src/components/Icons/Icons.test.tsx
@@ -4,7 +4,7 @@ import Icons, { IconTypes } from "./Icons";
describe("Icons", () => {
test("renders the correct icon based on the provided type", () => {
- Object.keys(IconTypes).map((type) => {
+ Object.keys(IconTypes).forEach((type) => {
const { container } = render();
expect(container.querySelector(".MuiSvgIcon-root")).toBeInTheDocument();
});
@@ -12,12 +12,12 @@ describe("Icons", () => {
test("renders the info icon based when type is not provided", () => {
render();
- expect(screen.queryByTestId("InfoIcon")).toBeInTheDocument();
+ expect(screen.getByTestId("InfoIcon")).toBeInTheDocument();
});
test("renders default icon when type is not from mapping", () => {
render();
- expect(screen.queryByTestId("default-icon")).toBeInTheDocument();
+ expect(screen.queryByTestId(".MuiSvgIcon-root")).not.toBeInTheDocument();
});
test("renders icon with provided fontsize", () => {
@@ -51,4 +51,4 @@ describe("Icons", () => {
fireEvent.click(iconElement!);
expect(onClick).toHaveBeenCalled();
});
-});
\ No newline at end of file
+});
diff --git a/react-web/src/compositions/Form/Form.test.tsx b/react-web/src/compositions/Form/Form.test.tsx
index 9688bbb2..e1649df5 100644
--- a/react-web/src/compositions/Form/Form.test.tsx
+++ b/react-web/src/compositions/Form/Form.test.tsx
@@ -1,4 +1,6 @@
import { screen, render } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+
import { Form } from "./Form";
import { useForm } from "react-hook-form";
import { Input } from "./components/Input";
diff --git a/react-web/src/compositions/Timeline/Timeline.test.tsx b/react-web/src/compositions/Timeline/Timeline.test.tsx
index 4767e96b..fbec5ebe 100644
--- a/react-web/src/compositions/Timeline/Timeline.test.tsx
+++ b/react-web/src/compositions/Timeline/Timeline.test.tsx
@@ -35,6 +35,10 @@ describe("Timeline", () => {
const timelineItems = screen.getAllByRole("listitem");
expect(timelineItems).toHaveLength(statusConfig.length);
+ statusConfig.forEach((config, index) => {
+ expect(timelineItems[index]).toHaveTextContent(config.status);
+ expect(timelineItems[index]).toHaveTextContent(String(config.runTimeTaken));
+ });
});
test("sets runTimeTaken property based on the buildInfo runState", () => {
diff --git a/react-web/src/pages/certification/Certification.helper.test.tsx b/react-web/src/pages/certification/Certification.helper.test.tsx
index 5f6616a6..1f4d8ee1 100644
--- a/react-web/src/pages/certification/Certification.helper.test.tsx
+++ b/react-web/src/pages/certification/Certification.helper.test.tsx
@@ -20,6 +20,31 @@ import {
expect(filteredKeys).toEqual(expectedKeys);
});
+
+ describe("filterCertificationTaskKeys", () => {
+ it("should return an empty array when an invalid type is passed", () => {
+ const type = "invalid";
+ const filteredKeys = filterCertificationTaskKeys(type);
+ expect(filteredKeys).toEqual([]);
+ });
+ });
+
+ describe("isAnyTaskFailure", () => {
+ it("should return false if the result object is empty", () => {
+ const result = {};
+ const hasFailure = isAnyTaskFailure(result);
+ expect(hasFailure).toBe(false);
+ });
+
+ it("should return false if the result object contains unexpected values", () => {
+ const result = {
+ _certRes_standardPropertyResult: { tag: "Unexpected" },
+ _certRes_doubleSatisfactionResult: { tag: "Unexpected" },
+ };
+ const hasFailure = isAnyTaskFailure(result);
+ expect(hasFailure).toBe(false);
+ });
+ });
});
describe("isAnyTaskFailure", () => {
diff --git a/react-web/src/pages/certification/components/ResultContainer.test.tsx b/react-web/src/pages/certification/components/ResultContainer.test.tsx
index c5d26521..48897870 100644
--- a/react-web/src/pages/certification/components/ResultContainer.test.tsx
+++ b/react-web/src/pages/certification/components/ResultContainer.test.tsx
@@ -153,4 +153,4 @@ describe("ResultContainer component", () => {
queryByText(/InstanceErr (GenericError "failed to create currency")/i)
).not.toBeInTheDocument();
});
-});
\ No newline at end of file
+});