From 85c3c6dfc0645e70fbd03199e4d7c1bf217744f4 Mon Sep 17 00:00:00 2001 From: "GitStart-Cal.com" <121884634+gitstart-calcom@users.noreply.github.com> Date: Fri, 21 Jul 2023 17:44:12 +0100 Subject: [PATCH] test: Create unit tests for react components in packages/ui/components/credits (#10044) Co-authored-by: gitstart-calcom --- .../ui/components/credits/credits.test.tsx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 packages/ui/components/credits/credits.test.tsx diff --git a/packages/ui/components/credits/credits.test.tsx b/packages/ui/components/credits/credits.test.tsx new file mode 100644 index 0000000000..0735728ecc --- /dev/null +++ b/packages/ui/components/credits/credits.test.tsx @@ -0,0 +1,35 @@ +/* eslint-disable playwright/missing-playwright-await */ +import { render, screen } from "@testing-library/react"; +import { vi } from "vitest"; + +import Credits from "./Credits"; + +vi.mock("../../../../apps/web/package.json", async () => { + return { + default: { + version: "mockedVersion", + }, + }; +}); + +describe("Tests for Credits component", () => { + test("Should render credits section with links", () => { + render(); + + const creditsLinkElement = screen.getByRole("link", { name: /Cal\.com, Inc\./i }); + expect(creditsLinkElement).toBeInTheDocument(); + expect(creditsLinkElement).toHaveAttribute("href", "https://go.cal.com/credits"); + + const versionLinkElement = screen.getByRole("link", { name: /mockedVersion/i }); + expect(versionLinkElement).toBeInTheDocument(); + expect(versionLinkElement).toHaveAttribute("href", "https://go.cal.com/releases"); + }); + + test("Should render credits section with correct text", () => { + render(); + + const currentYear = new Date().getFullYear(); + const copyrightElement = screen.getByText(`© ${currentYear}`); + expect(copyrightElement).toHaveTextContent(`${currentYear}`); + }); +});