You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.8 KiB
Kotlin
69 lines
1.8 KiB
Kotlin
5 years ago
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
|
||
5 years ago
|
package org.mozilla.fenix.settings.account
|
||
5 years ago
|
|
||
|
import androidx.navigation.NavController
|
||
|
import androidx.navigation.NavDestination
|
||
|
import io.mockk.every
|
||
|
import io.mockk.mockk
|
||
|
import io.mockk.verify
|
||
|
import org.junit.Assert.assertEquals
|
||
|
import org.junit.Test
|
||
|
import org.mozilla.fenix.R
|
||
|
|
||
|
class AccountSettingsInteractorTest {
|
||
|
|
||
|
@Test
|
||
|
fun onSyncNow() {
|
||
|
var ranSyncNow = false
|
||
|
|
||
|
val interactor = AccountSettingsInteractor(
|
||
|
mockk(),
|
||
|
{ ranSyncNow = true },
|
||
|
mockk(),
|
||
|
mockk()
|
||
|
)
|
||
|
|
||
|
interactor.onSyncNow()
|
||
|
|
||
|
assertEquals(ranSyncNow, true)
|
||
|
}
|
||
|
|
||
|
@Test
|
||
|
fun onChangeDeviceName() {
|
||
5 years ago
|
val store: AccountSettingsFragmentStore = mockk(relaxed = true)
|
||
5 years ago
|
|
||
|
val interactor = AccountSettingsInteractor(
|
||
|
mockk(),
|
||
|
mockk(),
|
||
|
{ true },
|
||
|
store
|
||
|
)
|
||
|
|
||
5 years ago
|
interactor.onChangeDeviceName("New Name") {}
|
||
5 years ago
|
|
||
5 years ago
|
verify { store.dispatch(AccountSettingsFragmentAction.UpdateDeviceName("New Name")) }
|
||
5 years ago
|
}
|
||
|
|
||
|
@Test
|
||
|
fun onSignOut() {
|
||
|
val navController: NavController = mockk(relaxed = true)
|
||
|
every { navController.currentDestination } returns NavDestination("").apply { id = R.id.accountSettingsFragment }
|
||
|
|
||
|
val interactor = AccountSettingsInteractor(
|
||
|
navController,
|
||
|
mockk(),
|
||
|
mockk(),
|
||
|
mockk()
|
||
|
)
|
||
|
|
||
|
interactor.onSignOut()
|
||
|
|
||
|
verify {
|
||
|
navController.navigate(AccountSettingsFragmentDirections.actionAccountSettingsFragmentToSignOutFragment())
|
||
|
}
|
||
|
}
|
||
|
}
|