Skip to content

Commit 2221420

Browse files
committed
Add tests on TimelineItemActionComparator
1 parent 57595d6 commit 2221420

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/actionlist/model/TimelineItemActionComparator.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77

88
package io.element.android.features.messages.impl.actionlist.model
99

10+
import androidx.annotation.VisibleForTesting
11+
1012
class TimelineItemActionComparator : Comparator<TimelineItemAction> {
1113
// See order in https://www.figma.com/design/ux3tYoZV9WghC7hHT9Fhk0/Compound-iOS-Components?node-id=2946-2392
12-
private val orderedList = listOf(
14+
@VisibleForTesting
15+
val orderedList = listOf(
1316
TimelineItemAction.EndPoll,
1417
TimelineItemAction.ViewInTimeline,
1518
TimelineItemAction.Reply,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.messages.impl.actionlist.model
9+
10+
import org.junit.Test
11+
12+
class TimelineItemActionComparatorTest {
13+
@Test
14+
fun `check that the list in the comparator only contain each item once`() {
15+
val sut = TimelineItemActionComparator()
16+
sut.orderedList.forEach {
17+
require(sut.orderedList.count { item -> item == it } == 1, { "Duplicate ${it::class.java}.$it" })
18+
}
19+
}
20+
21+
@Test
22+
fun `check that the list in the comparator contains all the items`() {
23+
val sut = TimelineItemActionComparator()
24+
TimelineItemAction.entries.forEach {
25+
require(it in sut.orderedList, { "Missing ${it::class.simpleName}.$it in orderedList" })
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)