mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
explicitly declaring the fake registrationb wizard as not relaxed and creating new test instances for each case
This commit is contained in:
parent
abf62aff47
commit
7f943d37fd
2 changed files with 5 additions and 4 deletions
|
@ -37,9 +37,6 @@ private val A_PID_TO_REGISTER = RegisterThreePid.Email("an email")
|
|||
|
||||
class RegistrationActionHandlerTest {
|
||||
|
||||
private val fakeRegistrationWizard = FakeRegistrationWizard()
|
||||
private val registrationActionHandler = RegistrationActionHandler()
|
||||
|
||||
@Test
|
||||
fun `when handling register action then delegates to wizard`() = runBlockingTest {
|
||||
val cases = listOf(
|
||||
|
@ -60,6 +57,8 @@ class RegistrationActionHandlerTest {
|
|||
}
|
||||
|
||||
private suspend fun testSuccessfulActionDelegation(case: Case) {
|
||||
val registrationActionHandler = RegistrationActionHandler()
|
||||
val fakeRegistrationWizard = FakeRegistrationWizard()
|
||||
fakeRegistrationWizard.givenSuccessFor(result = A_SESSION, case.expect)
|
||||
|
||||
val result = registrationActionHandler.handleRegisterAction(fakeRegistrationWizard, case.action)
|
||||
|
@ -71,3 +70,5 @@ class RegistrationActionHandlerTest {
|
|||
private fun case(action: RegisterAction, expect: suspend RegistrationWizard.() -> RegistrationResult) = Case(action, expect)
|
||||
|
||||
private class Case(val action: RegisterAction, val expect: suspend RegistrationWizard.() -> RegistrationResult)
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import org.matrix.android.sdk.api.auth.registration.RegistrationResult
|
|||
import org.matrix.android.sdk.api.auth.registration.RegistrationWizard
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
||||
class FakeRegistrationWizard : RegistrationWizard by mockk() {
|
||||
class FakeRegistrationWizard : RegistrationWizard by mockk(relaxed = false) {
|
||||
|
||||
fun givenSuccessFor(result: Session, expect: suspend RegistrationWizard.() -> RegistrationResult) {
|
||||
coEvery { expect(this@FakeRegistrationWizard) } returns RegistrationResult.Success(result)
|
||||
|
|
Loading…
Reference in a new issue