@@ -173,6 +173,57 @@ struct FCMTokenSyncHandlerTests {
173173 _ = handler
174174 }
175175
176+ @Test ( " 로그인 세션 전이 시 현재 FCM token을 저장한다 " )
177+ func 로그인_세션_전이_시_현재_FCM_token을_저장한다( ) async throws {
178+ let notificationCenter = NotificationCenter ( )
179+ let messagingService = PushMessagingServiceSpy ( currentFCMToken: " current-token " )
180+ let userService = UserServiceSpy ( )
181+ let authService = AuthServiceSpy ( uid: nil )
182+ let store = UserDefaultsStoreSpy ( )
183+ let handler = FCMTokenSyncHandler (
184+ authService: authService,
185+ messagingService: messagingService,
186+ userService: userService,
187+ store: store,
188+ notificationCenter: notificationCenter
189+ )
190+
191+ authService. updateSession ( uid: " user-id " )
192+
193+ try await waitUntil {
194+ await userService. updatedFCMTokens == [ " current-token " ]
195+ }
196+ _ = handler
197+ }
198+
199+ @Test ( " 로그아웃 세션 전이 시 저장된 FCM token hash를 제거한다 " )
200+ func 로그아웃_세션_전이_시_저장된_FCM_token_hash를_제거한다( ) async throws {
201+ let notificationCenter = NotificationCenter ( )
202+ let messagingService = PushMessagingServiceSpy ( currentFCMToken: " current-token " )
203+ let userService = UserServiceSpy ( )
204+ let authService = AuthServiceSpy ( )
205+ let store = UserDefaultsStoreSpy ( )
206+ let handler = FCMTokenSyncHandler (
207+ authService: authService,
208+ messagingService: messagingService,
209+ userService: userService,
210+ store: store,
211+ notificationCenter: notificationCenter
212+ )
213+
214+ notificationCenter. post ( name: . didRequestFCMTokenSync, object: nil )
215+ try await waitUntil {
216+ store. hasStoredString
217+ }
218+
219+ authService. updateSession ( uid: nil )
220+
221+ try await waitUntil {
222+ !store. hasStoredString
223+ }
224+ _ = handler
225+ }
226+
176227}
177228
178229private actor UserServiceSpy : UserService {
0 commit comments