Skip to content

Commit

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

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

export default meta;

type Story = StoryObj<typeof MonthBox>;

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-07',
date: '07',
status: 'late',
},
{
petPlantId: 6,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '쵸파 나무',
dictionaryPlantName: '스투키',
dDay: 0,
nextWaterDate: '2023-07-26',
date: '26',
status: 'exist',
},
{
petPlantId: 7,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '클린 나무',
dictionaryPlantName: '스투키',
dDay: 0,
nextWaterDate: '2023-07-26',
date: '26',
status: 'exist',
},
{
petPlantId: 8,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '피움 나무',
dictionaryPlantName: '스투키',
dDay: 0,
nextWaterDate: '2023-07-26',
date: '26',
status: 'exist',
},
{
petPlantId: 9,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '포비 나무',
dictionaryPlantName: '스투키',
dDay: -3,
nextWaterDate: '2023-07-29',
date: '29',
status: 'none',
},
{
petPlantId: 10,
image: 'https://images.unsplash.com/photo-1598983062491-5934ce558814',
nickName: '크론 나무',
dictionaryPlantName: '스투키',
dDay: -3,
nextWaterDate: '2023-07-29',
date: '29',
status: 'none',
},
];

return <MonthBox reminderDates={mockData} month="7" />;
},
};
6 changes: 3 additions & 3 deletions frontend/src/components/Reminder/MonthBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ const MonthBox = ({ month, reminderDates }: MonthBoxProps) => {
const dayMap = new Map();

const cardBoxes = reminderDates.map((info) => {
const hasDate = dayMap.has(info.date);
if (!hasDate) dayMap.set(info.date, true);
const notDate = dayMap.has(info.date);
if (!notDate) dayMap.set(info.date, true);

const id = info.petPlantId.toString();

return <CardBox key={id} hasDate={hasDate} data={info} />;
return <CardBox key={id} notDate={notDate} data={info} />;
});

return (
Expand Down

0 comments on commit 0b4bc9b

Please sign in to comment.