Skip to content

Commit

Permalink
test: add items test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sunjae95 committed Nov 8, 2024
1 parent b29a5b5 commit c359f4d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 31 deletions.
6 changes: 6 additions & 0 deletions src/components/Certificate/Certificate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,9 @@ test("render LinkedIn link", () => {
`https://www.linkedin.com/profile/add?startTask=CERTIFICATION_NAME&name=${username}&organizationId=104834174&certUrl=${location.href}`,
);
});

test("render footer", () => {
render(<Certificate />);

expect(screen.getByRole("contentinfo"));
});
50 changes: 25 additions & 25 deletions src/components/Footer/Footer.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
padding-bottom: 100px;
}

> section {
section {
display: flex;
flex-direction: column;
gap: 40px;
Expand All @@ -20,32 +20,9 @@
flex-direction: row;
width: 80%;
}

> ul:nth-child(1) {
display: flex;
flex-direction: column;
row-gap: 10px;
line-height: 20px;

@media (min-width: 768px) {
flex-direction: row;
column-gap: 80px;
}

> li > a {
font-size: 16px;
color: var(--bg-100);
}
}

> ul:nth-child(2) {
display: flex;
align-items: center;
column-gap: 40px;
}
}

> p {
p {
font-size: 14px;
color: rgba(253, 253, 255, 0.75);
border-top: 1px solid rgba(253, 253, 255, 0.2);
Expand All @@ -60,3 +37,26 @@
}
}
}

.leftMenu {
display: flex;
flex-direction: column;
row-gap: 10px;
line-height: 20px;

@media (min-width: 768px) {
flex-direction: row;
column-gap: 80px;
}

> li > a {
font-size: 16px;
color: var(--bg-100);
}
}

.rightMenu {
display: flex;
align-items: center;
column-gap: 40px;
}
6 changes: 4 additions & 2 deletions src/components/Footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function Footer() {
return (
<footer className={styles.footer}>
<section>
<ul>
<ul className={styles.leftMenu}>
{leftMenu.map(({ label, link }) => (
<li key={link}>
<a href={link} target="_blank" aria-label={label}>
Expand All @@ -105,7 +105,8 @@ export default function Footer() {
</li>
))}
</ul>
<ul>

<ul className={styles.rightMenu}>
{rightMenu.map(({ label, link, component }) => (
<li key={link}>
<a href={link} target="_blank" aria-label={label}>
Expand All @@ -115,6 +116,7 @@ export default function Footer() {
))}
</ul>
</section>

<p>© 2024 DaleStudy. All rights reserved.</p>
</footer>
);
Expand Down
10 changes: 8 additions & 2 deletions src/components/Leaderboard/Leaderboard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { render, screen, within } from "@testing-library/react";
import Leaderboard from "./Leaderboard";

describe("<Leaderboard/>", () => {
Expand Down Expand Up @@ -31,7 +31,9 @@ describe("<Leaderboard/>", () => {
{ name: "SamTheKorean", solved: 60, rank: "나무" },
];

const memberItems = screen.getAllByRole("listitem");
const memberItems = within(
screen.getByRole("article", { name: /members list/i }),
).getAllByRole("listitem");

expect(memberItems).toHaveLength(members.length);

Expand Down Expand Up @@ -71,4 +73,8 @@ describe("<Leaderboard/>", () => {
);
});
});

it("renders footer", () => {
expect(screen.getByRole("contentinfo"));
});
});
10 changes: 8 additions & 2 deletions src/components/Progress/Progress.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import { render, screen, within } from "@testing-library/react";
import Progress from "./Progress"; // Adjust the import path as needed

describe("<Progress/>", () => {
Expand Down Expand Up @@ -31,7 +31,9 @@ describe("<Progress/>", () => {
});

it("renders the task list", () => {
const taskItems = screen.getAllByRole("listitem");
const taskItems = within(
screen.getByRole("region", { name: "Task List" }),
).getAllByRole("listitem");
expect(taskItems).toHaveLength(4); // Since there are 4 tasks defined

const expectedTasks = [
Expand All @@ -47,4 +49,8 @@ describe("<Progress/>", () => {
expect(taskItem).toHaveTextContent(task.difficulty);
});
});

it("renders footer", () => {
expect(screen.getByRole("contentinfo"));
});
});

0 comments on commit c359f4d

Please sign in to comment.