test: Create unit tests for react components in packages/ui/components/credits (#10044)

Co-authored-by: gitstart-calcom <gitstart@users.noreply.github.com>
pull/9265/head
GitStart-Cal.com 2023-07-21 17:44:12 +01:00 committed by GitHub
parent 1aa3077706
commit 85c3c6dfc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 0 deletions

View File

@ -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(<Credits />);
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(<Credits />);
const currentYear = new Date().getFullYear();
const copyrightElement = screen.getByText(`© ${currentYear}`);
expect(copyrightElement).toHaveTextContent(`${currentYear}`);
});
});