Skip to content

Commit

Permalink
Add observeBlazeCampaignObjectives() to BlazeCampaignsStore
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Sep 14, 2024
1 parent b931b7b commit 826c064
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,27 @@ class BlazeCampaignsStoreTest {
verify(blazeCampaignsDao).replaceObjectives(any())
}

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

val objectives = store.observeBlazeCampaignObjectives().first()

assertThat(objectives).isNotNull
assertThat(objectives.size).isEqualTo(4)
}

@Test
fun `when fetching targeting locations, then locations are returned`() = test {
whenever(creationRestClient.fetchTargetingLocations(any(), any(), any())).thenReturn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ class BlazeCampaignsStore @Inject constructor(
}
}

fun observeBlazeCampaignObjectives(
locale: String = Locale.getDefault().language
) = campaignsDao.observeObjectives(locale).map { objectives -> objectives.map { it.toDomainModel() } }

suspend fun fetchBlazeTargetingLocations(
site: SiteModel,
query: String,
Expand Down

0 comments on commit 826c064

Please sign in to comment.