Skip to content

Commit

Permalink
Fix unit tests compile issues after dao refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
JorgeMucientes committed Sep 19, 2024
1 parent e056e69 commit 3b8d4ec
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import org.wordpress.android.fluxc.network.rest.wpcom.blaze.BlazeCreationRestCli
import org.wordpress.android.fluxc.network.rest.wpcom.blaze.CampaignImage
import org.wordpress.android.fluxc.persistence.blaze.BlazeCampaignsDao
import org.wordpress.android.fluxc.persistence.blaze.BlazeCampaignsDao.BlazeCampaignEntity
import org.wordpress.android.fluxc.persistence.blaze.BlazeCampaignsDao.BlazeCampaignObjectiveEntity
import org.wordpress.android.fluxc.persistence.blaze.BlazeObjectivesDao
import org.wordpress.android.fluxc.persistence.blaze.BlazeObjectivesDao.BlazeCampaignObjectiveEntity
import org.wordpress.android.fluxc.persistence.blaze.BlazeTargetingDao
import org.wordpress.android.fluxc.persistence.blaze.BlazeTargetingDeviceEntity
import org.wordpress.android.fluxc.persistence.blaze.BlazeTargetingLanguageEntity
Expand Down Expand Up @@ -123,6 +124,7 @@ class BlazeCampaignsStoreTest {
private val creationRestClient: BlazeCreationRestClient = mock()
private val blazeCampaignsDao: BlazeCampaignsDao = mock()
private val blazeTargetingDao: BlazeTargetingDao = mock()
private val blazeObjectivesDao: BlazeObjectivesDao = mock()
private val siteModel = SiteModel().apply { siteId = SITE_ID }

private lateinit var store: BlazeCampaignsStore
Expand All @@ -137,7 +139,8 @@ class BlazeCampaignsStoreTest {
creationRestClient = creationRestClient,
campaignsDao = blazeCampaignsDao,
targetingDao = blazeTargetingDao,
coroutineEngine = initCoroutineEngine()
coroutineEngine = initCoroutineEngine(),
blazeObjectivesDao = blazeObjectivesDao
)
}

Expand Down Expand Up @@ -224,26 +227,28 @@ class BlazeCampaignsStoreTest {
BlazeCampaignObjective(
id = it.toString(),
title = "Title $it",
description = "Description $it"
description = "Description $it",
suitableForDescription = "Suitable for description $it"
)
}
)
)

store.fetchBlazeCampaignObjectives(siteModel)

verify(blazeCampaignsDao).replaceObjectives(any())
verify(blazeObjectivesDao).replaceObjectives(any())
}

@Test
fun `when observing campaign objectives, then return data from DB`() = test {
whenever(blazeCampaignsDao.observeObjectives(any())).thenReturn(
whenever(blazeObjectivesDao.observeObjectives(any())).thenReturn(
flowOf(
List(4) {
BlazeCampaignObjectiveEntity(
id = it.toString(),
title = "Title $it",
description = "Description $it",
suitableForDescription = "Suitable for description $it",
locale = "en"
)
}
Expand Down

0 comments on commit 3b8d4ec

Please sign in to comment.