Fix test
This commit is contained in:
parent
fe85a7cc92
commit
cede53579c
1 changed files with 12 additions and 11 deletions
|
|
@ -25,6 +25,7 @@ import io.element.android.libraries.push.impl.notifications.fake.FakeNotificatio
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationFactory
|
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
import kotlinx.coroutines.test.runTest
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
private const val MY_USER_DISPLAY_NAME = "display-name"
|
private const val MY_USER_DISPLAY_NAME = "display-name"
|
||||||
|
|
@ -54,7 +55,7 @@ class NotificationRendererTest {
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given no notifications when rendering then cancels summary notification`() {
|
fun `given no notifications when rendering then cancels summary notification`() = runTest {
|
||||||
givenNoNotifications()
|
givenNoNotifications()
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -64,7 +65,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given last room message group notification is removed when rendering then remove the summary and then remove message notification`() {
|
fun `given last room message group notification is removed when rendering then remove the summary and then remove message notification`() = runTest {
|
||||||
givenNotifications(roomNotifications = listOf(RoomNotification.Removed(A_ROOM_ID)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
givenNotifications(roomNotifications = listOf(RoomNotification.Removed(A_ROOM_ID)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -76,7 +77,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a room message group notification is removed when rendering then remove the message notification and update summary`() {
|
fun `given a room message group notification is removed when rendering then remove the message notification and update summary`() = runTest {
|
||||||
givenNotifications(roomNotifications = listOf(RoomNotification.Removed(A_ROOM_ID)))
|
givenNotifications(roomNotifications = listOf(RoomNotification.Removed(A_ROOM_ID)))
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -88,7 +89,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a room message group notification is added when rendering then show the message notification and update summary`() {
|
fun `given a room message group notification is added when rendering then show the message notification and update summary`() = runTest {
|
||||||
givenNotifications(
|
givenNotifications(
|
||||||
roomNotifications = listOf(
|
roomNotifications = listOf(
|
||||||
RoomNotification.Message(
|
RoomNotification.Message(
|
||||||
|
|
@ -107,7 +108,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given last simple notification is removed when rendering then remove the summary and then remove simple notification`() {
|
fun `given last simple notification is removed when rendering then remove the summary and then remove simple notification`() = runTest {
|
||||||
givenNotifications(simpleNotifications = listOf(OneShotNotification.Removed(AN_EVENT_ID.value)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
givenNotifications(simpleNotifications = listOf(OneShotNotification.Removed(AN_EVENT_ID.value)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -119,7 +120,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a simple notification is removed when rendering then remove the simple notification and update summary`() {
|
fun `given a simple notification is removed when rendering then remove the simple notification and update summary`() = runTest {
|
||||||
givenNotifications(simpleNotifications = listOf(OneShotNotification.Removed(AN_EVENT_ID.value)))
|
givenNotifications(simpleNotifications = listOf(OneShotNotification.Removed(AN_EVENT_ID.value)))
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -131,7 +132,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a simple notification is added when rendering then show the simple notification and update summary`() {
|
fun `given a simple notification is added when rendering then show the simple notification and update summary`() = runTest {
|
||||||
givenNotifications(
|
givenNotifications(
|
||||||
simpleNotifications = listOf(
|
simpleNotifications = listOf(
|
||||||
OneShotNotification.Append(
|
OneShotNotification.Append(
|
||||||
|
|
@ -150,7 +151,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given last invitation notification is removed when rendering then remove the summary and then remove invitation notification`() {
|
fun `given last invitation notification is removed when rendering then remove the summary and then remove invitation notification`() = runTest {
|
||||||
givenNotifications(invitationNotifications = listOf(OneShotNotification.Removed(A_ROOM_ID.value)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
givenNotifications(invitationNotifications = listOf(OneShotNotification.Removed(A_ROOM_ID.value)), summaryNotification = A_REMOVE_SUMMARY_NOTIFICATION)
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -162,7 +163,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given an invitation notification is removed when rendering then remove the invitation notification and update summary`() {
|
fun `given an invitation notification is removed when rendering then remove the invitation notification and update summary`() = runTest {
|
||||||
givenNotifications(invitationNotifications = listOf(OneShotNotification.Removed(A_ROOM_ID.value)))
|
givenNotifications(invitationNotifications = listOf(OneShotNotification.Removed(A_ROOM_ID.value)))
|
||||||
|
|
||||||
renderEventsAsNotifications()
|
renderEventsAsNotifications()
|
||||||
|
|
@ -174,7 +175,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given an invitation notification is added when rendering then show the invitation notification and update summary`() {
|
fun `given an invitation notification is added when rendering then show the invitation notification and update summary`() = runTest {
|
||||||
givenNotifications(
|
givenNotifications(
|
||||||
simpleNotifications = listOf(
|
simpleNotifications = listOf(
|
||||||
OneShotNotification.Append(
|
OneShotNotification.Append(
|
||||||
|
|
@ -192,7 +193,7 @@ class NotificationRendererTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderEventsAsNotifications() {
|
private suspend fun renderEventsAsNotifications() {
|
||||||
notificationRenderer.render(
|
notificationRenderer.render(
|
||||||
MatrixUser(A_SESSION_ID, MY_USER_DISPLAY_NAME, MY_USER_AVATAR_URL),
|
MatrixUser(A_SESSION_ID, MY_USER_DISPLAY_NAME, MY_USER_AVATAR_URL),
|
||||||
useCompleteNotificationFormat = USE_COMPLETE_NOTIFICATION_FORMAT,
|
useCompleteNotificationFormat = USE_COMPLETE_NOTIFICATION_FORMAT,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue