Create test emptySearchText_NotAddToRecentSearches

- For empty query not add in recent query list.
pull/1223/head
Jaehwa Noh 2 years ago
parent 97686cbd8f
commit aa42b488a2

@ -33,6 +33,7 @@ import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.E
import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.Loading
import com.google.samples.apps.nowinandroid.feature.search.SearchResultUiState.SearchNotReady
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.runTest
@ -128,4 +129,15 @@ class SearchViewModelTest {
collectJob.cancel()
}
@Test
fun emptySearchText_NotAddToRecentSearches() = runTest {
viewModel.onSearchTriggered("")
val recentSearchQueriesStream = getRecentQueryUseCase()
val recentSearchQueries = recentSearchQueriesStream.first()
val recentSearchQuery = recentSearchQueries.firstOrNull()
assertEquals(null, recentSearchQuery)
}
}

Loading…
Cancel
Save