From 1d70fd4eb65e8d7ac4003f349a99e99393ff6664 Mon Sep 17 00:00:00 2001 From: blai0264 Date: Tue, 14 May 2024 17:07:49 -0400 Subject: [PATCH 01/26] Unit testing for ArticleCTA component --- .../fragment_components/ArticleCTA.test.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 components/fragment_renderer/fragment_components/ArticleCTA.test.js diff --git a/components/fragment_renderer/fragment_components/ArticleCTA.test.js b/components/fragment_renderer/fragment_components/ArticleCTA.test.js new file mode 100644 index 0000000000..0190c6186c --- /dev/null +++ b/components/fragment_renderer/fragment_components/ArticleCTA.test.js @@ -0,0 +1,16 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import ArticleCTA from "./ArticleCTA"; +import { Default } from "./ArticleCTA.stories.js"; +import { axe, toHaveNoViolations } from "jest-axe"; + +expect.extend(toHaveNoViolations); + +describe("ArticleCTA", () => { + test("renders ArticleCTA component with default props", async () => { + const { container } = render(); + expect(screen.getByText("This is a body")).toBeInTheDocument(); + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); +}); From 82e8659bd4914614078099b2635b4f33e6af9193 Mon Sep 17 00:00:00 2001 From: blai0264 Date: Tue, 14 May 2024 17:08:41 -0400 Subject: [PATCH 02/26] Unit testing for BasicTextWithImage component --- .../BasicTextWithImage.test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 components/fragment_renderer/fragment_components/BasicTextWithImage.test.js diff --git a/components/fragment_renderer/fragment_components/BasicTextWithImage.test.js b/components/fragment_renderer/fragment_components/BasicTextWithImage.test.js new file mode 100644 index 0000000000..53a2843fd9 --- /dev/null +++ b/components/fragment_renderer/fragment_components/BasicTextWithImage.test.js @@ -0,0 +1,18 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import BasicTextWithImage from "./BasicTextWithImage"; +import { Default } from "./BasicTextWithImage.stories.js"; +import { axe, toHaveNoViolations } from "jest-axe"; + +expect.extend(toHaveNoViolations); + +describe("BasicTextWithImage", () => { + test("renders BasicTextWithImage component with default props", async () => { + const { container } = render(); + expect(screen.getByAltText("image alt text")).toBeInTheDocument(); + expect(screen.getByText((content) => content.startsWith("Every week"))) + .toBeInTheDocument; + const results = await axe(container); + expect(results).toHaveNoViolations(); + }); +}); From 16c72b4d8ba0512012c4b601f08e0bd3b592f8c4 Mon Sep 17 00:00:00 2001 From: blai0264 Date: Tue, 14 May 2024 17:09:10 -0400 Subject: [PATCH 03/26] Unit testing for Button component --- .../fragment_components/Button.test.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 components/fragment_renderer/fragment_components/Button.test.js diff --git a/components/fragment_renderer/fragment_components/Button.test.js b/components/fragment_renderer/fragment_components/Button.test.js new file mode 100644 index 0000000000..e63ae5f9e5 --- /dev/null +++ b/components/fragment_renderer/fragment_components/Button.test.js @@ -0,0 +1,23 @@ +import React from "react"; +import { render, screen } from "@testing-library/react"; +import Button from "./Button"; +import { Primary } from "./Button.stories.js"; +import { Secondary } from "./Button.stories.js"; +import { axe, toHaveNoViolations } from "jest-axe"; + +expect.extend(toHaveNoViolations); + +describe("Button", () => { + test("renders Button component with Primary props", async () => { + const { container } = render(