Skip to content

Commit

Permalink
fix: Discussion Test Cases
Browse files Browse the repository at this point in the history
Fixes: LEARNER-10372
  • Loading branch information
HamzaIsrar12 committed Jan 12, 2025
1 parent 1cb0ef1 commit caa9acc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ class DiscussionCommentsViewModelTest {
@Before
fun setUp() {
Dispatchers.setMain(dispatcher)
every { analytics.logScreenEvent(any(), any()) } returns Unit
every { resourceManager.getString(R.string.core_error_no_connection) } returns noInternet
every { resourceManager.getString(R.string.core_error_unknown_error) } returns somethingWrong
every { resourceManager.getString(org.openedx.discussion.R.string.discussion_comment_added) } returns commentAddedSuccessfully
Expand Down Expand Up @@ -1109,4 +1110,4 @@ class DiscussionCommentsViewModelTest {
assert(viewModel.uiState.value is DiscussionCommentsUIState.Success)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class DiscussionResponsesViewModelTest {
@Before
fun setUp() {
Dispatchers.setMain(dispatcher)
every { analytics.logScreenEvent(any(), any()) } returns Unit
every { resourceManager.getString(R.string.core_error_no_connection) } returns noInternet
every { resourceManager.getString(R.string.core_error_unknown_error) } returns somethingWrong
every { resourceManager.getString(org.openedx.discussion.R.string.discussion_comment_added) } returns commentAddedSuccessfully
Expand Down Expand Up @@ -631,4 +632,4 @@ class DiscussionResponsesViewModelTest {
assert(viewModel.uiState.value is DiscussionResponsesUIState.Success)
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import org.openedx.core.system.ResourceManager
import org.openedx.discussion.domain.interactor.DiscussionInteractor
import org.openedx.discussion.domain.model.DiscussionType
import org.openedx.discussion.domain.model.ThreadsData
import org.openedx.discussion.presentation.DiscussionAnalytics
import org.openedx.discussion.presentation.topics.DiscussionTopicsViewModel
import org.openedx.discussion.system.notifier.DiscussionNotifier
import org.openedx.discussion.system.notifier.DiscussionThreadAdded
Expand All @@ -49,6 +50,7 @@ class DiscussionThreadsViewModelTest {
private val resourceManager = mockk<ResourceManager>()
private val interactor = mockk<DiscussionInteractor>()
private val notifier = mockk<DiscussionNotifier>()
private val analytics = mockk<DiscussionAnalytics>()

private val noInternet = "Slow or no internet connection"
private val somethingWrong = "Something went wrong"
Expand Down Expand Up @@ -128,6 +130,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand All @@ -148,6 +151,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery { interactor.getAllThreads(any(), any(), any(), any()) } throws Exception()
advanceUntilIdle()
Expand Down Expand Up @@ -179,6 +183,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand Down Expand Up @@ -207,6 +212,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand All @@ -227,6 +233,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery {
interactor.getFollowingThreads(
Expand Down Expand Up @@ -282,6 +289,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand Down Expand Up @@ -310,6 +318,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand All @@ -330,6 +339,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery { interactor.getThreads(any(), any(), any(), any(), any()) } throws Exception()
advanceUntilIdle()
Expand Down Expand Up @@ -361,6 +371,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
advanceUntilIdle()

Expand All @@ -380,6 +391,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery { interactor.getThreads(any(), any(), any(), any(), any()) } returns ThreadsData(
threads,
Expand All @@ -400,6 +412,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery { interactor.getThreads(any(), any(), any(), any(), any()) } returns ThreadsData(
threads,
Expand All @@ -420,6 +433,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
coEvery { interactor.getThreads(any(), any(), any(), any(), any()) } returns ThreadsData(
threads,
Expand Down Expand Up @@ -450,6 +464,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)
viewModel.updateThread("")
advanceUntilIdle()
Expand Down Expand Up @@ -486,6 +501,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)


Expand Down Expand Up @@ -525,6 +541,7 @@ class DiscussionThreadsViewModelTest {
interactor,
resourceManager,
notifier,
analytics,
)

val mockLifeCycleOwner: LifecycleOwner = mockk()
Expand All @@ -539,4 +556,4 @@ class DiscussionThreadsViewModelTest {
}


}
}

0 comments on commit caa9acc

Please sign in to comment.