Skip to content

Commit

Permalink
[Jetcaster] Add tests for category filter limit
Browse files Browse the repository at this point in the history
  • Loading branch information
yongsuk44 committed Apr 19, 2024
1 parent 78f5df9 commit 49dcaad
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,24 @@ class PodcastCategoryFilterUseCaseTest {
result.episodes
)
}

@Test
fun whenCategoryInfoNotNull_verifyLimitFlow() = runTest {
val resultFlow = useCase(testCategory.asExternalModel())

categoriesStore.setEpisodesFromPodcast(
testCategory.id,
List(8) { testEpisodeToPodcast }.flatten()
)
categoriesStore.setPodcastsInCategory(
testCategory.id,
List(4) { testPodcasts }.flatten()
)

val result = resultFlow.first()
assertEquals(20, result.episodes.size)
assertEquals(10, result.topPodcasts.size)
}
}

val testPodcasts = listOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class TestCategoryStore : CategoryStore {
categoryId: Long,
limit: Int
): Flow<List<PodcastWithExtraInfo>> = podcastsInCategoryFlow.map {
it[categoryId] ?: emptyList()
it[categoryId]?.take(limit) ?: emptyList()
}

override fun episodesFromPodcastsInCategory(
categoryId: Long,
limit: Int
): Flow<List<EpisodeToPodcast>> = episodesFromPodcasts.map {
it[categoryId] ?: emptyList()
it[categoryId]?.take(limit) ?: emptyList()
}

override suspend fun addCategory(category: Category): Long = -1
Expand Down

0 comments on commit 49dcaad

Please sign in to comment.