Unit tests for view navigator
This commit is contained in:
parent
0c708c0ad4
commit
bf42220422
|
@ -32,7 +32,6 @@ class SessionOverviewViewNavigator @Inject constructor() {
|
|||
context.startActivity(RenameSessionActivity.newIntent(context, deviceId))
|
||||
}
|
||||
|
||||
// TODO add unit test
|
||||
fun goBack(fragmentActivity: FragmentActivity) {
|
||||
fragmentActivity.finish()
|
||||
}
|
||||
|
|
|
@ -17,12 +17,15 @@
|
|||
package im.vector.app.features.settings.devices.v2.overview
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.fragment.app.FragmentActivity
|
||||
import im.vector.app.features.settings.devices.v2.details.SessionDetailsActivity
|
||||
import im.vector.app.features.settings.devices.v2.rename.RenameSessionActivity
|
||||
import im.vector.app.test.fakes.FakeContext
|
||||
import io.mockk.every
|
||||
import io.mockk.just
|
||||
import io.mockk.mockk
|
||||
import io.mockk.mockkObject
|
||||
import io.mockk.runs
|
||||
import io.mockk.unmockkAll
|
||||
import io.mockk.verify
|
||||
import org.junit.After
|
||||
|
@ -77,6 +80,21 @@ class SessionOverviewViewNavigatorTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `given an activity when going back then the activity is finished`() {
|
||||
// Given
|
||||
val fragmentActivity = mockk<FragmentActivity>()
|
||||
every { fragmentActivity.finish() } just runs
|
||||
|
||||
// When
|
||||
sessionOverviewViewNavigator.goBack(fragmentActivity)
|
||||
|
||||
// Then
|
||||
verify {
|
||||
fragmentActivity.finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun givenIntentForSessionDetails(sessionId: String): Intent {
|
||||
val intent = mockk<Intent>()
|
||||
every { SessionDetailsActivity.newIntent(context.instance, sessionId) } returns intent
|
||||
|
|
Loading…
Reference in New Issue