mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-20 12:09:45 +01:00
Image uri test cases
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
parent
d656a93e8a
commit
a51e3b98ad
@ -58,6 +58,8 @@ class ContactsViewModelTest {
|
|||||||
runTest {
|
runTest {
|
||||||
viewModel = ContactsViewModel(FakeRepositoryError())
|
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||||
assert(viewModel.contactsViewState.value is ContactsUiState.Error)
|
assert(viewModel.contactsViewState.value is ContactsUiState.Error)
|
||||||
|
val errorState = viewModel.contactsViewState.value as ContactsUiState.Error
|
||||||
|
assert(errorState.message == "unable to fetch contacts")
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -104,5 +106,21 @@ class ContactsViewModelTest {
|
|||||||
viewModel = ContactsViewModel(FakeRepositoryError())
|
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||||
viewModel.createRoom("1", "users", "s@gmail.com", null)
|
viewModel.createRoom("1", "users", "s@gmail.com", null)
|
||||||
assert(viewModel.roomViewState.value is RoomUiState.Error)
|
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 {
|
class FakeRepositoryError() : ContactsRepository {
|
||||||
override suspend fun getContacts(searchQuery: String?, shareTypes: List<String>): AutocompleteOverall {
|
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(
|
override suspend fun createRoom(
|
||||||
@ -22,10 +22,10 @@ class FakeRepositoryError() : ContactsRepository {
|
|||||||
userId: String,
|
userId: String,
|
||||||
conversationName: String?
|
conversationName: String?
|
||||||
): RoomOverall {
|
): RoomOverall {
|
||||||
throw Exception("unknown error occurred")
|
throw Exception("unable to create room")
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getImageUri(avatarId: String, requestBigSize: Boolean): String {
|
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