Add tests on TimelineItemActionComparator
This commit is contained in:
@@ -7,9 +7,12 @@
|
||||
|
||||
package io.element.android.features.messages.impl.actionlist.model
|
||||
|
||||
import androidx.annotation.VisibleForTesting
|
||||
|
||||
class TimelineItemActionComparator : Comparator<TimelineItemAction> {
|
||||
// See order in https://www.figma.com/design/ux3tYoZV9WghC7hHT9Fhk0/Compound-iOS-Components?node-id=2946-2392
|
||||
private val orderedList = listOf(
|
||||
@VisibleForTesting
|
||||
val orderedList = listOf(
|
||||
TimelineItemAction.EndPoll,
|
||||
TimelineItemAction.ViewInTimeline,
|
||||
TimelineItemAction.Reply,
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Copyright 2024 New Vector Ltd.
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
* Please see LICENSE in the repository root for full details.
|
||||
*/
|
||||
|
||||
package io.element.android.features.messages.impl.actionlist.model
|
||||
|
||||
import org.junit.Test
|
||||
|
||||
class TimelineItemActionComparatorTest {
|
||||
@Test
|
||||
fun `check that the list in the comparator only contain each item once`() {
|
||||
val sut = TimelineItemActionComparator()
|
||||
sut.orderedList.forEach {
|
||||
require(sut.orderedList.count { item -> item == it } == 1, { "Duplicate ${it::class.java}.$it" })
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `check that the list in the comparator contains all the items`() {
|
||||
val sut = TimelineItemActionComparator()
|
||||
TimelineItemAction.entries.forEach {
|
||||
require(it in sut.orderedList, { "Missing ${it::class.simpleName}.$it in orderedList" })
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user