Skip to content

Commit

Permalink
fix: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gongracr committed Sep 22, 2023
1 parent 697fb8f commit fc22205
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ class ConversationRepositoryTest {
// given
val conversationIdEntity = ConversationIDEntity("some_value", "some_domain")
val conversationId = QualifiedID("some_value", "some_domain")
val shouldFetchArchivedConversations = false

val conversationEntity = TestConversation.VIEW_ENTITY.copy(
id = conversationIdEntity,
Expand All @@ -686,7 +687,7 @@ class ConversationRepositoryTest {
.arrange()

// when
conversationRepository.observeConversationListDetails().test {
conversationRepository.observeConversationListDetails(shouldFetchArchivedConversations).test {
val result = awaitItem()

assertContains(result.map { it.conversation.id }, conversationId)
Expand Down Expand Up @@ -751,6 +752,7 @@ class ConversationRepositoryTest {
// given
val conversationIdEntity = ConversationIDEntity("some_value", "some_domain")
val conversationId = QualifiedID("some_value", "some_domain")
val shouldFetchArchivedConversations = false

val conversationEntity = TestConversation.VIEW_ENTITY.copy(
id = conversationIdEntity, type = ConversationEntity.Type.ONE_ON_ONE,
Expand All @@ -770,7 +772,7 @@ class ConversationRepositoryTest {
.arrange()

// when
conversationRepository.observeConversationListDetails().test {
conversationRepository.observeConversationListDetails(shouldFetchArchivedConversations).test {
val result = awaitItem()

assertContains(result.map { it.conversation.id }, conversationId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class ObserveConversationListDetailsUseCaseTest {
val selfConversation = TestConversation.SELF()
val conversations = listOf(selfConversation, groupConversation)
val selfConversationDetails = ConversationDetails.Self(selfConversation)
val fetchArchivedConversations = false
val groupConversationDetails =
ConversationDetails.Group(
groupConversation,
Expand All @@ -77,7 +78,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When
observeConversationsUseCase().collect()
observeConversationsUseCase(fetchArchivedConversations).collect()

// Then
with(arrangement) {
Expand All @@ -93,6 +94,7 @@ class ObserveConversationListDetailsUseCaseTest {
val selfConversation = TestConversation.SELF()
val groupConversation = TestConversation.GROUP()
val conversations = listOf(selfConversation, groupConversation)
val fetchArchivedConversations = false

val selfConversationDetails = ConversationDetails.Self(selfConversation)
val groupConversationDetails = ConversationDetails.Group(
Expand All @@ -112,7 +114,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When
observeConversationsUseCase().collect()
observeConversationsUseCase(fetchArchivedConversations).collect()

with(arrangement) {
conversations.forEach { conversation ->
Expand All @@ -130,6 +132,7 @@ class ObserveConversationListDetailsUseCaseTest {
val oneOnOneConversation = TestConversation.ONE_ON_ONE
val groupConversation = TestConversation.GROUP()
val conversations = listOf(groupConversation, oneOnOneConversation)
val fetchArchivedConversations = false

val groupConversationUpdates = listOf(
ConversationDetails.Group(
Expand Down Expand Up @@ -169,7 +172,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When, Then
observeConversationsUseCase().test {
observeConversationsUseCase(fetchArchivedConversations).test {
oneOnOneDetailsChannel.send(firstOneOnOneDetails)

val conversationList = awaitItem()
Expand All @@ -188,6 +191,7 @@ class ObserveConversationListDetailsUseCaseTest {
fun givenAConversationIsAddedToTheList_whenObservingDetailsList_thenTheUpdateIsPropagatedThroughTheFlow() = runTest {
// Given
val groupConversation = TestConversation.GROUP()
val fetchArchivedConversations = false
val groupConversationDetails = ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
Expand All @@ -212,7 +216,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When, Then
observeConversationsUseCase().test {
observeConversationsUseCase(fetchArchivedConversations).test {
assertContentEquals(listOf(groupConversationDetails), awaitItem())

conversationListUpdates.close()
Expand All @@ -225,6 +229,7 @@ class ObserveConversationListDetailsUseCaseTest {
fun givenAnOngoingCall_whenFetchingConversationDetails_thenTheConversationShouldHaveAnOngoingCall() = runTest {
// Given
val groupConversation = TestConversation.GROUP()
val fetchArchivedConversations = false
val groupConversationDetails = ConversationDetails.Group(
groupConversation,
LegalHoldStatus.DISABLED,
Expand All @@ -246,7 +251,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When, Then
observeConversationsUseCase().test {
observeConversationsUseCase(fetchArchivedConversations).test {
assertEquals(true, (awaitItem()[0] as ConversationDetails.Group).hasOngoingCall)
}
}
Expand All @@ -255,6 +260,7 @@ class ObserveConversationListDetailsUseCaseTest {
fun givenAConversationWithoutAnOngoingCall_whenFetchingConversationDetails_thenTheConversationShouldNotHaveAnOngoingCall() = runTest {
// Given
val groupConversation = TestConversation.GROUP()
val fetchArchivedConversations = false

val groupConversationDetails = ConversationDetails.Group(
groupConversation,
Expand All @@ -277,7 +283,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When, Then
observeConversationsUseCase().test {
observeConversationsUseCase(fetchArchivedConversations).test {
assertEquals(false, (awaitItem()[0] as ConversationDetails.Group).hasOngoingCall)
}
}
Expand All @@ -289,6 +295,7 @@ class ObserveConversationListDetailsUseCaseTest {
val successConversation = TestConversation.ONE_ON_ONE.copy(id = ConversationId("successId", "domain"))
val successConversationDetails = TestConversationDetails.CONVERSATION_ONE_ONE.copy(conversation = successConversation)
val failureConversation = TestConversation.ONE_ON_ONE.copy(id = ConversationId("failedId", "domain"))
val fetchArchivedConversations = false

val (_, observeConversationsUseCase) = Arrangement()
.withConversationsList(listOf(successConversation, failureConversation))
Expand All @@ -297,7 +304,7 @@ class ObserveConversationListDetailsUseCaseTest {
.arrange()

// When, Then
observeConversationsUseCase().test {
observeConversationsUseCase(fetchArchivedConversations).test {
assertEquals(awaitItem(), listOf(successConversationDetails))
awaitComplete()
}
Expand Down

0 comments on commit fc22205

Please sign in to comment.