oday
09/18/2022, 5:33 PMrunTest{ }
to call it, but this is causing me to be unable to answer with the type that I want now, since it’s now expecting TestResult
, I want to return Result.success(obj)
@ExperimentalCoroutinesApi
@Inject
fun firebaseSignInWithEmail(mock: FirebaseSignInWithEmail) {
every {
runTest {
mock.invoke("anyEmail", "anyPassword")
}
} returns TestResult
}
oday
09/18/2022, 5:34 PModay
09/18/2022, 5:34 PMclass FirebaseSignInWithEmail @Inject constructor(
private val firebaseAuth: FirebaseAuth
) {
suspend operator fun invoke(email: String, password: String): Result<AuthResult> {
return suspendCoroutine { cont ->
firebaseAuth.signInWithEmailAndPassword(email, password)
.addOnSuccessListener {
cont.resume(Result.success(it))
}
.addOnFailureListener {
cont.resumeWith(Result.failure(it))
}
}
}
}
franztesca
09/18/2022, 7:05 PM