Skip to content

Commit

Permalink
Migrated pages tests to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
marekdedic committed Jan 9, 2025
1 parent 12f1060 commit 081ca81
Show file tree
Hide file tree
Showing 10 changed files with 297 additions and 802 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from "@testing-library/react";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import { describe, expect, test } from "vitest";

import { IssueDetail } from "../../src/pages/IssueDetail";
import { testData } from "../testData";
Expand All @@ -9,6 +10,8 @@ const issue = project.issues[0];

describe("IssueDetail page", () => {
test("should render correctly", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter
initialEntries={[
Expand All @@ -23,10 +26,13 @@ describe("IssueDetail page", () => {
</Routes>
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});

test("should render correctly if there is no related issue", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter initialEntries={[`/${project.owner}/${project.repo}/0`]}>
<Routes>
Expand All @@ -37,6 +43,7 @@ describe("IssueDetail page", () => {
</Routes>
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { render } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, test } from "vitest";

import { IssuesList } from "../../src/pages/IssuesList";
import { testData } from "../testData";

describe("IssuesList page", () => {
test("should render correctly", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter>
<IssuesList data={testData} />
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render } from "@testing-library/react";
import { MemoryRouter, Route, Routes } from "react-router-dom";
import { describe, expect, test } from "vitest";

import { ProjectDetail } from "../../src/pages/ProjectDetail";
import { testData } from "../testData";
Expand All @@ -8,6 +9,8 @@ const project = testData.projects[0];

describe("ProjectDetail page", () => {
test("should render correctly", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter initialEntries={[`/${project.owner}/${project.repo}`]}>
<Routes>
Expand All @@ -18,10 +21,13 @@ describe("ProjectDetail page", () => {
</Routes>
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});

test("should render correctly if there is no related issue", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter initialEntries={[`/owner/repo`]}>
<Routes>
Expand All @@ -32,6 +38,7 @@ describe("ProjectDetail page", () => {
</Routes>
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { render } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { describe, expect, test } from "vitest";

import { ProjectsList } from "../../src/pages/ProjectsList";
import { testData } from "../testData";

describe("ProjectsList page", () => {
test("should render correctly", () => {
expect.assertions(1);

const { container } = render(
<MemoryRouter>
<ProjectsList data={testData} />
</MemoryRouter>,
);

expect(container.firstChild).toMatchSnapshot();
});
});
Loading

0 comments on commit 081ca81

Please sign in to comment.