From 25e467b3a5bb4bd7d898181467f778766d7babf3 Mon Sep 17 00:00:00 2001 From: Akshay Komar <146421342+Akshaykomar890@users.noreply.github.com> Date: Sun, 5 Jan 2025 13:51:17 +0530 Subject: [PATCH] Refactor Nearby Location Tests to Improve Assertion Logic (#6103) -Refactored testSearchCloseToCurrentLocationWhenFar: Simplified assertion by using assertFalse(!isClose) for better readability and logical clarity. -Added testSearchCloseToCurrentLocationWhenClose: Created a new test case to validate behavior when the search is close to the current location, ensuring assertTrue(isClose) for correctness. -Improved Coverage: These changes enhance the test coverage and reliability of the searchCloseToCurrentLocation function. --- .../nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt b/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt index cfd2a818d..80e9a53f9 100644 --- a/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt +++ b/app/src/test/kotlin/fr/free/nrw/commons/nearby/NearbyParentFragmentPresenterTest.kt @@ -306,7 +306,7 @@ class NearbyParentFragmentPresenterTest { // 111.19 km real distance, return false if 148306.444306 > currentLocationSearchRadius NearbyController.currentLocationSearchRadius = 148306.0 val isClose = nearbyPresenter.searchCloseToCurrentLocation() - assertFalse(isClose!!.equals(false)) + assertFalse(!isClose) } /** @@ -318,7 +318,7 @@ class NearbyParentFragmentPresenterTest { // 111.19 km real distance, return false if 148253.333 > currentLocationSearchRadius NearbyController.currentLocationSearchRadius = 148307.0 val isClose = nearbyPresenter.searchCloseToCurrentLocation() - assertTrue(isClose!!) + assertTrue(isClose) } fun expectMapAndListUpdate() {