From b0e121263e83a31197ad0729cbddbc9460b4803d Mon Sep 17 00:00:00 2001 From: Jaehwa Noh Date: Thu, 22 Feb 2024 11:07:24 +0900 Subject: [PATCH] Create stateIsEmptyQuery_withThreeWhiteSpacesSearchQuery test. Change-Id: I6d6e8f9fe988ca83fae484e4f2338ad6fe58b676 --- .../feature/search/SearchViewModelTest.kt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt index 2aeb82123..607391c77 100644 --- a/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt +++ b/feature/search/src/test/kotlin/com/google/samples/apps/nowinandroid/feature/search/SearchViewModelTest.kt @@ -141,4 +141,17 @@ class SearchViewModelTest { assertNull(recentSearchQuery) } + + @Test + fun stateIsEmptyQuery_withThreeWhiteSpacesSearchQuery() = runTest { + searchContentsRepository.addNewsResources(newsResourcesTestData) + searchContentsRepository.addTopics(topicsTestData) + val collectJob = launch(UnconfinedTestDispatcher()) { viewModel.searchResultUiState.collect() } + + viewModel.onSearchQueryChanged(" ") + + assertIs(viewModel.searchResultUiState.value) + + collectJob.cancel() + } }