NTP-7179 | Narayan | Added test cases for FAQ view model (#13591)
This commit is contained in:
committed by
GitHub
parent
0732276ef0
commit
ca9cd10092
@@ -7,12 +7,18 @@
|
||||
|
||||
package com.navi.pay.onboarding.faq.viewmodel
|
||||
|
||||
import app.cash.turbine.test
|
||||
import com.navi.pay.common.setup.NaviPayCustomerStatusHandler
|
||||
import com.navi.pay.common.utils.DeviceInfoProvider
|
||||
import com.navi.pay.network.testsetup.NaviPayAndroidTest
|
||||
import com.navi.pay.onboarding.faq.model.view.UpiVideoEntity
|
||||
import dagger.hilt.android.testing.HiltAndroidTest
|
||||
import javax.inject.Inject
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import kotlin.time.Duration.Companion.seconds
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
|
||||
@HiltAndroidTest
|
||||
class NaviPayFaqViewModelTest : NaviPayAndroidTest() {
|
||||
@@ -28,4 +34,51 @@ class NaviPayFaqViewModelTest : NaviPayAndroidTest() {
|
||||
naviPayFaqViewModel =
|
||||
NaviPayFaqViewModel(naviPayCustomerStatusHandler = naviPayCustomerStatusHandler)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_bottom_sheet_visibility() = runTest {
|
||||
naviPayFaqViewModel.isBottomSheetVisible.test(5.seconds) {
|
||||
// Initially bottom sheet should not visible
|
||||
assertEquals(false, awaitItem())
|
||||
|
||||
naviPayFaqViewModel.updateBottomSheetVisibility(isBottomSheetVisible = true)
|
||||
// bottom sheet should be visible after state update
|
||||
assertEquals(true, awaitItem())
|
||||
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun test_ui_options_selected_video() = runTest {
|
||||
naviPayFaqViewModel.uiOptionsSelectedVideo.test(5.seconds) {
|
||||
val initialSelectedVideoEntity =
|
||||
UpiVideoEntity(
|
||||
languageCode = "en",
|
||||
languageName = "English",
|
||||
youtubeVideoId = "X0-QiPD4kqs"
|
||||
)
|
||||
// Initially the default selected video is English
|
||||
assertEquals(initialSelectedVideoEntity, awaitItem())
|
||||
|
||||
naviPayFaqViewModel.updateUiOptionsSelectedVideo(
|
||||
UpiVideoEntity(
|
||||
languageCode = "hi",
|
||||
languageName = "Hindi",
|
||||
youtubeVideoId = "g-Mfbk4j0Y8"
|
||||
)
|
||||
)
|
||||
// After updating the selected video to Hindi, the selected video should be Hindi
|
||||
assertEquals(
|
||||
UpiVideoEntity(
|
||||
languageCode = "hi",
|
||||
languageName = "Hindi",
|
||||
youtubeVideoId = "g-Mfbk4j0Y8"
|
||||
),
|
||||
awaitItem()
|
||||
)
|
||||
|
||||
cancelAndIgnoreRemainingEvents()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user