add test cases for create room
Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
Родитель
8d52a6fcc9
Коммит
d656a93e8a
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Nextcloud Talk - Android Client
|
||||
*
|
||||
* SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
|
||||
* SPDX-FileCopyrightText: 2024 Sowjanya Kota <sowjanya.kch@gmail.com>
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
@ -59,4 +59,50 @@ class ContactsViewModelTest {
|
|||
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||
assert(viewModel.contactsViewState.value is ContactsUiState.Error)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `update search query`() {
|
||||
viewModel.updateSearchQuery("Ma")
|
||||
assert(viewModel.searchQuery.value == "Ma")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `initial search query is empty string`() {
|
||||
viewModel.updateSearchQuery("")
|
||||
assert(viewModel.searchQuery.value == "")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `initial shareType is User`() {
|
||||
assert(viewModel.shareTypeList.contains(ShareType.User.shareType))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `update shareTypes`() {
|
||||
viewModel.updateShareTypes(ShareType.Group.shareType)
|
||||
assert(viewModel.shareTypeList.contains(ShareType.Group.shareType))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `initial room state is none`() =
|
||||
runTest {
|
||||
assert(viewModel.roomViewState.value is RoomUiState.None)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test success room state`() =
|
||||
runTest {
|
||||
viewModel.createRoom("1", "users", "s@gmail.com", null)
|
||||
assert(viewModel.roomViewState.value is RoomUiState.Success)
|
||||
val successState = viewModel.roomViewState.value as RoomUiState.Success
|
||||
assert(successState.conversation == FakeItem.roomOverall.ocs!!.data)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test failure room state`() =
|
||||
runTest {
|
||||
viewModel = ContactsViewModel(FakeRepositoryError())
|
||||
viewModel.createRoom("1", "users", "s@gmail.com", null)
|
||||
assert(viewModel.roomViewState.value is RoomUiState.Error)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,11 @@ package com.nextcloud.talk.contacts.apiService
|
|||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOCS
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
|
||||
import com.nextcloud.talk.models.json.autocomplete.AutocompleteUser
|
||||
import com.nextcloud.talk.models.json.conversations.Conversation
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOCS
|
||||
import com.nextcloud.talk.models.json.conversations.RoomOverall
|
||||
import com.nextcloud.talk.models.json.generic.GenericMeta
|
||||
import org.mockito.Mockito.mock
|
||||
|
||||
object FakeItem {
|
||||
val contacts: List<AutocompleteUser>? =
|
||||
|
@ -41,4 +45,14 @@ object FakeItem {
|
|||
data = contacts
|
||||
)
|
||||
)
|
||||
val roomOverall: RoomOverall = RoomOverall(
|
||||
ocs = RoomOCS(
|
||||
meta = GenericMeta(
|
||||
status = "ok",
|
||||
statusCode = 200,
|
||||
message = "OK"
|
||||
),
|
||||
data = mock(Conversation::class.java)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@ class FakeRepositorySuccess() : ContactsRepository {
|
|||
userId: String,
|
||||
conversationName: String?
|
||||
): RoomOverall {
|
||||
TODO("Not yet implemented")
|
||||
return FakeItem.roomOverall
|
||||
}
|
||||
|
||||
override fun getImageUri(avatarId: String, requestBigSize: Boolean): String {
|
||||
TODO("Not yet implemented")
|
||||
return "https://mydomain.com/index.php/avatar/$avatarId/512"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче