Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Horta committed May 20, 2024
1 parent b150ba3 commit 12e9ef7
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ class SubFilterViewModelTest : BaseUnitTest() {

@Test
fun `view model updates the tags and sites and asks to show the bottom sheet when filters button is tapped`() {
mockReaderTableEmpty()

var updateTasks: EnumSet<UpdateTask>? = null

viewModel.updateTagsAndSites.observeForever { updateTasks = it.peekContent() }
Expand All @@ -318,6 +320,8 @@ class SubFilterViewModelTest : BaseUnitTest() {

@Test
fun `view model asks to show the bottom sheet when filters button is tapped`() {
mockReaderTableEmpty()

var uiState: BottomSheetUiState? = null

viewModel.bottomSheetUiState.observeForever { uiState = it.peekContent() }
Expand Down Expand Up @@ -539,4 +543,11 @@ class SubFilterViewModelTest : BaseUnitTest() {
assertThat(viewModel.isTitleContainerVisible.getOrAwaitValue()).isEqualTo(isTitleContainerVisible)
}
}

private fun mockReaderTableEmpty() {
whenever(initialTag.organization).thenReturn(Organization.NO_ORGANIZATION)
whenever(accountStore.hasAccessToken()).thenReturn(true)
whenever(readerTagTableWrapper.getFollowedTags()).thenReturn(ReaderTagList())
whenever(readerBlogTableWrapper.getFollowedBlogs()).thenReturn(emptyList())
}
}

0 comments on commit 12e9ef7

Please sign in to comment.