Skip to content

Commit

Permalink
update : adjust stories and test with new props
Browse files Browse the repository at this point in the history
  • Loading branch information
SamTheKorean committed Dec 4, 2024
1 parent 8133827 commit f8fc300
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 12 deletions.
98 changes: 93 additions & 5 deletions src/components/Table/Table.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,127 @@
import type { Meta, StoryObj } from "@storybook/react";
import Table from "./Table";

// Define meta for Table component with default args
const meta: Meta<typeof Table> = {
component: Table,
args: {
problems: [
{
id: 1,
title: "Two Sum",
difficulty: "Easy",
},
{
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
},
{
id: 133,
title: "Clone Graph",
difficulty: "Med.",
},
{
id: 295,
title: "Find Median From Data Stream",
difficulty: "Hard",
},
],
solvedProblems: [
{
id: 1,
title: "Two Sum",
difficulty: "Easy",
},
{
id: 133,
title: "Clone Graph",
difficulty: "Med.",
},
], // Default solved problems for this example
},
};

export default meta;

export const Default: StoryObj<typeof Table> = {
// Default story (uses default args)
export const Default: StoryObj<typeof Table> = {};

// Story for all problems marked as solved
export const AllCompleted: StoryObj<typeof Table> = {
args: {
problems: [
{
id: 1,
title: "Two Sum",
difficulty: "Easy",
},
{
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
},
{
id: 133,
title: "Clone Graph",
difficulty: "Med.",
},
{
id: 295,
title: "Find Median From Data Stream",
difficulty: "Hard",
},
],
solvedProblems: [
{
id: 1,
title: "Two Sum",
difficulty: "Easy",
},
{
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
},
{
id: 133,
title: "Clone Graph",
difficulty: "Med.",
},
{
id: 295,
title: "Find Median From Data Stream",
difficulty: "Hard",
},
], // All problems are solved
},
};

// Story for no problems solved
export const NoCompletedProblems: StoryObj<typeof Table> = {
args: {
problems: [
{
id: 1,
title: "Two Sum",
difficulty: "Easy",
completed: true,
},
{
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
completed: false,
},
{
id: 133,
title: "Clone Graph",
difficulty: "Med.",
completed: true,
},
{
id: 295,
title: "Find Median From Data Stream",
difficulty: "Hard",
completed: false,
},
],
solvedProblems: [], // No problems solved
},
};
12 changes: 5 additions & 7 deletions src/components/Table/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,20 @@ const problems = [
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
completed: true,
},
{ id: 1, title: "Two Sum", difficulty: "Easy", completed: true },
{ id: 257, title: "Binary Tree Paths", difficulty: "Easy", completed: false },
{ id: 133, title: "Clone Graph", difficulty: "Med.", completed: true },
{ id: 1, title: "Two Sum", difficulty: "Easy" },
{ id: 257, title: "Binary Tree Paths", difficulty: "Easy" },
{ id: 133, title: "Clone Graph", difficulty: "Med." },
];

const solvedProblems = [
{
id: 128,
title: "Longest Consecutive Sequence",
difficulty: "Med.",
completed: true,
},
{ id: 257, title: "Binary Tree Paths", difficulty: "Easy", completed: false },
{ id: 133, title: "Clone Graph", difficulty: "Med.", completed: true },
{ id: 257, title: "Binary Tree Paths", difficulty: "Easy" },
{ id: 133, title: "Clone Graph", difficulty: "Med." },
];

test("renders table headers", () => {
Expand Down

0 comments on commit f8fc300

Please sign in to comment.