For #1019 Update unit tests and UI tests
parent
1d36098878
commit
f18c047132
|
@ -50,6 +50,7 @@ class SearchFragmentStoreTest {
|
|||
query = "",
|
||||
searchEngineSource = mockk(),
|
||||
defaultEngineSource = mockk(),
|
||||
showSearchSuggestionsHint = false,
|
||||
showSearchSuggestions = false,
|
||||
showSearchShortcuts = false,
|
||||
showClipboardSuggestions = false,
|
||||
|
|
|
@ -8,22 +8,33 @@ import android.content.Context
|
|||
import androidx.navigation.NavController
|
||||
import androidx.navigation.NavDestination
|
||||
import androidx.navigation.NavDirections
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import io.mockk.Runs
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
import io.mockk.mockk
|
||||
import io.mockk.verify
|
||||
import io.mockk.mockkObject
|
||||
import mozilla.components.browser.search.SearchEngine
|
||||
import mozilla.components.browser.search.SearchEngineManager
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.support.test.robolectric.testContext
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.FenixApplication
|
||||
import org.mozilla.fenix.TestApplication
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.metrics
|
||||
import org.mozilla.fenix.ext.searchEngineManager
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
import org.mozilla.fenix.whatsnew.clear
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@Config(application = TestApplication::class)
|
||||
class SearchInteractorTest {
|
||||
@Test
|
||||
fun onUrlCommitted() {
|
||||
|
@ -84,11 +95,16 @@ class SearchInteractorTest {
|
|||
@Test
|
||||
fun onTextChanged() {
|
||||
val store: SearchFragmentStore = mockk(relaxed = true)
|
||||
val context: HomeActivity = mockk(relaxed = true)
|
||||
val settings = testContext.settings().apply { testContext.settings().clear() }
|
||||
|
||||
mockkObject(Settings)
|
||||
every { Settings.getInstance(context = context) } returns settings
|
||||
|
||||
every { store.state } returns mockk(relaxed = true)
|
||||
|
||||
val searchController: SearchController = DefaultSearchController(
|
||||
mockk(),
|
||||
context,
|
||||
store,
|
||||
mockk()
|
||||
)
|
||||
|
@ -97,6 +113,7 @@ class SearchInteractorTest {
|
|||
interactor.onTextChanged("test")
|
||||
|
||||
verify { store.dispatch(SearchFragmentAction.UpdateQuery("test")) }
|
||||
verify { store.dispatch(SearchFragmentAction.ShowSearchSuggestionsHint(false)) }
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue