mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-29 07:35:11 +01:00
add error test case for contacts fetch
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
62b2ecd338
commit
8d52a6fcc9
@ -325,8 +325,6 @@ fun ConversationCreationOptions(context: Context) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class CompanionClass {
|
||||
companion object {
|
||||
internal val TAG = ContactsActivityCompose::class.simpleName
|
||||
|
@ -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 = {
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
buildscript {
|
||||
|
||||
ext {
|
||||
kotlinVersion = '1.9.23'
|
||||
kotlinVersion = '2.0.0'
|
||||
hilt_version = '2.44'
|
||||
}
|
||||
|
||||
|
@ -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"/>
|
||||
|
Loading…
Reference in New Issue
Block a user