From f2b38e50e36152c9c78a2c0c0995edc5212bab6e Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Tue, 20 Aug 2024 17:11:30 +0200 Subject: [PATCH] Add test on function name which may start or end with spaces and fix existing issues. --- .../roomlist/impl/RoomListPresenterTest.kt | 2 +- .../mediaviewer/MediaViewerPresenterTest.kt | 2 +- .../push/impl/push/DefaultPushHandlerTest.kt | 2 +- .../tests/konsist/KonsistMethodNameTest.kt | 32 +++++++++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistMethodNameTest.kt diff --git a/features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt b/features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt index 4bf4510d2f..a381dc414d 100644 --- a/features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt +++ b/features/roomlist/impl/src/test/kotlin/io/element/android/features/roomlist/impl/RoomListPresenterTest.kt @@ -495,7 +495,7 @@ class RoomListPresenterTest { } @Test - fun `present - when room service returns no room, then contentState is Empty `() = runTest { + fun `present - when room service returns no room, then contentState is Empty`() = runTest { val scope = CoroutineScope(coroutineContext + SupervisorJob()) val roomListService = FakeRoomListService() roomListService.postAllRoomsLoadingState(RoomList.LoadingState.Loaded(0)) diff --git a/libraries/mediaviewer/api/src/test/kotlin/io/element/android/libraries/mediaviewer/MediaViewerPresenterTest.kt b/libraries/mediaviewer/api/src/test/kotlin/io/element/android/libraries/mediaviewer/MediaViewerPresenterTest.kt index 67d8f7c3a1..23abdce74c 100644 --- a/libraries/mediaviewer/api/src/test/kotlin/io/element/android/libraries/mediaviewer/MediaViewerPresenterTest.kt +++ b/libraries/mediaviewer/api/src/test/kotlin/io/element/android/libraries/mediaviewer/MediaViewerPresenterTest.kt @@ -70,7 +70,7 @@ class MediaViewerPresenterTest { } @Test - fun `present - check all actions `() = runTest { + fun `present - check all actions`() = runTest { val matrixMediaLoader = FakeMatrixMediaLoader() val mediaActions = FakeLocalMediaActions() val snackbarDispatcher = SnackbarDispatcher() diff --git a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt index 4953e4d7b4..160f9f5135 100644 --- a/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt +++ b/libraries/push/impl/src/test/kotlin/io/element/android/libraries/push/impl/push/DefaultPushHandlerTest.kt @@ -306,7 +306,7 @@ class DefaultPushHandlerTest { } @Test - fun `when diagnostic PushData is received, the diagnostic push handler is informed `() = + fun `when diagnostic PushData is received, the diagnostic push handler is informed`() = runTest { val aPushData = PushData( eventId = DefaultTestPush.TEST_EVENT_ID, diff --git a/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistMethodNameTest.kt b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistMethodNameTest.kt new file mode 100644 index 0000000000..2d3a91c093 --- /dev/null +++ b/tests/konsist/src/test/kotlin/io/element/android/tests/konsist/KonsistMethodNameTest.kt @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 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 io.element.android.tests.konsist + +import com.lemonappdev.konsist.api.Konsist +import com.lemonappdev.konsist.api.verify.assertTrue +import org.junit.Test + +class KonsistMethodNameTest { + @Test + fun `Ensure that method name does not start or end with spaces`() { + Konsist.scopeFromProject() + .functions() + .assertTrue { + it.name.trim() == it.name + } + } +}