Fix tests.
This commit is contained in:
parent
e8d1490a92
commit
ae7137bd1d
2 changed files with 12 additions and 12 deletions
|
|
@ -21,7 +21,7 @@ import io.element.android.libraries.matrix.api.core.EventId
|
||||||
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
import io.element.android.libraries.matrix.test.AN_EVENT_ID
|
||||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
import io.element.android.libraries.matrix.test.A_SESSION_ID
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeNotificationUtils
|
import io.element.android.libraries.push.impl.notifications.fake.FakeAndroidNotificationFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator
|
import io.element.android.libraries.push.impl.notifications.fake.FakeRoomGroupMessageCreator
|
||||||
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator
|
import io.element.android.libraries.push.impl.notifications.fake.FakeSummaryGroupMessageCreator
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
|
|
@ -36,19 +36,19 @@ private val A_MESSAGE_EVENT = aNotifiableMessageEvent(eventId = AN_EVENT_ID, roo
|
||||||
|
|
||||||
class NotificationFactoryTest {
|
class NotificationFactoryTest {
|
||||||
|
|
||||||
private val notificationUtils = FakeNotificationUtils()
|
private val androidNotificationFactory = FakeAndroidNotificationFactory()
|
||||||
private val roomGroupMessageCreator = FakeRoomGroupMessageCreator()
|
private val roomGroupMessageCreator = FakeRoomGroupMessageCreator()
|
||||||
private val summaryGroupMessageCreator = FakeSummaryGroupMessageCreator()
|
private val summaryGroupMessageCreator = FakeSummaryGroupMessageCreator()
|
||||||
|
|
||||||
private val notificationFactory = NotificationFactory(
|
private val notificationFactory = NotificationFactory(
|
||||||
notificationUtils.instance,
|
androidNotificationFactory.instance,
|
||||||
roomGroupMessageCreator.instance,
|
roomGroupMessageCreator.instance,
|
||||||
summaryGroupMessageCreator.instance
|
summaryGroupMessageCreator.instance
|
||||||
)
|
)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a room invitation when mapping to notification then is Append`() = testWith(notificationFactory) {
|
fun `given a room invitation when mapping to notification then is Append`() = testWith(notificationFactory) {
|
||||||
val expectedNotification = notificationUtils.givenBuildRoomInvitationNotificationFor(AN_INVITATION_EVENT)
|
val expectedNotification = androidNotificationFactory.givenCreateRoomInvitationNotificationFor(AN_INVITATION_EVENT)
|
||||||
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, AN_INVITATION_EVENT))
|
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, AN_INVITATION_EVENT))
|
||||||
|
|
||||||
val result = roomInvitation.toNotifications()
|
val result = roomInvitation.toNotifications()
|
||||||
|
|
@ -85,7 +85,7 @@ class NotificationFactoryTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `given a simple event when mapping to notification then is Append`() = testWith(notificationFactory) {
|
fun `given a simple event when mapping to notification then is Append`() = testWith(notificationFactory) {
|
||||||
val expectedNotification = notificationUtils.givenBuildSimpleInvitationNotificationFor(A_SIMPLE_EVENT)
|
val expectedNotification = androidNotificationFactory.givenCreateSimpleInvitationNotificationFor(A_SIMPLE_EVENT)
|
||||||
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, A_SIMPLE_EVENT))
|
val roomInvitation = listOf(ProcessedEvent(ProcessedEvent.Type.KEEP, A_SIMPLE_EVENT))
|
||||||
|
|
||||||
val result = roomInvitation.toNotifications()
|
val result = roomInvitation.toNotifications()
|
||||||
|
|
|
||||||
|
|
@ -17,24 +17,24 @@
|
||||||
package io.element.android.libraries.push.impl.notifications.fake
|
package io.element.android.libraries.push.impl.notifications.fake
|
||||||
|
|
||||||
import android.app.Notification
|
import android.app.Notification
|
||||||
import io.element.android.libraries.push.impl.notifications.NotificationUtils
|
import io.element.android.libraries.push.impl.notifications.factories.NotificationFactory
|
||||||
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.InviteNotifiableEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.SimpleNotifiableEvent
|
||||||
import io.mockk.every
|
import io.mockk.every
|
||||||
import io.mockk.mockk
|
import io.mockk.mockk
|
||||||
|
|
||||||
class FakeNotificationUtils {
|
class FakeAndroidNotificationFactory {
|
||||||
val instance = mockk<NotificationUtils>()
|
val instance = mockk<NotificationFactory>()
|
||||||
|
|
||||||
fun givenBuildRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {
|
fun givenCreateRoomInvitationNotificationFor(event: InviteNotifiableEvent): Notification {
|
||||||
val mockNotification = mockk<Notification>()
|
val mockNotification = mockk<Notification>()
|
||||||
every { instance.buildRoomInvitationNotification(event) } returns mockNotification
|
every { instance.createRoomInvitationNotification(event) } returns mockNotification
|
||||||
return mockNotification
|
return mockNotification
|
||||||
}
|
}
|
||||||
|
|
||||||
fun givenBuildSimpleInvitationNotificationFor(event: SimpleNotifiableEvent): Notification {
|
fun givenCreateSimpleInvitationNotificationFor(event: SimpleNotifiableEvent): Notification {
|
||||||
val mockNotification = mockk<Notification>()
|
val mockNotification = mockk<Notification>()
|
||||||
every { instance.buildSimpleEventNotification(event) } returns mockNotification
|
every { instance.createSimpleEventNotification(event) } returns mockNotification
|
||||||
return mockNotification
|
return mockNotification
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue