fix(creator): 후원 empty 실패 메시지를 표시한다

This commit is contained in:
2026-06-22 22:06:58 +09:00
parent 4097181923
commit ba6616c81a
2 changed files with 42 additions and 7 deletions

View File

@@ -133,6 +133,25 @@ class CreatorChannelDonationViewModelTest {
assertEquals(0, SharedPreferenceManager.can)
}
@Test
fun `Empty 상태에서 채널 후원 실패는 action toast message를 emit하고 consume한다`() {
stubGetDonations(response = Single.just(ApiResponse(true, donationResponse(donationCount = 0, ids = emptyList()), null)))
whenever(repository.postChannelDonation(100L, 50, false, "응원", "Bearer test-token")).thenReturn(
Single.just(ApiResponse(false, Any(), "후원 실패"))
)
viewModel.loadDonations(100L, isOwner = false)
viewModel.postChannelDonation(can = 50, isSecret = false, message = "응원")
val state = viewModel.donationStateLiveData.requireValue() as CreatorChannelDonationUiState.Empty
assertEquals("후원 실패", state.actionToastMessage)
viewModel.consumeActionToastMessage()
val consumed = viewModel.donationStateLiveData.requireValue() as CreatorChannelDonationUiState.Empty
assertEquals(null, consumed.actionToastMessage)
}
private fun stubGetDonations(
page: Int = 0,
response: Single<ApiResponse<CreatorChannelDonationTabResponse>>