Created
April 28, 2021 14:40
-
-
Save stoichoandreev/a4ea4a9fcea9a6ce02dc7a7cc444bea5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.sniper.bdd.robo.LoginPresenter | |
import com.sniper.bdd.robo.LoginValidator | |
import com.sniper.bdd.robo.data.DataFactory | |
import io.mockk.MockKAnnotations | |
import io.mockk.every | |
import io.mockk.impl.annotations.RelaxedMockK | |
import io.mockk.verify | |
import org.junit.Before | |
import org.junit.Test | |
class LoginPresenterTest { | |
@RelaxedMockK | |
private lateinit var view: LoginPresenter.View | |
@RelaxedMockK | |
private lateinit var validator: LoginValidator | |
private lateinit var tested: LoginPresenter | |
@Before | |
fun setup() { | |
MockKAnnotations.init(this) | |
tested = LoginPresenter(view, validator) | |
} | |
@Test | |
fun `shouldClearErrorsOnLogin`() { | |
//when | |
tested.onLoginSubmit(DataFactory.EMAIL, DataFactory.VALID_PASSWORD) | |
//then | |
verify { view.clearErrors() } | |
} | |
@Test | |
fun `shouldDisplaySuccessfulLogin`() { | |
//given | |
every { validator.isEmailValid(any()) }.returns(true) | |
every { validator.isPasswordValid(any()) }.returns(true) | |
//when | |
tested.onLoginSubmit(DataFactory.EMAIL, DataFactory.VALID_PASSWORD) | |
//then | |
verify { view.displaySuccessfulLogin() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment