Created
May 8, 2024 16:08
-
-
Save MkhytarMkhoian/d75dc30f3d77e6466fd6a6ab8396896c 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
class GetCategoriesFromIdsUseCaseTest { | |
private val categoriesRepository: CategoriesRepository = mockk(relaxed = true) | |
private val getCategoriesFromIdsUseCase = GetCategoriesFromIdsUseCase( | |
categoriesRepository = categoriesRepository | |
) | |
@Test | |
fun `On invoke should return correct list of categories`() = runTest { | |
// Given | |
val child1CategoryId = Category.CATEGORY_PRO | |
val child1: Category = mockk { | |
every { categoryId } returns child1CategoryId | |
} | |
val child2CategoryId = CategoryId(id = -faker.number().randomNumber()) | |
val child2: Category = mockk { | |
every { categoryId } returns child2CategoryId | |
} | |
val categoryTreeIds: List<CategoryId> = listOf( | |
child1CategoryId, | |
child2CategoryId, | |
) | |
val map = mapOf( | |
child1CategoryId to child1, | |
child2CategoryId to child2, | |
) | |
coEvery { categoriesRepository.getCategories() } returns map | |
// When | |
val result = getCategoriesFromIdsUseCase(categoryTreeIds) | |
// Then | |
assertContains(result, child1) | |
assertContains(result, child2) | |
coVerify { categoriesRepository.getCategories() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment