mirror of
https://github.com/nextcloud/talk-android
synced 2025-08-02 17:45:21 +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 {
|
class CompanionClass {
|
||||||
companion object {
|
companion object {
|
||||||
internal val TAG = ContactsActivityCompose::class.simpleName
|
internal val TAG = ContactsActivityCompose::class.simpleName
|
||||||
|
@ -61,25 +61,24 @@ fun DisplaySearch(text: String, onTextChange: (String) -> Unit, contactsViewMode
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
trailingIcon = {
|
trailingIcon = {
|
||||||
if (text.isNotEmpty()) {
|
if (text.isNotEmpty()) {
|
||||||
IconButton(
|
IconButton(
|
||||||
onClick = {
|
onClick = {
|
||||||
onTextChange("")
|
onTextChange("")
|
||||||
}
|
|
||||||
) {
|
|
||||||
Icon(
|
|
||||||
imageVector = Icons.Default.Close,
|
|
||||||
contentDescription = stringResource(R.string.close_icon),
|
|
||||||
//tint = MaterialTheme.colorScheme.onSurface
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
) {
|
||||||
|
Icon(
|
||||||
|
imageVector = Icons.Default.Close,
|
||||||
|
contentDescription = stringResource(R.string.close_icon)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
},
|
||||||
|
|
||||||
keyboardOptions = KeyboardOptions(
|
keyboardOptions = KeyboardOptions(
|
||||||
imeAction = ImeAction.Search
|
imeAction = ImeAction.Search
|
||||||
),
|
),
|
||||||
|
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onSearch = {
|
onSearch = {
|
||||||
|
@ -12,7 +12,6 @@ import androidx.lifecycle.ViewModelProvider
|
|||||||
import com.nextcloud.talk.chat.viewmodels.ChatViewModel
|
import com.nextcloud.talk.chat.viewmodels.ChatViewModel
|
||||||
import com.nextcloud.talk.contacts.ContactsViewModel
|
import com.nextcloud.talk.contacts.ContactsViewModel
|
||||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel
|
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.ConversationViewModel
|
||||||
import com.nextcloud.talk.conversation.viewmodel.RenameConversationViewModel
|
import com.nextcloud.talk.conversation.viewmodel.RenameConversationViewModel
|
||||||
import com.nextcloud.talk.conversationinfo.viewmodel.ConversationInfoViewModel
|
import com.nextcloud.talk.conversationinfo.viewmodel.ConversationInfoViewModel
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
package com.nextcloud.talk.contacts
|
package com.nextcloud.talk.contacts
|
||||||
|
|
||||||
import com.nextcloud.talk.contacts.apiService.FakeItem
|
import com.nextcloud.talk.contacts.apiService.FakeItem
|
||||||
|
import com.nextcloud.talk.contacts.repository.FakeRepositoryError
|
||||||
import com.nextcloud.talk.contacts.repository.FakeRepositorySuccess
|
import com.nextcloud.talk.contacts.repository.FakeRepositorySuccess
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
@ -38,16 +39,24 @@ class ContactsViewModelTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
fun setUp() {
|
fun setUp() {
|
||||||
viewModel = ContactsViewModel(repository)
|
viewModel = ContactsViewModel(repository)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `fetch contacts`() =
|
fun `fetch contacts`() =
|
||||||
runTest {
|
runTest {
|
||||||
|
viewModel = ContactsViewModel(repository)
|
||||||
viewModel.getContactsFromSearchParams()
|
viewModel.getContactsFromSearchParams()
|
||||||
assert(viewModel.contactsViewState.value is ContactsUiState.Success)
|
assert(viewModel.contactsViewState.value is ContactsUiState.Success)
|
||||||
val successState = viewModel.contactsViewState.value as ContactsUiState.Success
|
val successState = viewModel.contactsViewState.value as ContactsUiState.Success
|
||||||
assert(successState.contacts == FakeItem.contacts)
|
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 {
|
buildscript {
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
kotlinVersion = '1.9.23'
|
kotlinVersion = '2.0.0'
|
||||||
hilt_version = '2.44'
|
hilt_version = '2.44'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +138,7 @@
|
|||||||
<trusting group="androidx.annotation"/>
|
<trusting group="androidx.annotation"/>
|
||||||
<trusting group="androidx.camera"/>
|
<trusting group="androidx.camera"/>
|
||||||
<trusting group="androidx.collection"/>
|
<trusting group="androidx.collection"/>
|
||||||
|
<trusting group="androidx.compose.foundation"/>
|
||||||
<trusting group="androidx.compose.material3"/>
|
<trusting group="androidx.compose.material3"/>
|
||||||
<trusting group="androidx.core"/>
|
<trusting group="androidx.core"/>
|
||||||
<trusting group="androidx.emoji2"/>
|
<trusting group="androidx.emoji2"/>
|
||||||
@ -149,7 +150,6 @@
|
|||||||
<trusting group="androidx.sqlite"/>
|
<trusting group="androidx.sqlite"/>
|
||||||
<trusting group="androidx.webkit"/>
|
<trusting group="androidx.webkit"/>
|
||||||
<trusting group="androidx.work"/>
|
<trusting group="androidx.work"/>
|
||||||
<trusting group="androidx.compose.foundation"/>
|
|
||||||
</trusted-key>
|
</trusted-key>
|
||||||
<trusted-key id="84789D24DF77A32433CE1F079EB80E92EB2135B1">
|
<trusted-key id="84789D24DF77A32433CE1F079EB80E92EB2135B1">
|
||||||
<trusting group="org.apache" name="apache"/>
|
<trusting group="org.apache" name="apache"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user