Increase coverage of devices view model.
This commit is contained in:
parent
50466792c6
commit
73e2f02c48
|
@ -53,6 +53,8 @@ import org.matrix.android.sdk.api.session.crypto.crosssigning.DeviceTrustLevel
|
|||
import org.matrix.android.sdk.api.session.crypto.model.CryptoDeviceInfo
|
||||
import org.matrix.android.sdk.api.session.crypto.model.DeviceInfo
|
||||
import org.matrix.android.sdk.api.session.crypto.model.RoomEncryptionTrustLevel
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTransaction
|
||||
import org.matrix.android.sdk.api.session.crypto.verification.VerificationTxState
|
||||
import org.matrix.android.sdk.api.session.uia.DefaultBaseAuth
|
||||
|
||||
private const val A_CURRENT_DEVICE_ID = "current-device-id"
|
||||
|
@ -76,6 +78,10 @@ class DevicesViewModelTest {
|
|||
private val fakeVectorPreferences = FakeVectorPreferences()
|
||||
private val toggleIpAddressVisibilityUseCase = mockk<ToggleIpAddressVisibilityUseCase>()
|
||||
|
||||
private val verifiedTransaction = mockk<VerificationTransaction>().apply {
|
||||
every { state } returns VerificationTxState.Verified
|
||||
}
|
||||
|
||||
private fun createViewModel(): DevicesViewModel {
|
||||
return DevicesViewModel(
|
||||
initialState = DevicesViewState(),
|
||||
|
@ -375,6 +381,18 @@ class DevicesViewModelTest {
|
|||
viewModelTest.finish()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given the view model when a verified transaction is updated then device list is refreshed`() {
|
||||
// Given
|
||||
val viewModel = createViewModel()
|
||||
|
||||
// When
|
||||
viewModel.transactionUpdated(verifiedTransaction)
|
||||
|
||||
// Then
|
||||
verify { viewModel.refreshDeviceList() }
|
||||
}
|
||||
|
||||
private fun givenCurrentSessionCrossSigningInfo(): CurrentSessionCrossSigningInfo {
|
||||
val currentSessionCrossSigningInfo = mockk<CurrentSessionCrossSigningInfo>()
|
||||
every { currentSessionCrossSigningInfo.deviceId } returns A_CURRENT_DEVICE_ID
|
||||
|
|
Loading…
Reference in New Issue