From c96d671e6b9e119b6959c881eb4bd5454dde23c8 Mon Sep 17 00:00:00 2001 From: Maxime NATUREL Date: Tue, 20 Sep 2022 14:52:58 +0200 Subject: [PATCH] Adding unit tests for navigator --- .../v2/rename/RenameSessionViewNavigator.kt | 1 - .../rename/RenameSessionViewNavigatorTest.kt | 45 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 vector/src/test/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigatorTest.kt diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigator.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigator.kt index d26733635b..e00d7b25ff 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigator.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigator.kt @@ -19,7 +19,6 @@ package im.vector.app.features.settings.devices.v2.rename import androidx.fragment.app.FragmentActivity import javax.inject.Inject -// TODO add unit tests class RenameSessionViewNavigator @Inject constructor() { fun goBack(activity: FragmentActivity) { diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigatorTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigatorTest.kt new file mode 100644 index 0000000000..faf25e5487 --- /dev/null +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/rename/RenameSessionViewNavigatorTest.kt @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.app.features.settings.devices.v2.rename + +import androidx.fragment.app.FragmentActivity +import io.mockk.every +import io.mockk.just +import io.mockk.mockk +import io.mockk.runs +import io.mockk.verify +import org.junit.Test + +class RenameSessionViewNavigatorTest { + + private val renameSessionViewNavigator = RenameSessionViewNavigator() + + @Test + fun `given an activity when going back then the activity is finished`() { + // Given + val fragmentActivity = mockk() + every { fragmentActivity.finish() } just runs + + // When + renameSessionViewNavigator.goBack(fragmentActivity) + + // Then + verify { + fragmentActivity.finish() + } + } +}