Skip to content

Commit e6ba9c9

Browse files
committed
test: 알람제거 테스트 작성
1 parent c23c3bf commit e6ba9c9

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/__tests__/hooks/medium.useNotifications.spec.ts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ it('지정된 시간이 된 경우 알림이 새롭게 생성되어 추가된다
3434
waitFor(() => expect(result.current.notifications.length).toBe(1));
3535
});
3636

37-
it('index를 기준으로 알림을 적절하게 제거할 수 있다', () => {});
37+
it('index를 기준으로 알림을 적절하게 제거할 수 있다', async () => {
38+
const { result } = renderHook(() => useNotifications(events as Event[]));
39+
40+
const start = new Date(`${events[0].date}T${events[0].startTime}`);
41+
const beforeStart = start.getTime() - 10 * 60000;
42+
43+
await act(async () => {
44+
vi.setSystemTime(new Date(beforeStart - 1000));
45+
vi.advanceTimersByTime(1000);
46+
});
47+
48+
waitFor(() => expect(result.current.notifications.length).toBe(1));
49+
50+
const removedIndex = 0;
51+
52+
await act(async () => {
53+
result.current.removeNotification(removedIndex);
54+
});
55+
56+
waitFor(() => expect(result.current.notifications.length).toBe(0));
57+
});
3858

3959
it('이미 알림이 발생한 이벤트에 대해서는 중복 알림이 발생하지 않아야 한다', () => {});

0 commit comments

Comments
 (0)