feat(home): 홈 추천 activity type 매퍼를 추가한다
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
|
||||
@StringRes
|
||||
fun String.toRecommendedActivityTypeLabelRes(): Int? = RecommendedActivityType.from(this)?.labelResId
|
||||
@@ -0,0 +1,18 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home.model
|
||||
|
||||
import androidx.annotation.StringRes
|
||||
import kr.co.vividnext.sodalive.R
|
||||
|
||||
enum class RecommendedActivityType(
|
||||
val code: String,
|
||||
@StringRes val labelResId: Int
|
||||
) {
|
||||
Live("LIVE", R.string.home_recommendation_activity_live),
|
||||
LiveReplay("LIVE_REPLAY", R.string.home_recommendation_activity_live),
|
||||
Audio("AUDIO", R.string.home_recommendation_activity_audio),
|
||||
Community("COMMUNITY", R.string.home_recommendation_activity_community);
|
||||
|
||||
companion object {
|
||||
fun from(code: String): RecommendedActivityType? = entries.firstOrNull { it.code.equals(code, ignoreCase = true) }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home
|
||||
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.toRecommendedActivityTypeLabelRes
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Test
|
||||
|
||||
class RecommendedActivityTypeTest {
|
||||
@Test
|
||||
fun `LIVE maps to live label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_live,
|
||||
"LIVE".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `LIVE_REPLAY maps to live label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_live,
|
||||
"LIVE_REPLAY".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `AUDIO maps to audio label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_audio,
|
||||
"AUDIO".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `COMMUNITY maps to community label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_community,
|
||||
"COMMUNITY".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `lowercase activity type maps to matching label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_live,
|
||||
"live".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `mixed case activity type maps to matching label`() {
|
||||
assertEquals(
|
||||
R.string.home_recommendation_activity_live,
|
||||
"Live_RePlay".toRecommendedActivityTypeLabelRes()
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `unknown activity type maps to null`() {
|
||||
assertNull("UNKNOWN".toRecommendedActivityTypeLabelRes())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user