Skip to content

Commit 9621511

Browse files
author
이태영
committed
✅ easy.fetchHolidays.spec.ts 및 easy.notificationUtils.spec.ts 테스트 코드 작성 완료!
1 parent 2afbaa7 commit 9621511

File tree

2 files changed

+66
-8
lines changed

2 files changed

+66
-8
lines changed
Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
import { fetchHolidays } from '../../apis/fetchHolidays';
22
describe('fetchHolidays', () => {
3-
it('주어진 월의 공휴일만 반환한다', () => {});
3+
it('주어진 월의 공휴일만 반환한다', () => {
4+
const date = new Date('2025-08-01');
5+
const holidays = fetchHolidays(date);
46

5-
it('공휴일이 없는 월에 대해 빈 객체를 반환한다', () => {});
7+
expect(holidays).toHaveProperty('2025-08-15');
8+
expect(holidays['2025-08-15']).toBe('광복절');
9+
});
610

7-
it('여러 공휴일이 있는 월에 대해 모든 공휴일을 반환한다', () => {});
11+
it('공휴일이 없는 월에 대해 빈 객체를 반환한다', () => {
12+
const date = new Date('2025-11-01');
13+
const holidays = fetchHolidays(date);
14+
15+
expect(holidays).toEqual({});
16+
});
17+
18+
it('여러 공휴일이 있는 월에 대해 모든 공휴일을 반환한다', () => {
19+
const date = new Date('2025-10-01');
20+
const holidays = fetchHolidays(date);
21+
22+
expect(holidays).toHaveProperty('2025-10-03');
23+
expect(holidays).toHaveProperty('2025-10-09');
24+
});
825
});
Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,57 @@
11
import { Event } from '../../types';
22
import { createNotificationMessage, getUpcomingEvents } from '../../utils/notificationUtils';
3+
import { createMockEvent } from '../utils';
34

45
describe('getUpcomingEvents', () => {
5-
it('알림 시간이 정확히 도래한 이벤트를 반환한다', () => {});
6+
it('알림 시간이 정확히 도래한 이벤트를 반환한다', () => {
7+
const event = createMockEvent(1, {
8+
date: '2025-08-14',
9+
startTime: '09:00',
10+
notificationTime: 1,
11+
});
612

7-
it('이미 알림이 간 이벤트는 제외한다', () => {});
13+
const result = getUpcomingEvents([event], new Date('2025-08-14T08:59:00'), []);
814

9-
it('알림 시간이 아직 도래하지 않은 이벤트는 반환하지 않는다', () => {});
15+
expect(result).toHaveLength(1);
16+
expect(result[0]).toBe(event);
17+
});
1018

11-
it('알림 시간이 지난 이벤트는 반환하지 않는다', () => {});
19+
it('이미 알림이 간 이벤트는 제외한다', () => {
20+
const event = createMockEvent(1, {
21+
date: '2025-08-14',
22+
startTime: '09:00',
23+
notificationTime: 1,
24+
});
25+
26+
const result = getUpcomingEvents([event], new Date('2025-08-14T08:59:00'), ['1']);
27+
28+
expect(result).toHaveLength(0);
29+
expect(result).toEqual([]);
30+
});
31+
32+
it('알림 시간이 아직 도래하지 않은 이벤트는 반환하지 않는다', () => {
33+
const event = createMockEvent(1, {
34+
date: '2025-08-14',
35+
startTime: '09:00',
36+
notificationTime: 1,
37+
});
38+
39+
const result = getUpcomingEvents([event], new Date('2025-08-14T09:10:00'), []);
40+
41+
expect(result).toHaveLength(0);
42+
expect(result).toEqual([]);
43+
});
1244
});
1345

1446
describe('createNotificationMessage', () => {
15-
it('올바른 알림 메시지를 생성해야 한다', () => {});
47+
it('올바른 알림 메시지를 생성해야 한다', () => {
48+
const event = createMockEvent(1, {
49+
title: '[필수] 중요한 회의!',
50+
notificationTime: 5,
51+
});
52+
53+
const result = createNotificationMessage(event);
54+
55+
expect(result).toBe('5분 후 [필수] 중요한 회의! 일정이 시작됩니다.');
56+
});
1657
});

0 commit comments

Comments
 (0)