Skip to content

Commit

Permalink
Add tests for always showing selected providers
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Dec 20, 2024
1 parent 39388cf commit 5955a08
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,25 @@ class FilterScreenTest {
verify { mockClickListener() }
}

@Test
fun ensureSelectedProviderIsShowEvenThoughItIsNotInAllProviders() =
composeExtension.use {
// Arrange
initScreen(
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = null,
selectedProviders = listOf(ProviderId("1RemovedProvider")),
)
)

// Act
onNodeWithText("Providers").performClick()
// Asset
onNodeWithText("1RemovedProvider (removed)").assertExists()
}

companion object {
private val DUMMY_RELAY_ALL_PROVIDERS =
mapOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,4 +184,27 @@ class FilterChipUseCaseTest {

filterChipUseCase(RelayListType.EXIT).test { assertLists(emptyList(), awaitItem()) }
}

@Test
fun `ensure that a selected provider that is not in the provider list is still counted`() =
runTest {
// Arrange
val expectedProviders = Providers(providers = setOf(ProviderId("1")))
val expectedOwnership = Ownership.MullvadOwned
selectedProviders.value = Constraint.Only(expectedProviders)
selectedOwnership.value = Constraint.Only(expectedOwnership)
providerToOwnerships.value =
mapOf(
ProviderId("2") to setOf(Ownership.MullvadOwned),
ProviderId("3") to setOf(Ownership.Rented),
)

// Act, Assert
filterChipUseCase(RelayListType.EXIT).test {
assertLists(
listOf(FilterChip.Ownership(expectedOwnership), FilterChip.Provider(1)),
awaitItem(),
)
}
}
}

0 comments on commit 5955a08

Please sign in to comment.