-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 상수 가시성 변경 * feat: test fixture 구현 * feat: fake repository 이미지 업로드 기능 추가 * test: OfferingWriteViewModelTest 이미지 업로드 test 코드 작성
- Loading branch information
1 parent
c93ce60
commit 7e4fbd2
Showing
4 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...pp/src/test/java/com/zzang/chongdae/presentation/view/write/OfferingWriteViewModelTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.zzang.chongdae.presentation.view.write | ||
|
||
import com.zzang.chongdae.domain.repository.OfferingRepository | ||
import com.zzang.chongdae.presentation.view.write.OfferingWriteViewModel.Companion.HTTPS | ||
import com.zzang.chongdae.repository.FakeOfferingRepository | ||
import com.zzang.chongdae.util.CoroutinesTestExtension | ||
import com.zzang.chongdae.util.InstantTaskExecutorExtension | ||
import com.zzang.chongdae.util.TestFixture.martiPartBody | ||
import com.zzang.chongdae.util.TestFixture.productUrl | ||
import com.zzang.chongdae.util.getOrAwaitValue | ||
import kotlinx.coroutines.ExperimentalCoroutinesApi | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.jupiter.api.BeforeEach | ||
import org.junit.jupiter.api.DisplayName | ||
import org.junit.jupiter.api.Test | ||
import org.junit.jupiter.api.extension.ExtendWith | ||
|
||
@ExperimentalCoroutinesApi | ||
@ExtendWith(CoroutinesTestExtension::class) | ||
@ExtendWith(InstantTaskExecutorExtension::class) | ||
class OfferingWriteViewModelTest { | ||
private lateinit var viewModel: OfferingWriteViewModel | ||
private lateinit var offeringRepository: OfferingRepository | ||
|
||
@BeforeEach | ||
fun setUp() { | ||
offeringRepository = FakeOfferingRepository() | ||
viewModel = OfferingWriteViewModel(offeringRepository) | ||
} | ||
|
||
@DisplayName("상품 url을 통해 og 이미지 정보를 가져온다") | ||
@Test | ||
fun saveProductImageOg() { | ||
// given | ||
// when | ||
viewModel.postProductImageOg() | ||
|
||
// then | ||
val result = viewModel.thumbnailUrl.getOrAwaitValue() | ||
assertThat(result).isEqualTo(HTTPS + productUrl.imageUrl) | ||
} | ||
|
||
@DisplayName("상품 이미지를 S3에 저장한다") | ||
@Test | ||
fun saveProductImageS3() { | ||
// given | ||
// when | ||
viewModel.uploadImageFile(martiPartBody) | ||
|
||
// then | ||
val result = viewModel.thumbnailUrl.getOrAwaitValue() | ||
assertThat(result).isEqualTo(productUrl.imageUrl) | ||
} | ||
|
||
@DisplayName("업로드한 상품 이미지를 지울 수 있다") | ||
@Test | ||
fun deleteProductImage() { | ||
// given | ||
viewModel.uploadImageFile(martiPartBody) | ||
|
||
// when | ||
viewModel.clearProductImage() | ||
|
||
// then | ||
val result = viewModel.thumbnailUrl.getOrAwaitValue() | ||
assertThat(result).isEqualTo(null) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters