public MockitoRule mockito = MockitoJUnit.rule();
@Mock
MainView viewMock;
@Mock
MainUseCase useCaseMock;
@Spy
@InjectMocks
MainPresenter presenter;
@Test
public void onCreateTest() {
when(useCaseMock.loadButtonText()).thenReturn(Single.just("test"));
presenter.onCreate();
verify(useCaseMock, times(1)).loadButtonText();
verify(viewMock, times(2)).showButton();
verify(viewMock, times(1)).setButtonText("test");
}
@Test
public void buttonTextEmptyTest() {
when(useCaseMock.loadButtonText()).thenReturn(Single.just(""));
presenter.onCreate();
verify(useCaseMock, times(1)).loadButtonText();
verify(viewMock, times(1)).showButton();
verify(viewMock, times(1)).hideButton();
verify(viewMock, never()).setButtonText(anyString());
}
@Test
public void onButtonClickTest() {
when(useCaseMock.loadButtonText()).thenReturn(Single.just("test"));
presenter.onCreate();
presenter.onButtonClick();
verify(viewMock, times(1)).startSubActivity();
}
}