Skip to content

Instantly share code, notes, and snippets.

@MkhytarMkhoian
Last active May 8, 2024 13:18
Show Gist options
  • Save MkhytarMkhoian/658b716f0d4ccb124be40362aa75a552 to your computer and use it in GitHub Desktop.
Save MkhytarMkhoian/658b716f0d4ccb124be40362aa75a552 to your computer and use it in GitHub Desktop.
class CategoriesDataRepositoryTest {
private val apiManager: APIManager = mockk(relaxed = true)
private val categoriesInMemoryDataSource: CategoriesInMemoryDataSource = mockk(relaxed = true)
private val categoriesLocalDataSource: CategoriesLocalDataSource = mockk(relaxed = true)
private val categoriesDataRepository = CategoriesDataRepository(
apiManager = apiManager,
categoriesInMemoryDataSource = categoriesInMemoryDataSource,
categoriesLocalDataSource = categoriesLocalDataSource,
)
@Test
fun `On get new root instance should return correct result`() = runTest {
// Given
val categoryName = faker.name().name()
val children: List<Category> = listOf(
randomCategory(),
randomCategory(),
randomCategory()
)
// When
val result = categoriesDataRepository.getNewRootInstance(
name = categoryName,
children = children
)
// Then
assertEquals(Category.ROOT, result.categoryId)
assertEquals(categoryName, result.name)
assertEquals(children.size, result.adsCount)
assertTrue { result.searchNames.isEmpty() }
assertNull(result.image)
assertNull(result.iconImage)
assertEquals(Category.PostingType.DEFAULT, result.postingType)
assertEquals(Category.FeedType.DEFAULT, result.feedType)
assertEquals(Category.PanelType.CATEGORY, result.panelType)
assertFalse(result.categoryId.isDuplicate)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment