Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Co-Authored-By: Boban Sijuk <[email protected]>
  • Loading branch information
MaryamShaghaghi and Boki91 committed Nov 23, 2023
1 parent 99ad505 commit 5c78bdd
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class FilterScreenTest {
RelayFilterState(
allProviders = listOf(),
selectedOwnership = null,
selectedProviders = listOf( Provider("31173", true)),
selectedProviders = listOf(Provider("31173", true)),
),
uiCloseAction = MutableSharedFlow(),
onSelectedProviders = { _, _ -> },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SelectLocationScreenTest {
SelectLocationScreen(
uiState = SelectLocationUiState.Loading,
uiCloseAction = MutableSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow()
)
}

Expand All @@ -59,10 +59,10 @@ class SelectLocationScreenTest {
selectedRelay = null,
selectedOwnership = null,
selectedProvidersCount = 0,
searchTerm = "",
searchTerm = ""
),
uiCloseAction = MutableSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow()
)
}

Expand Down Expand Up @@ -99,10 +99,10 @@ class SelectLocationScreenTest {
selectedRelay = updatedDummyList[0].cities[0].relays[0],
selectedOwnership = null,
selectedProvidersCount = 0,
searchTerm = "",
searchTerm = ""
),
uiCloseAction = MutableSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow()
)
}

Expand All @@ -129,11 +129,11 @@ class SelectLocationScreenTest {
selectedRelay = null,
selectedOwnership = null,
selectedProvidersCount = 0,
searchTerm = "",
searchTerm = ""
),
uiCloseAction = MutableSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow(),
onSearchTermInput = mockedSearchTermInput,
onSearchTermInput = mockedSearchTermInput
)
}
val mockSearchString = "SEARCH"
Expand All @@ -158,11 +158,11 @@ class SelectLocationScreenTest {
selectedRelay = null,
selectedOwnership = null,
selectedProvidersCount = 0,
searchTerm = mockSearchString,
searchTerm = mockSearchString
),
uiCloseAction = MutableSharedFlow(),
enterTransitionEndAction = MutableSharedFlow<Unit>().asSharedFlow(),
onSearchTermInput = mockedSearchTermInput,
onSearchTermInput = mockedSearchTermInput
)
}

Expand All @@ -180,15 +180,15 @@ class SelectLocationScreenTest {
active = true,
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
owned = true,
provider = "PROVIDER",
provider = "PROVIDER"
)
private val DUMMY_RELAY_2 =
net.mullvad.mullvadvpn.model.Relay(
hostname = "Relay host 2",
active = true,
endpointData = RelayEndpointData.Wireguard(WireguardRelayEndpointData),
owned = true,
provider = "PROVIDER",
provider = "PROVIDER"
)
private val DUMMY_RELAY_CITY_1 =
RelayListCity("Relay City 1", "RCi1", arrayListOf(DUMMY_RELAY_1))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ open class MainActivity : FragmentActivity() {
R.anim.do_nothing,
R.anim.fragment_exit_to_right
)
replace(R.id.select_location_fragment, FilterFragment())
replace(R.id.main_fragment, FilterFragment())
addToBackStack(null)
commitAllowingStateLoss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import io.mockk.mockk
import io.mockk.mockkStatic
import io.mockk.unmockkAll
import io.mockk.verify
import kotlin.test.assertEquals
import kotlin.test.assertIs
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.runTest
Expand All @@ -31,8 +33,6 @@ import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import kotlin.test.assertEquals
import kotlin.test.assertIs

class SelectLocationViewModelTest {
@get:Rule val testCoroutineRule = TestCoroutineRule()
Expand All @@ -50,8 +50,8 @@ class SelectLocationViewModelTest {
fun setup() {

every { mockRelayListFilterUseCase.selectedOwnership() } returns selectedOwnership
every { mockRelayListFilterUseCase.selectedProviders()} returns selectedProvider
every { mockRelayListFilterUseCase.availableProviders() } returns allProvider
every { mockRelayListFilterUseCase.selectedProviders() } returns selectedProvider
every { mockRelayListFilterUseCase.availableProviders() } returns allProvider
every { mockRelayListUseCase.relayListWithSelection() } returns relayListWithSelectionFlow

mockkStatic(SERVICE_CONNECTION_MANAGER_EXTENSIONS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import io.mockk.coVerify
import io.mockk.every
import io.mockk.mockk
import io.mockk.unmockkAll
import kotlin.test.assertEquals
import kotlinx.coroutines.cancel
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.flowOf
Expand All @@ -23,7 +24,6 @@ import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import kotlin.test.assertEquals

class FilterViewModelTest {
@get:Rule val testCoroutineRule = TestCoroutineRule()
Expand Down Expand Up @@ -79,7 +79,7 @@ class FilterViewModelTest {
val mockOwnership = Ownership.Rented
// Assert
viewModel.uiState.test {
assertEquals(awaitItem().selectedOwnership , Ownership.MullvadOwned)
assertEquals(awaitItem().selectedOwnership, Ownership.MullvadOwned)
viewModel.setSelectedOwnership(mockOwnership)
assertEquals(mockOwnership, awaitItem().selectedOwnership)
}
Expand Down

0 comments on commit 5c78bdd

Please sign in to comment.