feat(content): 전체보기 UI 모델 매핑을 추가한다
This commit is contained in:
@@ -0,0 +1,112 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.content.overview
|
||||
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.data.ContentOverviewItemResponse
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.data.ContentOverviewPageResponse
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.data.ContentOverviewType
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.model.toContent
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.model.toTitleResId
|
||||
import kr.co.vividnext.sodalive.v2.main.content.overview.model.toUiModel
|
||||
import kr.co.vividnext.sodalive.v2.widget.AudioContentTag
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class ContentOverviewMapperTest {
|
||||
|
||||
@Test
|
||||
fun `type title resource maps to overview screen title`() {
|
||||
assertEquals(
|
||||
R.string.content_recommendation_section_new_and_hot,
|
||||
ContentOverviewType.NEW_AND_HOT_AUDIO.toTitleResId()
|
||||
)
|
||||
assertEquals(
|
||||
R.string.home_recommendation_section_first_audio_contents,
|
||||
ContentOverviewType.FIRST_AUDIO_CONTENT.toTitleResId()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `audio item maps tags and adult badge`() {
|
||||
val item = item(
|
||||
price = 0,
|
||||
isPointAvailable = true,
|
||||
isFirstContent = true,
|
||||
isOriginalSeries = true,
|
||||
isAdult = true
|
||||
).toUiModel()
|
||||
|
||||
assertEquals(
|
||||
setOf(
|
||||
AudioContentTag.Original,
|
||||
AudioContentTag.First,
|
||||
AudioContentTag.Point,
|
||||
AudioContentTag.Free
|
||||
),
|
||||
item.tags
|
||||
)
|
||||
assertTrue(item.showAdultBadge)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `paid non adult item has no free tag and hides adult badge`() {
|
||||
val item = item(price = 500, isAdult = false).toUiModel()
|
||||
|
||||
assertFalse(item.tags.contains(AudioContentTag.Free))
|
||||
assertFalse(item.showAdultBadge)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `page response preserves paging metadata and type`() {
|
||||
val content = pageResponse(
|
||||
type = ContentOverviewType.FIRST_AUDIO_CONTENT,
|
||||
page = 2,
|
||||
size = 20,
|
||||
hasNext = true,
|
||||
items = listOf(item(contentId = 7L))
|
||||
).toContent()
|
||||
|
||||
assertEquals(ContentOverviewType.FIRST_AUDIO_CONTENT, content.type)
|
||||
assertEquals(2, content.page)
|
||||
assertEquals(20, content.size)
|
||||
assertTrue(content.hasNext)
|
||||
assertEquals(listOf(7L), content.items.map { it.contentId })
|
||||
}
|
||||
|
||||
private fun pageResponse(
|
||||
type: ContentOverviewType = ContentOverviewType.NEW_AND_HOT_AUDIO,
|
||||
items: List<ContentOverviewItemResponse> = listOf(item()),
|
||||
page: Int = 0,
|
||||
size: Int = 20,
|
||||
hasNext: Boolean = false
|
||||
) = ContentOverviewPageResponse(
|
||||
type = type,
|
||||
items = items,
|
||||
page = page,
|
||||
size = size,
|
||||
hasNext = hasNext
|
||||
)
|
||||
|
||||
private fun item(
|
||||
contentId: Long = 1L,
|
||||
title: String = "content",
|
||||
coverImage: String? = "https://example.com/image.png",
|
||||
price: Int = 100,
|
||||
isAdult: Boolean = false,
|
||||
isPointAvailable: Boolean = false,
|
||||
isFirstContent: Boolean = false,
|
||||
isOriginalSeries: Boolean = false,
|
||||
creatorNickname: String = "creator"
|
||||
) = ContentOverviewItemResponse(
|
||||
contentId = contentId,
|
||||
title = title,
|
||||
coverImage = coverImage,
|
||||
price = price,
|
||||
isAdult = isAdult,
|
||||
isPointAvailable = isPointAvailable,
|
||||
isFirstContent = isFirstContent,
|
||||
isOriginalSeries = isOriginalSeries,
|
||||
creatorNickname = creatorNickname
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user