mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 19:49:33 +01:00
Image uri test cases
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
d656a93e8a
commit
a51e3b98ad
@ -58,16 +58,18 @@ class ContactsViewModelTest {
|
||||
runTest {
|
||||
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||
assert(viewModel.contactsViewState.value is ContactsUiState.Error)
|
||||
val errorState = viewModel.contactsViewState.value as ContactsUiState.Error
|
||||
assert(errorState.message == "unable to fetch contacts")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `update search query`() {
|
||||
fun `update search query`() {
|
||||
viewModel.updateSearchQuery("Ma")
|
||||
assert(viewModel.searchQuery.value == "Ma")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `initial search query is empty string`() {
|
||||
fun `initial search query is empty string`() {
|
||||
viewModel.updateSearchQuery("")
|
||||
assert(viewModel.searchQuery.value == "")
|
||||
}
|
||||
@ -104,5 +106,21 @@ class ContactsViewModelTest {
|
||||
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||
viewModel.createRoom("1", "users", "s@gmail.com", null)
|
||||
assert(viewModel.roomViewState.value is RoomUiState.Error)
|
||||
val errorState = viewModel.roomViewState.value as RoomUiState.Error
|
||||
assert(errorState.message == "unable to create room")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test image uri`() {
|
||||
val expectedImageUri = "https://mydomain.com/index.php/avatar/vidya/512"
|
||||
val imageUri = viewModel.getImageUri("vidya", false)
|
||||
assert(imageUri == expectedImageUri)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test error image uri`() {
|
||||
val expectedImageUri = "https://mydoman.com/index.php/avatar/vidya/512"
|
||||
val imageUri = viewModel.getImageUri("vidya", false)
|
||||
assert(imageUri != expectedImageUri)
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
|
||||
class FakeRepositoryError() : ContactsRepository {
|
||||
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
|
||||
throw Exception("unknown error occurred")
|
||||
throw Exception("unable to fetch contacts")
|
||||
}
|
||||
|
||||
override suspend fun createRoom(
|
||||
@ -22,10 +22,10 @@ class FakeRepositoryError() : ContactsRepository {
|
||||
userId: String,
|
||||
conversationName: String?
|
||||
): RoomOverall {
|
||||
throw Exception("unknown error occurred")
|
||||
throw Exception("unable to create room")
|
||||
}
|
||||
|
||||
override fun getImageUri(avatarId: String, requestBigSize: Boolean): String {
|
||||
throw Exception("unknown error occurred")
|
||||
return "https://mydoman.com/index.php/avatar/$avatarId/512"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user