feat(widget): 랭킹 순위 변동 표시 옵션을 추가한다
This commit is contained in:
@@ -5,12 +5,12 @@ import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType
|
|||||||
data class CreatorRankingItem(
|
data class CreatorRankingItem(
|
||||||
val creatorId: Long,
|
val creatorId: Long,
|
||||||
val rank: Int,
|
val rank: Int,
|
||||||
val previousRank: Int?,
|
|
||||||
val rankChangeType: RankingChangeType,
|
val rankChangeType: RankingChangeType,
|
||||||
val rankChangeAmount: Int,
|
val rankChangeAmount: Int,
|
||||||
val creatorName: String,
|
val creatorName: String,
|
||||||
val imageUrl: String,
|
val imageUrl: String,
|
||||||
val isBlocked: Boolean
|
val isBlocked: Boolean,
|
||||||
|
val showRankChange: Boolean = true
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
require(rank >= 1) { "rank must be greater than or equal to 1." }
|
require(rank >= 1) { "rank must be greater than or equal to 1." }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package kr.co.vividnext.sodalive.v2.widget.creatorranking
|
package kr.co.vividnext.sodalive.v2.widget.creatorranking
|
||||||
|
|
||||||
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType
|
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType
|
||||||
|
import kr.co.vividnext.sodalive.v2.widget.ranking.RankingChangeType.Increase
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@@ -45,23 +46,45 @@ class CreatorRankingItemTest {
|
|||||||
assertEquals("크리에이터 이름", item.displayName(inaccessibleMessage = "접근할 수 없는 정보입니다."))
|
assertEquals("크리에이터 이름", item.displayName(inaccessibleMessage = "접근할 수 없는 정보입니다."))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `순위 변동 표시는 기본값이 true이다`() {
|
||||||
|
val item = sampleItem()
|
||||||
|
|
||||||
|
assertTrue(item.showRankChange)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `순위 변동 표시는 숨김 처리할 수 있다`() {
|
||||||
|
val item = sampleItem(showRankChange = false)
|
||||||
|
|
||||||
|
assertFalse(item.showRankChange)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `차단된 creator id 아이템은 터치할 수 없다`() {
|
||||||
|
val item = sampleItem(creatorId = 0L, isBlocked = true)
|
||||||
|
|
||||||
|
assertTrue(item.isInaccessible)
|
||||||
|
assertFalse(item.isTouchable)
|
||||||
|
}
|
||||||
|
|
||||||
private fun sampleItem(
|
private fun sampleItem(
|
||||||
creatorId: Long = 1L,
|
creatorId: Long = 1L,
|
||||||
rank: Int = 1,
|
rank: Int = 1,
|
||||||
previousRank: Int? = 5,
|
rankChangeType: RankingChangeType = Increase,
|
||||||
rankChangeType: RankingChangeType = RankingChangeType.Increase,
|
|
||||||
rankChangeAmount: Int = 4,
|
rankChangeAmount: Int = 4,
|
||||||
creatorName: String = "크리에이터 이름",
|
creatorName: String = "크리에이터 이름",
|
||||||
imageUrl: String = "https://example.com/image.png",
|
imageUrl: String = "https://example.com/image.png",
|
||||||
isBlocked: Boolean = false
|
isBlocked: Boolean = false,
|
||||||
|
showRankChange: Boolean = true
|
||||||
) = CreatorRankingItem(
|
) = CreatorRankingItem(
|
||||||
creatorId = creatorId,
|
creatorId = creatorId,
|
||||||
rank = rank,
|
rank = rank,
|
||||||
previousRank = previousRank,
|
|
||||||
rankChangeType = rankChangeType,
|
rankChangeType = rankChangeType,
|
||||||
rankChangeAmount = rankChangeAmount,
|
rankChangeAmount = rankChangeAmount,
|
||||||
creatorName = creatorName,
|
creatorName = creatorName,
|
||||||
imageUrl = imageUrl,
|
imageUrl = imageUrl,
|
||||||
isBlocked = isBlocked
|
isBlocked = isBlocked,
|
||||||
|
showRankChange = showRankChange
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user