add error test case for contacts fetch

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-07-23 16:36:42 +02:00 committed by Marcel Hibbe
parent 62b2ecd338
commit 8d52a6fcc9
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
6 changed files with 27 additions and 22 deletions

View File

@ -325,8 +325,6 @@ fun ConversationCreationOptions(context: Context) {
}
}
class CompanionClass {
companion object {
internal val TAG = ContactsActivityCompose::class.simpleName

View File

@ -61,25 +61,24 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
}
},
trailingIcon = {
if (text.isNotEmpty()) {
IconButton(
onClick = {
onTextChange("")
}
) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = stringResource(R.string.close_icon),
//tint = MaterialTheme.colorScheme.onSurface
)
trailingIcon = {
if (text.isNotEmpty()) {
IconButton(
onClick = {
onTextChange("")
}
) {
Icon(
imageVector = Icons.Default.Close,
contentDescription = stringResource(R.string.close_icon)
)
}
},
}
},
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Search
),
keyboardOptions = KeyboardOptions(
imeAction = ImeAction.Search
),
keyboardActions = KeyboardActions(
onSearch = {

View File

@ -12,7 +12,6 @@ import androidx.lifecycle.ViewModelProvider
import com.nextcloud.talk.chat.viewmodels.ChatViewModel
import com.nextcloud.talk.contacts.ContactsViewModel
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel
import com.nextcloud.talk.contacts.ContactsViewModel
import com.nextcloud.talk.conversation.viewmodel.ConversationViewModel
import com.nextcloud.talk.conversation.viewmodel.RenameConversationViewModel
import com.nextcloud.talk.conversationinfo.viewmodel.ConversationInfoViewModel

View File

@ -8,6 +8,7 @@
package com.nextcloud.talk.contacts
import com.nextcloud.talk.contacts.apiService.FakeItem
import com.nextcloud.talk.contacts.repository.FakeRepositoryError
import com.nextcloud.talk.contacts.repository.FakeRepositorySuccess
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
@ -38,16 +39,24 @@ class ContactsViewModelTest {
}
@Before
fun setUp() {
fun setUp() {
viewModel = ContactsViewModel(repository)
}
@Test
fun `fetch contacts`() =
runTest {
viewModel = ContactsViewModel(repository)
viewModel.getContactsFromSearchParams()
assert(viewModel.contactsViewState.value is ContactsUiState.Success)
val successState = viewModel.contactsViewState.value as ContactsUiState.Success
assert(successState.contacts == FakeItem.contacts)
}
@Test
fun `fetch contacts with error`() =
runTest {
viewModel = ContactsViewModel(FakeRepositoryError())
assert(viewModel.contactsViewState.value is ContactsUiState.Error)
}
}

View File

@ -11,7 +11,7 @@
buildscript {
ext {
kotlinVersion = '1.9.23'
kotlinVersion = '2.0.0'
hilt_version = '2.44'
}

View File

@ -138,6 +138,7 @@
<trusting group="androidx.annotation"/>
<trusting group="androidx.camera"/>
<trusting group="androidx.collection"/>
<trusting group="androidx.compose.foundation"/>
<trusting group="androidx.compose.material3"/>
<trusting group="androidx.core"/>
<trusting group="androidx.emoji2"/>
@ -149,7 +150,6 @@
<trusting group="androidx.sqlite"/>
<trusting group="androidx.webkit"/>
<trusting group="androidx.work"/>
<trusting group="androidx.compose.foundation"/>
</trusted-key>
<trusted-key id="84789D24DF77A32433CE1F079EB80E92EB2135B1">
<trusting group="org.apache" name="apache"/>