|
7 | 7 |
|
8 | 8 | package io.element.android.libraries.push.impl
|
9 | 9 |
|
| 10 | +import app.cash.turbine.test |
10 | 11 | import com.google.common.truth.Truth.assertThat
|
11 | 12 | import io.element.android.libraries.matrix.api.MatrixClient
|
12 | 13 | import io.element.android.libraries.matrix.api.core.SessionId
|
| 14 | +import io.element.android.libraries.matrix.test.AN_EVENT_ID |
13 | 15 | import io.element.android.libraries.matrix.test.AN_EXCEPTION
|
| 16 | +import io.element.android.libraries.matrix.test.A_ROOM_ID |
14 | 17 | import io.element.android.libraries.matrix.test.A_SESSION_ID
|
15 | 18 | import io.element.android.libraries.matrix.test.FakeMatrixClient
|
16 | 19 | import io.element.android.libraries.push.api.GetCurrentPushProvider
|
| 20 | +import io.element.android.libraries.push.api.history.PushHistoryItem |
17 | 21 | import io.element.android.libraries.push.impl.push.FakeMutableBatteryOptimizationStore
|
18 | 22 | import io.element.android.libraries.push.impl.push.MutableBatteryOptimizationStore
|
19 | 23 | import io.element.android.libraries.push.impl.store.InMemoryPushDataStore
|
@@ -297,6 +301,41 @@ class DefaultPushServiceTest {
|
297 | 301 | resetResult.assertions().isCalledOnce()
|
298 | 302 | }
|
299 | 303 |
|
| 304 | + @Test |
| 305 | + fun `resetPushHistory invokes the store method`() = runTest { |
| 306 | + val resetResult = lambdaRecorder<Unit> { } |
| 307 | + val defaultPushService = createDefaultPushService( |
| 308 | + pushDataStore = InMemoryPushDataStore( |
| 309 | + resetResult = resetResult |
| 310 | + ), |
| 311 | + ) |
| 312 | + defaultPushService.resetPushHistory() |
| 313 | + resetResult.assertions().isCalledOnce() |
| 314 | + } |
| 315 | + |
| 316 | + @Test |
| 317 | + fun `getPushHistoryItemsFlow invokes the store method`() = runTest { |
| 318 | + val store = InMemoryPushDataStore() |
| 319 | + val aPushHistoryItem = PushHistoryItem( |
| 320 | + pushDate = 0L, |
| 321 | + formattedDate = "formattedDate", |
| 322 | + providerInfo = "providerInfo", |
| 323 | + eventId = AN_EVENT_ID, |
| 324 | + roomId = A_ROOM_ID, |
| 325 | + sessionId = A_SESSION_ID, |
| 326 | + hasBeenResolved = false, |
| 327 | + comment = null, |
| 328 | + ) |
| 329 | + val defaultPushService = createDefaultPushService( |
| 330 | + pushDataStore = store, |
| 331 | + ) |
| 332 | + defaultPushService.getPushHistoryItemsFlow().test { |
| 333 | + assertThat(awaitItem().isEmpty()).isTrue() |
| 334 | + store.emitPushHistoryItems(listOf(aPushHistoryItem)) |
| 335 | + assertThat(awaitItem().first()).isEqualTo(aPushHistoryItem) |
| 336 | + } |
| 337 | + } |
| 338 | + |
300 | 339 | private fun createDefaultPushService(
|
301 | 340 | testPush: TestPush = FakeTestPush(),
|
302 | 341 | userPushStoreFactory: UserPushStoreFactory = FakeUserPushStoreFactory(),
|
|
0 commit comments