Fix tests and remove unused code.
This commit is contained in:
-1
@@ -39,7 +39,6 @@ class QrCodeScanPresenter(
|
||||
private val qrCodeLoginDataFactory: MatrixQrCodeLoginDataFactory,
|
||||
private val qrCodeLoginManager: QrCodeLoginManager,
|
||||
private val coroutineDispatchers: CoroutineDispatchers,
|
||||
private val defaultAccountProviderAccessControl: DefaultAccountProviderAccessControl,
|
||||
) : Presenter<QrCodeScanState> {
|
||||
private var isScanning by mutableStateOf(true)
|
||||
|
||||
|
||||
-38
@@ -66,44 +66,6 @@ class QrCodeScanPresenterTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - scanned QR code successfully, but homeserver not allowed`() = runTest {
|
||||
val qrCodeLoginDataFactory = FakeMatrixQrCodeLoginDataFactory(
|
||||
parseQrCodeLoginDataResult = {
|
||||
Result.success(
|
||||
FakeMatrixQrCodeLoginData(
|
||||
serverNameResult = { "example.com" }
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
val presenter = createQrCodeScanPresenter(
|
||||
qrCodeLoginDataFactory = qrCodeLoginDataFactory,
|
||||
enterpriseService = FakeEnterpriseService(
|
||||
isAllowedToConnectToHomeserverResult = { false },
|
||||
defaultHomeserverListResult = { listOf("element.io") },
|
||||
)
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
initialState.eventSink(QrCodeScanEvents.QrCodeScanned(byteArrayOf()))
|
||||
assertThat(awaitItem().isScanning).isFalse()
|
||||
assertThat(awaitItem().authenticationAction.isLoading()).isTrue()
|
||||
awaitItem().also { state ->
|
||||
assertThat(
|
||||
(state.authenticationAction
|
||||
.errorOrNull() as AccountProviderAccessException.UnauthorizedAccountProviderException).unauthorisedAccountProviderTitle
|
||||
)
|
||||
.isEqualTo("example.com")
|
||||
assertThat(
|
||||
(state.authenticationAction
|
||||
.errorOrNull() as AccountProviderAccessException.UnauthorizedAccountProviderException).authorisedAccountProviderTitles
|
||||
)
|
||||
.containsExactly("element.io")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `present - scanned QR code failed and can be retried`() = runTest {
|
||||
val qrCodeLoginDataFactory = FakeMatrixQrCodeLoginDataFactory(
|
||||
|
||||
Reference in New Issue
Block a user