|
1 | 1 | import { Event } from '../../types'; |
2 | 2 | import { createNotificationMessage, getUpcomingEvents } from '../../utils/notificationUtils'; |
| 3 | +import { createMockEvent } from '../utils'; |
3 | 4 |
|
4 | 5 | describe('getUpcomingEvents', () => { |
5 | | - it('알림 시간이 정확히 도래한 이벤트를 반환한다', () => {}); |
| 6 | + it('알림 시간이 정확히 도래한 이벤트를 반환한다', () => { |
| 7 | + const event = createMockEvent(1, { |
| 8 | + date: '2025-08-14', |
| 9 | + startTime: '09:00', |
| 10 | + notificationTime: 1, |
| 11 | + }); |
6 | 12 |
|
7 | | - it('이미 알림이 간 이벤트는 제외한다', () => {}); |
| 13 | + const result = getUpcomingEvents([event], new Date('2025-08-14T08:59:00'), []); |
8 | 14 |
|
9 | | - it('알림 시간이 아직 도래하지 않은 이벤트는 반환하지 않는다', () => {}); |
| 15 | + expect(result).toHaveLength(1); |
| 16 | + expect(result[0]).toBe(event); |
| 17 | + }); |
10 | 18 |
|
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 | + }); |
12 | 44 | }); |
13 | 45 |
|
14 | 46 | 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 | + }); |
16 | 57 | }); |
0 commit comments