Skip to content

Commit c821ed4

Browse files
committed
test: 🟩 반복 일정 표시 구현 및 테스트 통과
1 parent 0def319 commit c821ed4

File tree

2 files changed

+46
-13
lines changed

2 files changed

+46
-13
lines changed

src/__tests__/unit/custom.repeatUtils.spec.ts renamed to src/__tests__/unit/custom.repeatUtils.spec.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { render, screen } from '@testing-library/react';
2+
3+
import { RepeatIcon } from '../../icons/RepeatIcon';
24
import { EventForm } from '../../types';
35
import { generateRepeatEvents } from '../../utils/repeatUtils';
46
import { createMockEvent } from '../utils';
@@ -120,22 +122,20 @@ describe('generateRepeatEvents: 반복 일정을 생성한다.', () => {
120122
});
121123
});
122124

123-
describe('RepeatIcon', () => {
124-
describe('반복 일정 아이콘을 표시한다', () => {
125-
it('반복 유형이 none인 경우 아이콘을 표시하지 않는다', () => {
126-
render(<RepeatIcon repeatType="none" />);
125+
describe('반복 일정 아이콘을 표시한다', () => {
126+
it('반복 유형이 none인 경우 아이콘을 표시하지 않는다', () => {
127+
render(<RepeatIcon repeatType="none" />);
127128

128-
const icon = screen.queryByTestId('repeat-icon');
129-
expect(icon).not.toBeInTheDocument();
130-
});
129+
const icon = screen.queryByTestId('repeat-icon');
130+
expect(icon).not.toBeInTheDocument();
131+
});
131132

132-
it('매일 반복 일정 아이콘을 표시한다', () => {
133-
render(<RepeatIcon repeatType="daily" />);
133+
it('매일 반복 일정 아이콘을 표시한다', () => {
134+
render(<RepeatIcon repeatType="daily" />);
134135

135-
const icon = screen.getByTestId('repeat-icon');
136-
expect(icon).toBeInTheDocument();
137-
expect(icon).toHaveAttribute('data-repeat-type', 'daily');
138-
});
136+
const icon = screen.getByTestId('repeat-icon');
137+
expect(icon).toBeInTheDocument();
138+
expect(icon).toHaveAttribute('data-repeat-type', 'daily');
139139
});
140140
});
141141
});

src/icons/RepeatIcon.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import CalendarToday from '@mui/icons-material/CalendarToday';
2+
import CalendarViewMonth from '@mui/icons-material/CalendarViewMonth';
3+
import DateRange from '@mui/icons-material/DateRange';
4+
import Repeat from '@mui/icons-material/Repeat';
5+
6+
import { RepeatType } from '../types';
7+
8+
interface RepeatIconProps {
9+
repeatType: RepeatType;
10+
}
11+
12+
export function RepeatIcon({ repeatType }: RepeatIconProps) {
13+
if (repeatType === 'none') {
14+
return null;
15+
}
16+
17+
const getIcon = (type: RepeatType) => {
18+
switch (type) {
19+
case 'daily':
20+
return <Repeat data-testid="repeat-icon" data-repeat-type="daily" />;
21+
case 'weekly':
22+
return <DateRange data-testid="repeat-icon" data-repeat-type="weekly" />;
23+
case 'monthly':
24+
return <CalendarViewMonth data-testid="repeat-icon" data-repeat-type="monthly" />;
25+
case 'yearly':
26+
return <CalendarToday data-testid="repeat-icon" data-repeat-type="yearly" />;
27+
default:
28+
return null;
29+
}
30+
};
31+
32+
return getIcon(repeatType);
33+
}

0 commit comments

Comments
 (0)