Fix unit tests.

This commit is contained in:
Benoit Marty 2022-12-01 17:44:12 +01:00
parent d96ff6e527
commit 381103383e
2 changed files with 7 additions and 0 deletions

View File

@ -1152,11 +1152,13 @@ class OnboardingViewModelTest {
resultingState: SelectedHomeserverState, resultingState: SelectedHomeserverState,
config: HomeServerConnectionConfig = A_HOMESERVER_CONFIG, config: HomeServerConnectionConfig = A_HOMESERVER_CONFIG,
fingerprint: Fingerprint? = null, fingerprint: Fingerprint? = null,
canLoginWithQrCode: Boolean = false,
) { ) {
fakeHomeServerConnectionConfigFactory.givenConfigFor(homeserverUrl, fingerprint, config) fakeHomeServerConnectionConfigFactory.givenConfigFor(homeserverUrl, fingerprint, config)
fakeStartAuthenticationFlowUseCase.givenResult(config, StartAuthenticationResult(isHomeserverOutdated = false, resultingState)) fakeStartAuthenticationFlowUseCase.givenResult(config, StartAuthenticationResult(isHomeserverOutdated = false, resultingState))
givenRegistrationResultFor(RegisterAction.StartRegistration, RegistrationActionHandler.Result.StartRegistration) givenRegistrationResultFor(RegisterAction.StartRegistration, RegistrationActionHandler.Result.StartRegistration)
fakeHomeServerHistoryService.expectUrlToBeAdded(config.homeServerUri.toString()) fakeHomeServerHistoryService.expectUrlToBeAdded(config.homeServerUri.toString())
fakeAuthenticationService.givenIsQrLoginSupported(config, canLoginWithQrCode)
} }
private fun givenUpdatingHomeserverErrors(homeserverUrl: String, resultingState: SelectedHomeserverState, error: Throwable) { private fun givenUpdatingHomeserverErrors(homeserverUrl: String, resultingState: SelectedHomeserverState, error: Throwable) {
@ -1164,6 +1166,7 @@ class OnboardingViewModelTest {
fakeStartAuthenticationFlowUseCase.givenResult(A_HOMESERVER_CONFIG, StartAuthenticationResult(isHomeserverOutdated = false, resultingState)) fakeStartAuthenticationFlowUseCase.givenResult(A_HOMESERVER_CONFIG, StartAuthenticationResult(isHomeserverOutdated = false, resultingState))
givenRegistrationResultFor(RegisterAction.StartRegistration, RegistrationActionHandler.Result.Error(error)) givenRegistrationResultFor(RegisterAction.StartRegistration, RegistrationActionHandler.Result.Error(error))
fakeHomeServerHistoryService.expectUrlToBeAdded(A_HOMESERVER_CONFIG.homeServerUri.toString()) fakeHomeServerHistoryService.expectUrlToBeAdded(A_HOMESERVER_CONFIG.homeServerUri.toString())
fakeAuthenticationService.givenIsQrLoginSupported(A_HOMESERVER_CONFIG, false)
} }
private fun givenUserNameIsAvailable(userName: String) { private fun givenUserNameIsAvailable(userName: String) {

View File

@ -58,6 +58,10 @@ class FakeAuthenticationService : AuthenticationService by mockk() {
coEvery { getWellKnownData(matrixId, config) } returns result coEvery { getWellKnownData(matrixId, config) } returns result
} }
fun givenIsQrLoginSupported(config: HomeServerConnectionConfig, result: Boolean) {
coEvery { isQrLoginSupported(config) } returns result
}
fun givenWellKnownThrows(matrixId: String, config: HomeServerConnectionConfig?, cause: Throwable) { fun givenWellKnownThrows(matrixId: String, config: HomeServerConnectionConfig?, cause: Throwable) {
coEvery { getWellKnownData(matrixId, config) } throws cause coEvery { getWellKnownData(matrixId, config) } throws cause
} }