Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Rawa committed Dec 20, 2024
1 parent b9b7ed2 commit 405dd61
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import io.mockk.verify
import net.mullvad.mullvadvpn.compose.createEdgeToEdgeComposeExtension
import net.mullvad.mullvadvpn.compose.setContentWithTheme
import net.mullvad.mullvadvpn.compose.state.RelayFilterUiState
import net.mullvad.mullvadvpn.lib.model.Constraint
import net.mullvad.mullvadvpn.lib.model.Ownership
import net.mullvad.mullvadvpn.lib.model.ProviderId
import org.junit.jupiter.api.Test
Expand All @@ -27,7 +28,7 @@ class FilterScreenTest {
state: RelayFilterUiState = RelayFilterUiState(),
onBackClick: () -> Unit = {},
onApplyClick: () -> Unit = {},
onSelectedOwnership: (ownership: Ownership?) -> Unit = {},
onSelectedOwnership: (ownership: Constraint<Ownership>) -> Unit = {},
onAllProviderCheckChange: (isChecked: Boolean) -> Unit = {},
onSelectedProvider: (checked: Boolean, provider: ProviderId) -> Unit = { _, _ -> },
) {
Expand All @@ -50,8 +51,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = null,
selectedProviders = DUMMY_SELECTED_PROVIDERS,
selectedOwnership = Constraint.Any,
selectedProviders = Constraint.Only(DUMMY_SELECTED_PROVIDERS),
)
)
onNodeWithText("Ownership").assertExists()
Expand All @@ -65,8 +66,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = null,
selectedProviders = DUMMY_SELECTED_PROVIDERS,
selectedOwnership = Constraint.Any,
selectedProviders = Constraint.Only(DUMMY_SELECTED_PROVIDERS),
)
)
onNodeWithText("Ownership").performClick()
Expand All @@ -80,8 +81,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = Ownership.MullvadOwned,
selectedProviders = DUMMY_SELECTED_PROVIDERS,
selectedOwnership = Constraint.Only(Ownership.MullvadOwned),
selectedProviders = Constraint.Only(DUMMY_SELECTED_PROVIDERS),
)
)
onNodeWithText("Ownership").performClick()
Expand All @@ -95,8 +96,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = Ownership.Rented,
selectedProviders = DUMMY_SELECTED_PROVIDERS,
selectedOwnership = Constraint.Only(Ownership.Rented),
selectedProviders = Constraint.Only(DUMMY_SELECTED_PROVIDERS),
)
)
onNodeWithText("Ownership").performClick()
Expand All @@ -110,8 +111,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = null,
selectedProviders = DUMMY_SELECTED_PROVIDERS,
selectedOwnership = Constraint.Any,
selectedProviders = Constraint.Only(DUMMY_SELECTED_PROVIDERS),
)
)

Expand All @@ -128,8 +129,8 @@ class FilterScreenTest {
state =
RelayFilterUiState(
providerToOwnerships = DUMMY_RELAY_ALL_PROVIDERS,
selectedOwnership = null,
selectedProviders = listOf(ProviderId("31173")),
selectedOwnership = Constraint.Any,
selectedProviders = Constraint.Only(listOf(ProviderId("31173"))),
),
onApplyClick = mockClickListener,
)
Expand Down Expand Up @@ -159,6 +160,6 @@ class FilterScreenTest {
ProviderId("xtom") to setOf(Ownership.Rented),
)

private val DUMMY_SELECTED_PROVIDERS = DUMMY_RELAY_ALL_PROVIDERS.keys.toList()
private val DUMMY_SELECTED_PROVIDERS = DUMMY_RELAY_ALL_PROVIDERS.keys.toList().dropLast(3)
}
}

0 comments on commit 405dd61

Please sign in to comment.