Fix login when an error occurs (#187)

This commit is contained in:
Rafał Borcz
2018-11-28 20:06:08 +01:00
committed by Mikołaj Pich
parent 7686228e01
commit 834ef7c297
20 changed files with 80 additions and 43 deletions

View File

@ -68,8 +68,9 @@ class LoginOptionsPresenterTest {
@Test
fun onSelectedStudentTest() {
doReturn(Completable.complete()).`when`(studentRepository).saveStudent(testStudent)
doReturn(Single.just(1L)).`when`(studentRepository).saveStudent(testStudent)
doReturn(Single.just(emptyList<Semester>())).`when`(semesterRepository).getSemesters(testStudent, true)
doReturn(Completable.complete()).`when`(studentRepository).switchStudent(testStudent)
presenter.onItemSelected(LoginOptionsItem(testStudent))
verify(loginOptionsView).showContent(false)
verify(loginOptionsView).showProgress(true)
@ -78,9 +79,9 @@ class LoginOptionsPresenterTest {
@Test
fun onSelectedStudentErrorTest() {
doReturn(Completable.error(testException)).`when`(studentRepository).saveStudent(testStudent)
doReturn(Single.error<Student>(testException)).`when`(studentRepository).saveStudent(testStudent)
doReturn(Single.just(emptyList<Semester>())).`when`(semesterRepository).getSemesters(testStudent, true)
doReturn(Completable.complete()).`when`(studentRepository).logoutCurrentStudent()
doReturn(Completable.complete()).`when`(studentRepository).logoutStudent(testStudent)
presenter.onItemSelected(LoginOptionsItem(testStudent))
verify(loginOptionsView).showContent(false)
verify(loginOptionsView).showProgress(true)