Skip to content

Commit 0c76106

Browse files
committed
Fix test
1 parent 7456d9b commit 0c76106

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

android/app/src/test/kotlin/net/mullvad/mullvadvpn/viewmodel/SelectLocationViewModelTest.kt

+9-8
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import net.mullvad.mullvadvpn.lib.model.Providers
3232
import net.mullvad.mullvadvpn.lib.model.RelayItem
3333
import net.mullvad.mullvadvpn.lib.model.RelayItemId
3434
import net.mullvad.mullvadvpn.relaylist.descendants
35-
import net.mullvad.mullvadvpn.relaylist.filterOnSearchTerm
3635
import net.mullvad.mullvadvpn.repository.CustomListsRepository
3736
import net.mullvad.mullvadvpn.repository.RelayListFilterRepository
3837
import net.mullvad.mullvadvpn.repository.RelayListRepository
@@ -170,11 +169,7 @@ class SelectLocationViewModelTest {
170169
@Test
171170
fun `on onSearchTermInput call uiState should emit with filtered countries`() = runTest {
172171
// Arrange
173-
val mockCountries = listOf<RelayItem.Location.Country>(mockk(), mockk())
174-
val selectedItem: RelayItemId? = null
175-
val mockRelayList: List<RelayItem.Location.Country> = mockk(relaxed = true)
176172
val mockSearchString = "got"
177-
every { mockCustomList.filterOnSearchTerm(mockSearchString) } returns mockCustomList
178173
filteredRelayList.value = testCountries
179174
selectedRelayItemFlow.value = Constraint.Any
180175

@@ -186,11 +181,17 @@ class SelectLocationViewModelTest {
186181
// Update search string
187182
viewModel.onSearchTermInput(mockSearchString)
188183

189-
// Assert
184+
// We get some unnecessary emissions for now
185+
awaitItem()
186+
awaitItem()
187+
awaitItem()
188+
190189
val actualState = awaitItem()
191190
assertIs<SelectLocationUiState.Content>(actualState)
192-
// assertLists(mockCountries, actualState.countries)
193-
// assertEquals(selectedItem, actualState.selectedItem)
191+
assertTrue(
192+
actualState.relayListItems.filterIsInstance<RelayListItem.GeoLocationItem>().any {
193+
it.item is RelayItem.Location.City && it.item.name == "Gothenburg"
194+
})
194195
}
195196
}
196197

0 commit comments

Comments
 (0)