mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-30 13:35:18 +00:00
Fix group admin test
This commit is contained in:
parent
c492a74014
commit
9968b5d6ea
@ -136,7 +136,7 @@ class ExpirationSettingsViewModelTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `group, off, admin, new config`() = runTest {
|
fun `group, off, admin, new config`() = runTest {
|
||||||
mockGroup(ExpiryMode.NONE)
|
mockGroup(ExpiryMode.NONE, isAdmin = true)
|
||||||
|
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ class ExpirationSettingsViewModelTest {
|
|||||||
).isEqualTo(
|
).isEqualTo(
|
||||||
State(
|
State(
|
||||||
isGroup = true,
|
isGroup = true,
|
||||||
isSelfAdmin = false,
|
isSelfAdmin = true,
|
||||||
address = GROUP_ADDRESS,
|
address = GROUP_ADDRESS,
|
||||||
isNoteToSelf = false,
|
isNoteToSelf = false,
|
||||||
expiryMode = ExpiryMode.NONE,
|
expiryMode = ExpiryMode.NONE,
|
||||||
@ -163,21 +163,20 @@ class ExpirationSettingsViewModelTest {
|
|||||||
UiState(
|
UiState(
|
||||||
CardModel(
|
CardModel(
|
||||||
R.string.activity_expiration_settings_timer,
|
R.string.activity_expiration_settings_timer,
|
||||||
typeOption(ExpiryMode.NONE, enabled = false, selected = true),
|
typeOption(ExpiryMode.NONE, selected = true),
|
||||||
timeOption(ExpiryType.AFTER_SEND, 12.hours, enabled = false),
|
timeOption(ExpiryType.AFTER_SEND, 12.hours),
|
||||||
timeOption(ExpiryType.AFTER_SEND, 1.days, enabled = false),
|
timeOption(ExpiryType.AFTER_SEND, 1.days),
|
||||||
timeOption(ExpiryType.AFTER_SEND, 7.days, enabled = false),
|
timeOption(ExpiryType.AFTER_SEND, 7.days),
|
||||||
timeOption(ExpiryType.AFTER_SEND, 14.days, enabled = false)
|
timeOption(ExpiryType.AFTER_SEND, 14.days)
|
||||||
),
|
),
|
||||||
showGroupFooter = true,
|
showGroupFooter = true
|
||||||
showSetButton = false
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `group, off, not admin, new config`() = runTest {
|
fun `group, off, not admin, new config`() = runTest {
|
||||||
mockGroup(ExpiryMode.NONE)
|
mockGroup(ExpiryMode.NONE, isAdmin = false)
|
||||||
|
|
||||||
val viewModel = createViewModel()
|
val viewModel = createViewModel()
|
||||||
|
|
||||||
@ -526,7 +525,7 @@ class ExpirationSettingsViewModelTest {
|
|||||||
whenever(recipient.address).thenReturn(someAddress)
|
whenever(recipient.address).thenReturn(someAddress)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun mockGroup(mode: ExpiryMode) {
|
private fun mockGroup(mode: ExpiryMode, isAdmin: Boolean) {
|
||||||
val config = config(mode)
|
val config = config(mode)
|
||||||
|
|
||||||
whenever(threadDb.getRecipientForThreadId(Mockito.anyLong())).thenReturn(recipient)
|
whenever(threadDb.getRecipientForThreadId(Mockito.anyLong())).thenReturn(recipient)
|
||||||
@ -536,7 +535,11 @@ class ExpirationSettingsViewModelTest {
|
|||||||
whenever(recipient.address).thenReturn(GROUP_ADDRESS)
|
whenever(recipient.address).thenReturn(GROUP_ADDRESS)
|
||||||
whenever(recipient.isClosedGroupRecipient).thenReturn(true)
|
whenever(recipient.isClosedGroupRecipient).thenReturn(true)
|
||||||
whenever(groupDb.getGroup(any<String>())).thenReturn(Optional.of(groupRecord))
|
whenever(groupDb.getGroup(any<String>())).thenReturn(Optional.of(groupRecord))
|
||||||
whenever(groupRecord.admins).thenReturn(listOf())
|
whenever(groupRecord.admins).thenReturn(
|
||||||
|
buildList {
|
||||||
|
if (isAdmin) add(LOCAL_ADDRESS)
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun config(mode: ExpiryMode) = ExpirationConfiguration(
|
private fun config(mode: ExpiryMode) = ExpirationConfiguration(
|
||||||
|
Loading…
Reference in New Issue
Block a user