Skip to content

Commit

Permalink
test: CardBox 스토리 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
hozzijeong committed Jul 26, 2023
1 parent 4a4676b commit ad20253
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
45 changes: 45 additions & 0 deletions frontend/src/components/Reminder/CardBox/CardBox.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { ReminderExtendType } from 'types/api/reminder';
import type { Meta, StoryObj } from '@storybook/react';
import CardBox from '.';

const meta: Meta<typeof CardBox> = {
component: CardBox,
};

export default meta;

type Story = StoryObj<typeof CardBox>;

export const NotHasDate: Story = {
render: () => {
const mockData: ReminderExtendType = {
petPlantId: 1,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '참새나무',
dictionaryPlantName: '알로카시아',
dDay: 0,
nextWaterDate: '2023-07-26',
date: '26',
status: 'exist',
};

return <CardBox data={mockData} notDate={true} />;
},
};

export const HasDate: Story = {
render: () => {
const mockData: ReminderExtendType = {
petPlantId: 1,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '참새나무',
dictionaryPlantName: '알로카시아',
dDay: 0,
nextWaterDate: '2023-07-26',
date: '26',
status: 'exist',
};

return <CardBox data={mockData} notDate={false} />;
},
};
6 changes: 3 additions & 3 deletions frontend/src/components/Reminder/CardBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import ReminderCard from '../Card';

interface CardBoxProps {
data: ReminderExtendType;
hasDate: boolean;
notDate: boolean;
}

const CardBox = ({ data, hasDate }: CardBoxProps) => {
const CardBox = ({ data, notDate }: CardBoxProps) => {
const context = useContext(ReminderContext);

const waterHandler = () => {
Expand All @@ -27,7 +27,7 @@ const CardBox = ({ data, hasDate }: CardBoxProps) => {
return (
<ReminderCardBox key={data.petPlantId}>
<InfoBox>
{!hasDate && <DateLabel>{data.date}</DateLabel>}
{!notDate && <DateLabel>{data.date}</DateLabel>}
<CheckButton type="button" onClick={waterHandler} />
</InfoBox>
<ReminderCard data={data} />
Expand Down

0 comments on commit ad20253

Please sign in to comment.