-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5667acc
commit b712541
Showing
7 changed files
with
112 additions
and
140 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import Sidebar from "./Sidebar.tsx"; | ||
import { Grade } from "../../api/services/types"; | ||
|
||
const meta = { | ||
component: Sidebar, | ||
args: { | ||
githubUsername: "testuser", | ||
easyProgress: "5/10", | ||
mediumProgress: "8/10", | ||
hardProgress: "3/5", | ||
solvedProblems: 16, | ||
totalProblems: 25, | ||
profileUrl: "https://avatars.githubusercontent.com/u/104721736?v=4", | ||
cohort: 3, | ||
grade: Grade.LEAF, | ||
}, | ||
} satisfies Meta<typeof Sidebar>; | ||
|
||
export default meta; | ||
|
||
export const Default: StoryObj<typeof meta> = {}; | ||
|
||
export const HighProgress: StoryObj<typeof meta> = { | ||
args: { | ||
solvedProblems: 28, | ||
totalProblems: 30, | ||
easyProgress: "10/10", | ||
mediumProgress: "10/10", | ||
hardProgress: "8/10", | ||
grade: Grade.FRUIT, | ||
}, | ||
}; | ||
|
||
export const NoProblems: StoryObj<typeof meta> = { | ||
args: { | ||
easyProgress: "0/0", | ||
mediumProgress: "0/0", | ||
hardProgress: "0/0", | ||
solvedProblems: 0, | ||
totalProblems: 0, | ||
grade: Grade.SEED, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { test, expect } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import Sidebar from "./Sidebar.tsx"; | ||
import { Grade } from "../../api/services/types"; | ||
|
||
test("renders Sidebar with all elements", () => { | ||
render( | ||
<Sidebar | ||
githubUsername="testuser" | ||
easyProgress="10/15" | ||
mediumProgress="5/10" | ||
hardProgress="2/5" | ||
solvedProblems={17} | ||
totalProblems={30} | ||
profileUrl="example.png" | ||
cohort={3} | ||
grade={Grade.TREE} | ||
/>, | ||
); | ||
|
||
// Check if the sidebar exists | ||
const sidebar = screen.getByRole("complementary"); | ||
expect(sidebar).toBeInTheDocument(); | ||
|
||
// Check if the username is displayed | ||
const username = screen.getByText(/testuser/i); | ||
expect(username).toBeInTheDocument(); | ||
|
||
// Check if the button link exists | ||
const buttonLink = screen.getByRole("link", { | ||
name: /리더보드로 돌아가기/i, | ||
}); | ||
expect(buttonLink).toBeInTheDocument(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters