Update recipe repo
This commit is contained in:
@@ -46,28 +46,18 @@ class RecipeRepoTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when loadRecipeInfo expect return value from data source`() = runTest {
|
fun `when loadRecipeInfo expect return value from data source`() = runTest {
|
||||||
coEvery { dataSource.requestRecipeInfo(eq("cake")) } returns CAKE_FULL_RECIPE_INFO
|
|
||||||
coEvery { storage.queryRecipeInfo(eq("1")) } returns FULL_CAKE_INFO_ENTITY
|
coEvery { storage.queryRecipeInfo(eq("1")) } returns FULL_CAKE_INFO_ENTITY
|
||||||
val actual = subject.loadRecipeInfo("1", "cake")
|
val actual = subject.loadRecipeInfo("1")
|
||||||
assertThat(actual).isEqualTo(FULL_CAKE_INFO_ENTITY)
|
assertThat(actual).isEqualTo(FULL_CAKE_INFO_ENTITY)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when loadRecipeInfo expect call to storage`() = runTest {
|
fun `when refreshRecipeInfo expect call to storage`() = runTest {
|
||||||
coEvery { dataSource.requestRecipeInfo(eq("cake")) } returns CAKE_FULL_RECIPE_INFO
|
coEvery { dataSource.requestRecipeInfo(eq("cake")) } returns CAKE_FULL_RECIPE_INFO
|
||||||
coEvery { storage.queryRecipeInfo(eq("1")) } returns FULL_CAKE_INFO_ENTITY
|
subject.refreshRecipeInfo("cake")
|
||||||
subject.loadRecipeInfo("1", "cake")
|
|
||||||
coVerify { storage.saveRecipeInfo(eq(CAKE_FULL_RECIPE_INFO)) }
|
coVerify { storage.saveRecipeInfo(eq(CAKE_FULL_RECIPE_INFO)) }
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `when data source fails expect loadRecipeInfo return value from storage`() = runTest {
|
|
||||||
coEvery { dataSource.requestRecipeInfo(eq("cake")) } throws RuntimeException()
|
|
||||||
coEvery { storage.queryRecipeInfo(eq("1")) } returns FULL_CAKE_INFO_ENTITY
|
|
||||||
val actual = subject.loadRecipeInfo("1", "cake")
|
|
||||||
assertThat(actual).isEqualTo(FULL_CAKE_INFO_ENTITY)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `when clearLocalData expect call to storage`() = runTest {
|
fun `when clearLocalData expect call to storage`() = runTest {
|
||||||
subject.clearLocalData()
|
subject.clearLocalData()
|
||||||
|
|||||||
Reference in New Issue
Block a user