From dc19bb74a2779ac29abeda0a226f1b8ca83b4486 Mon Sep 17 00:00:00 2001 From: Zeeshan Sheikh Date: Mon, 14 Oct 2024 23:43:03 +0500 Subject: [PATCH] ALS-1805 fixed PR feedback --- .../project.pbxproj | 6 +- .../xcshareddata/swiftpm/Package.resolved | 18 ++-- .../Extensions/AWSEndpoint+Extension.swift | 91 ------------------ .../Extensions/Double+Extension.swift | 16 ++-- .../Extensions/Int+Extension.swift | 4 +- .../Services/LocationServiceable.swift | 2 +- .../Contracts/DirectionContracts.swift | 2 +- .../Direction/Controller/DirectionVC.swift | 2 +- .../ViewModel/DirectionViewModel.swift | 2 +- .../POICard/ViewModel/POICardViewModel.swift | 2 +- .../Search/Contracts/SearchVCContracts.swift | 2 +- .../Search/Controller/SearchVC.swift | 2 +- .../Search/ViewModel/SearchViewModel.swift | 2 +- .../Search/Views/Cell/SearchCell.swift | 2 +- .../Contracts/AddGeofenceContracts.swift | 2 +- .../Controller/AddGeofenceVC.swift | 4 +- .../ViewModel/AddGeofenceViewModel.swift | 2 +- .../Views/AddGeofenceSearchView.swift | 8 +- .../Services/LocationSearchService.swift | 4 +- .../Views/Common/POICardView.swift | 2 +- .../AddGeofenceViewModelTests.swift | 22 ++--- .../DirectionViewModelTests.swift | 23 ++--- .../DoubleExtensionTests.swift | 4 +- .../GeofenceViewModelTests.swift | 1 + .../IntExtensionTests.swift | 8 +- .../NavigationVCViewModelTests.swift | 2 +- .../SearchViewModelTests.swift | 22 ++--- .../TrackingViewModelTests.swift | 13 +-- .../SearchUITests.swift | 96 ------------------- 29 files changed, 78 insertions(+), 288 deletions(-) delete mode 100644 LocationServices/LocationServices/Extensions/AWSEndpoint+Extension.swift diff --git a/LocationServices/LocationServices.xcodeproj/project.pbxproj b/LocationServices/LocationServices.xcodeproj/project.pbxproj index a695d9d8..ac65e623 100644 --- a/LocationServices/LocationServices.xcodeproj/project.pbxproj +++ b/LocationServices/LocationServices.xcodeproj/project.pbxproj @@ -113,7 +113,6 @@ 8AFBAFE0296F19BC0022A7E3 /* AWSLocationTravelMode+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFBAFDF296F19BC0022A7E3 /* AWSLocationTravelMode+Extension.swift */; }; 8AFDA09429DDBB3600114BB7 /* VersionVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFDA09329DDBB3600114BB7 /* VersionVC.swift */; }; 8AFDA09629DDBC3800114BB7 /* VersionVCBuilder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8AFDA09529DDBC3800114BB7 /* VersionVCBuilder.swift */; }; - 960968A529A2C83D0026C05A /* AWSEndpoint+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 960968A429A2C83D0026C05A /* AWSEndpoint+Extension.swift */; }; 963EBF5229AF92F7001961F2 /* LocationServicesTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 963EBF5129AF92F7001961F2 /* LocationServicesTests.swift */; }; 9660600129A4F20100FB88D0 /* StringConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9660600029A4F20100FB88D0 /* StringConstants.swift */; }; 96E742AA2967381900D5C0BC /* Sequence+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96E742A92967381800D5C0BC /* Sequence+Extension.swift */; }; @@ -536,7 +535,6 @@ 8AFBAFDF296F19BC0022A7E3 /* AWSLocationTravelMode+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AWSLocationTravelMode+Extension.swift"; sourceTree = ""; }; 8AFDA09329DDBB3600114BB7 /* VersionVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionVC.swift; sourceTree = ""; }; 8AFDA09529DDBC3800114BB7 /* VersionVCBuilder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VersionVCBuilder.swift; sourceTree = ""; }; - 960968A429A2C83D0026C05A /* AWSEndpoint+Extension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "AWSEndpoint+Extension.swift"; sourceTree = ""; }; 963EBF4F29AF92F5001961F2 /* LocationServicesTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LocationServicesTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 963EBF5129AF92F7001961F2 /* LocationServicesTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationServicesTests.swift; sourceTree = ""; }; 9660600029A4F20100FB88D0 /* StringConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StringConstants.swift; sourceTree = ""; }; @@ -2895,7 +2893,6 @@ 8A3471CB2975D30B00BAF374 /* Locale+Extension.swift */, 8A76327B297EAE270064D60F /* MGLMapViewDelegate+Extension.swift */, ADB0B187299221A800282814 /* Date+Extension.swift */, - 960968A429A2C83D0026C05A /* AWSEndpoint+Extension.swift */, 8A439F0729C0BA1B00B59D0B /* UIApplication+Extension.swift */, 8A6B834929DAD4960047AA17 /* UITapGestureRecognizer+Extensions.swift */, 8ACAAD7529F14B9D00523256 /* CLLocationManager+Extension.swift */, @@ -3344,7 +3341,6 @@ ADD139902980A2590003F917 /* RouteOptionContracts.swift in Sources */, AD625E9C293BEFAC00C67B44 /* SearchCell.swift in Sources */, ADA85E752989A22300446788 /* SettingsDefaultValueHelper.swift in Sources */, - 960968A529A2C83D0026C05A /* AWSEndpoint+Extension.swift in Sources */, AD2AF099292EA8D600149904 /* GeofenceView.swift in Sources */, AD2AF09B292EA8E000149904 /* GeofenceContracts.swift in Sources */, ADC1249E2979BB8300B08C20 /* Notificaton+Extension.swift in Sources */, @@ -4061,7 +4057,7 @@ repositoryURL = "https://github.com/awslabs/aws-sdk-swift"; requirement = { kind = upToNextMajorVersion; - minimumVersion = 0.47.0; + minimumVersion = 1.0.18; }; }; /* End XCRemoteSwiftPackageReference section */ diff --git a/LocationServices/LocationServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/LocationServices/LocationServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 7843d34c..482a7e97 100644 --- a/LocationServices/LocationServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/LocationServices/LocationServices.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -7,7 +7,7 @@ "location" : "https://github.com/awslabs/aws-crt-swift", "state" : { "branch" : "mqtt_test_app", - "revision" : "c0e4aa6bddb7b54c6d07545fe55655f29ce1bc0d" + "revision" : "e7e603d3aadd1749b3e5cc554832ab337fdfd8f3" } }, { @@ -15,8 +15,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/awslabs/aws-sdk-swift", "state" : { - "revision" : "6b4d5f7447dd8a76c6935fa3484491cd3203c888", - "version" : "0.62.0" + "revision" : "8ec5c0c820ca912a6bad1fc31c287d321385d698", + "version" : "1.0.18" } }, { @@ -33,8 +33,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/maplibre/maplibre-gl-native-distribution", "state" : { - "revision" : "039ef525064a685c291db5118f6b5f6e8b090bb0", - "version" : "6.5.2" + "revision" : "f23db791d7b6f0329e3c6788d8e4152c24c52b6b", + "version" : "6.7.1" } }, { @@ -42,8 +42,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/smithy-lang/smithy-swift", "state" : { - "revision" : "e7e71e9c128b6dfeb0349537d6fd4a7cbc358ae1", - "version" : "0.59.0" + "revision" : "bf096bf5c507e2c3f9ecc23c0c65dba2e1ffe3b2", + "version" : "0.79.0" } }, { @@ -51,8 +51,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/SnapKit/SnapKit.git", "state" : { - "revision" : "f222cbdf325885926566172f6f5f06af95473158", - "version" : "5.6.0" + "revision" : "2842e6e84e82eb9a8dac0100ca90d9444b0307f4", + "version" : "5.7.1" } }, { diff --git a/LocationServices/LocationServices/Extensions/AWSEndpoint+Extension.swift b/LocationServices/LocationServices/Extensions/AWSEndpoint+Extension.swift deleted file mode 100644 index 089e002e..00000000 --- a/LocationServices/LocationServices/Extensions/AWSEndpoint+Extension.swift +++ /dev/null @@ -1,91 +0,0 @@ -// -// AWSEndpoint+Extension.swift -// LocationServices -// -// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. -// SPDX-License-Identifier: MIT-0 - -//import Foundation -// -//fileprivate let AWSRegionNameUSEast1 = "us-east-1" -//fileprivate let AWSRegionNameUSEast2 = "us-east-2" -//fileprivate let AWSRegionNameUSWest2 = "us-west-2" -//fileprivate let AWSRegionNameUSWest1 = "us-west-1" -//fileprivate let AWSRegionNameEUWest1 = "eu-west-1" -//fileprivate let AWSRegionNameEUWest2 = "eu-west-2" -//fileprivate let AWSRegionNameEUWest3 = "eu-west-3" -//fileprivate let AWSRegionNameEUCentral1 = "eu-central-1" -//fileprivate let AWSRegionNameEUNorth1 = "eu-north-1" -//fileprivate let AWSRegionNameAPEast1 = "ap-east-1" -//fileprivate let AWSRegionNameAPSoutheast1 = "ap-southeast-1" -//fileprivate let AWSRegionNameAPNortheast1 = "ap-northeast-1" -//fileprivate let AWSRegionNameAPNortheast2 = "ap-northeast-2" -//fileprivate let AWSRegionNameAPSoutheast2 = "ap-southeast-2" -//fileprivate let AWSRegionNameAPSouth1 = "ap-south-1" -//fileprivate let AWSRegionNameSAEast1 = "sa-east-1" -//fileprivate let AWSRegionNameCNNorth1 = "cn-north-1" -//fileprivate let AWSRegionNameCNNorthWest1 = "cn-northwest-1" -//fileprivate let AWSRegionNameCACentral1 = "ca-central-1" -//fileprivate let AWSRegionNameUSGovWest1 = "us-gov-west-1" -//fileprivate let AWSRegionNameUSGovEast1 = "us-gov-east-1" -//fileprivate let AWSRegionNameMESouth1 = "me-south-1" -//fileprivate let AWSRegionNameAFSouth1 = "af-south-1" -//fileprivate let AWSRegionNameEUSouth1 = "eu-south-1" -// -//public class AWSEndpoint { -// -// static func regionTypeByString(regionString: String) -> AWSRegionType? { -// switch regionString { -// case AWSRegionNameUSEast1: -// return .USEast1 -// case AWSRegionNameUSEast2: -// return .USEast2 -// case AWSRegionNameUSWest2: -// return .USWest2 -// case AWSRegionNameUSWest1: -// return .USWest1 -// case AWSRegionNameEUWest1: -// return .EUWest1 -// case AWSRegionNameEUWest2: -// return .EUWest2 -// case AWSRegionNameEUCentral1: -// return .EUCentral1 -// case AWSRegionNameAPSoutheast1: -// return .APSoutheast1 -// case AWSRegionNameAPSoutheast2: -// return .APSoutheast2 -// case AWSRegionNameAPNortheast1: -// return .APNortheast1 -// case AWSRegionNameAPNortheast2: -// return .APNortheast2 -// case AWSRegionNameAPSouth1: -// return .APSouth1 -// case AWSRegionNameSAEast1: -// return .SAEast1 -// case AWSRegionNameCNNorth1: -// return .CNNorth1 -// case AWSRegionNameCACentral1: -// return .CACentral1 -// case AWSRegionNameUSGovWest1: -// return .USGovWest1; -// case AWSRegionNameCNNorthWest1: -// return .CNNorthWest1; -// case AWSRegionNameEUWest3: -// return .EUWest3; -// case AWSRegionNameUSGovEast1: -// return .USGovEast1; -// case AWSRegionNameEUNorth1: -// return .EUNorth1; -// case AWSRegionNameAPEast1: -// return .APEast1; -// case AWSRegionNameMESouth1: -// return .MESouth1; -// case AWSRegionNameAFSouth1: -// return .AFSouth1; -// case AWSRegionNameEUSouth1: -// return .EUSouth1; -// default: -// return nil; -// } -// } -//} diff --git a/LocationServices/LocationServices/Extensions/Double+Extension.swift b/LocationServices/LocationServices/Extensions/Double+Extension.swift index 4d00771f..72f903ad 100644 --- a/LocationServices/LocationServices/Extensions/Double+Extension.swift +++ b/LocationServices/LocationServices/Extensions/Double+Extension.swift @@ -29,21 +29,19 @@ extension Double { } func convertFormattedKMString() -> String { - let distanceInMeters = Int(convertKMToM()) - return distanceInMeters.convertToKm() + let distanceInMeters = convertKMToMeters() + return distanceInMeters.fromatToKmString() } - func convertKMToM() -> Double { + func convertKMToMeters() -> Double { return self * 1000 } - func convertToKm() -> String { - let num: Double = Double(self) - if num > 1000 { - let result = Double(num * 1000 / 1000 / 1000) - return String(format: "%.2f", result) + " km" + func fromatToKmString() -> String { + if self >= 1000 { + return String(format: "%.2f km", self / 1000) } else { - return "\(String(format: "%.0f", num)) m" + return String(format: "%.0f m", self) } } } diff --git a/LocationServices/LocationServices/Extensions/Int+Extension.swift b/LocationServices/LocationServices/Extensions/Int+Extension.swift index 166db705..d50d882d 100644 --- a/LocationServices/LocationServices/Extensions/Int+Extension.swift +++ b/LocationServices/LocationServices/Extensions/Int+Extension.swift @@ -8,7 +8,7 @@ import UIKit extension Int { - func convertToKm() -> String { + func fromatToKmString() -> String { let num: Double = Double(self) if num > 1000 { let result = Double(round(num * 1000 / 1000) / 1000) @@ -20,7 +20,7 @@ extension Int { } extension Int64 { - func convertToKm() -> String { + func fromatToKmString() -> String { let num: Double = Double(self) if num > 1000 { let result = Double(round(num * 1000 / 1000) / 1000) diff --git a/LocationServices/LocationServices/Networking/Services/LocationServiceable.swift b/LocationServices/LocationServices/Networking/Services/LocationServiceable.swift index 93fdac90..c8bc1f0c 100644 --- a/LocationServices/LocationServices/Networking/Services/LocationServiceable.swift +++ b/LocationServices/LocationServices/Networking/Services/LocationServiceable.swift @@ -36,7 +36,7 @@ struct LocationService: AWSLocationSearchService, LocationServiceable { func searchTextWithSuggestion(text: String, userLat: Double?, userLong: Double?) async -> Result<[SearchPresentation], Error> { do { - let result = try await searchTextWithSuggesstionRequest(text: text, userLat: userLat, userLong: userLong) + let result = try await searchTextWithSuggestionRequest(text: text, userLat: userLat, userLong: userLong) let model = try await result!.results!.asyncMap({ model in guard let placeId = model.placeId else { return SearchPresentation(model: model) } diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Contracts/DirectionContracts.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Contracts/DirectionContracts.swift index 39fb148a..1b858b81 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Contracts/DirectionContracts.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Contracts/DirectionContracts.swift @@ -9,7 +9,7 @@ import Foundation protocol DirectionViewModelProtocol: AnyObject { var delegate: DirectionViewModelOutputDelegate? { get set } - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async func searchWith(text: String, userLat: Double?, userLong: Double?) async throws func numberOfRowsInSection() -> Int func getSearchCellModel() -> [SearchCellViewModel] diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Controller/DirectionVC.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Controller/DirectionVC.swift index e833a79e..30123126 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Controller/DirectionVC.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/Controller/DirectionVC.swift @@ -161,7 +161,7 @@ final class DirectionVC: UIViewController { self?.directionView.isHidden = true self?.tableView.isHidden = false Task { - await self?.viewModel.searchWithSuggesstion(text: model.searchText, + await self?.viewModel.searchWithSuggestion(text: model.searchText, userLat: self?.userLocation?.lat, userLong: self?.userLocation?.long) } diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/ViewModel/DirectionViewModel.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/ViewModel/DirectionViewModel.swift index d5c8763c..e1c1424a 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/ViewModel/DirectionViewModel.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Direction/ViewModel/DirectionViewModel.swift @@ -51,7 +51,7 @@ final class DirectionViewModel: DirectionViewModelProtocol { delegate?.reloadView() } - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async { + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async { guard !text.isEmpty && text != "My Location" else { presentation = [] diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/POICard/ViewModel/POICardViewModel.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/POICard/ViewModel/POICardViewModel.swift index 5a2a2296..0fa0a369 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/POICard/ViewModel/POICardViewModel.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/POICard/ViewModel/POICardViewModel.swift @@ -71,7 +71,7 @@ final class POICardViewModel: POICardViewModelProcotol { case .success(let direction): guard !(self.datas.isEmpty) else { break } - self.datas[0].distance = direction.distance.convertKMToM() + self.datas[0].distance = direction.distance.convertKMToMeters() self.datas[0].duration = direction.duration.convertSecondsToMinString() case .failure(let error): responseError = error diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Contracts/SearchVCContracts.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Contracts/SearchVCContracts.swift index edd3e27b..9d17acd4 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Contracts/SearchVCContracts.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Contracts/SearchVCContracts.swift @@ -18,7 +18,7 @@ protocol SearchVCOutputDelegate: AnyObject { protocol SearchViewModelProcotol: AnyObject { var delegate: SearchViewModelOutputDelegate? { get set } - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async throws + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async throws func searchWith(text: String, userLat: Double?, userLong: Double?) async throws func numberOfRowsInSection() -> Int func getSearchCellModel() -> [SearchCellViewModel] diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Controller/SearchVC.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Controller/SearchVC.swift index c07db77e..e2046734 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Controller/SearchVC.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Controller/SearchVC.swift @@ -189,7 +189,7 @@ extension SearchVC: SearchViewModelOutputDelegate { extension SearchVC: SearchBarViewOutputDelegate { func searchText(_ text: String?) { Task { - try await viewModel.searchWithSuggesstion(text: text ?? "", userLat: userLocation?.lat, userLong: userLocation?.long) + try await viewModel.searchWithSuggestion(text: text ?? "", userLat: userLocation?.lat, userLong: userLocation?.long) } } diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/ViewModel/SearchViewModel.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/ViewModel/SearchViewModel.swift index 75195461..293a80ad 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/ViewModel/SearchViewModel.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/ViewModel/SearchViewModel.swift @@ -22,7 +22,7 @@ final class SearchViewModel: SearchViewModelProcotol { self.service = service } - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async throws { + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async throws { guard !text.isEmpty else { self.presentation = [] self.delegate?.searchResult(mapModel: [], shouldDismiss: false, showOnMap: false) diff --git a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Views/Cell/SearchCell.swift b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Views/Cell/SearchCell.swift index 6bbeb8e3..016b6d1e 100644 --- a/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Views/Cell/SearchCell.swift +++ b/LocationServices/LocationServices/Scenes/Explore/Sub-Scenes/Search/Views/Cell/SearchCell.swift @@ -51,7 +51,7 @@ final class SearchCell: UITableViewCell { if model.searchType == .location { self.locationDistance.isHidden = false self.locationAddress.isHidden = false - self.locationDistance.text = model.locationDistance?.convertToKm() + self.locationDistance.text = model.locationDistance?.fromatToKmString() locationAddress.snp.remakeConstraints { $0.top.equalTo(locationTitle.snp.bottom).offset(5) $0.leading.equalTo(locationTitle.snp.leading) diff --git a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Contracts/AddGeofenceContracts.swift b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Contracts/AddGeofenceContracts.swift index cd8e199b..da217c7a 100644 --- a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Contracts/AddGeofenceContracts.swift +++ b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Contracts/AddGeofenceContracts.swift @@ -16,7 +16,7 @@ protocol AddGeofenceViewModelProcotol: AnyObject { func saveData(with id: String, lat: Double, long: Double, radius: Double) async throws -> Result func deleteData(with model: GeofenceDataModel) func searchWith(text: String, userLat: Double?, userLong: Double?) async throws - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async throws + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async throws func searchSelectedPlaceWith(_ indexPath: IndexPath, lat: Double?, long: Double?) async throws -> Bool func numberOfRowsInSection() -> Int func getSearchCellModel() -> [SearchCellViewModel] diff --git a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Controller/AddGeofenceVC.swift b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Controller/AddGeofenceVC.swift index 7dd69be1..23d245a4 100644 --- a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Controller/AddGeofenceVC.swift +++ b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Controller/AddGeofenceVC.swift @@ -186,7 +186,7 @@ final class AddGeofenceVC: UIViewController { searchView.searchTextValue = { [weak self] value in self?.changeElementVisibility(state: true) Task { - try await self?.viewModel.searchWithSuggesstion(text: value, + try await self?.viewModel.searchWithSuggestion(text: value, userLat: self?.userLocation?.lat, userLong: self?.userLocation?.long) } @@ -194,7 +194,7 @@ final class AddGeofenceVC: UIViewController { searchView.searchTextClose = {[weak self] in Task { - try await self?.viewModel.searchWithSuggesstion(text: "", + try await self?.viewModel.searchWithSuggestion(text: "", userLat: nil, userLong: nil) self?.changeElementVisibility(state: false) diff --git a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/ViewModel/AddGeofenceViewModel.swift b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/ViewModel/AddGeofenceViewModel.swift index 3ba06866..ac3cd66b 100644 --- a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/ViewModel/AddGeofenceViewModel.swift +++ b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/ViewModel/AddGeofenceViewModel.swift @@ -78,7 +78,7 @@ final class AddGeofenceViewModel: AddGeofenceViewModelProcotol { } - func searchWithSuggesstion(text: String, userLat: Double?, userLong: Double?) async throws { + func searchWithSuggestion(text: String, userLat: Double?, userLong: Double?) async throws { guard !text.isEmpty else { self.delegate?.searchResult(mapModel: []) return diff --git a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Views/AddGeofenceSearchView.swift b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Views/AddGeofenceSearchView.swift index d7d53983..d8bea9ba 100644 --- a/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Views/AddGeofenceSearchView.swift +++ b/LocationServices/LocationServices/Scenes/Geofence/SubViews/AddGeofence/Views/AddGeofenceSearchView.swift @@ -85,7 +85,7 @@ final class AddGeofenceSearchView: UIView { @objc private func geofenceRadiusDragged(_ notification: Notification){ let radius = notification.userInfo?["radius"] as! Double radiusSlider.value = Float(radius) - radiusSliderValue.text = Int(radius).convertToKm() + radiusSliderValue.text = Int(radius).fromatToKmString() radiusValueHander?(radius) } @@ -119,8 +119,8 @@ final class AddGeofenceSearchView: UIView { if let radius = model.radius { self?.radiusSlider.value = Float(radius) - self?.radiusSliderValue.text = radius.convertToKm() - } + self?.radiusSliderValue.text = radius.fromatToKmString() + } } } @@ -183,7 +183,7 @@ final class AddGeofenceSearchView: UIView { extension AddGeofenceSearchView { @objc func radiusSliderValuChanged(sender: UISlider) { let value = Double(radiusSlider.value) - self.radiusSliderValue.text = value.convertToKm() + self.radiusSliderValue.text = value.fromatToKmString() radiusValueHander?(value) } diff --git a/LocationServices/LocationServices/Services/LocationSearchService.swift b/LocationServices/LocationServices/Services/LocationSearchService.swift index 0cfdbc72..aeafacb2 100755 --- a/LocationServices/LocationServices/Services/LocationSearchService.swift +++ b/LocationServices/LocationServices/Services/LocationSearchService.swift @@ -14,7 +14,7 @@ enum LocationServiceConstant { protocol AWSLocationSearchService { func searchTextRequest(text: String, userLat: Double?, userLong: Double?) async throws -> SearchPlaceIndexForTextOutput? - func searchTextWithSuggesstionRequest(text: String, + func searchTextWithSuggestionRequest(text: String, userLat: Double?, userLong: Double?) async throws -> SearchPlaceIndexForSuggestionsOutput? func getPlaceRequest(with placeId: String) async throws -> GetPlaceOutput? @@ -41,7 +41,7 @@ extension AWSLocationSearchService { } } - func searchTextWithSuggesstionRequest(text: String, + func searchTextWithSuggestionRequest(text: String, userLat: Double?, userLong: Double?) async throws -> SearchPlaceIndexForSuggestionsOutput? { var biasPosition: [Double]? = nil diff --git a/LocationServices/LocationServices/Views/Common/POICardView.swift b/LocationServices/LocationServices/Views/Common/POICardView.swift index 74c4281d..1dc0f3b5 100755 --- a/LocationServices/LocationServices/Views/Common/POICardView.swift +++ b/LocationServices/LocationServices/Views/Common/POICardView.swift @@ -31,7 +31,7 @@ final class POICardView: UIView { if let distance = dataModel.distance, distance != 0 { self.distanceLabel.isHidden = false self.dotView.isHidden = false - self.distanceLabel.text = distance.convertToKm() + self.distanceLabel.text = distance.fromatToKmString() } else { self.dotView.isHidden = true self.distanceLabel.isHidden = true diff --git a/LocationServices/LocationServicesTests/AddGeofenceViewModelTests.swift b/LocationServices/LocationServicesTests/AddGeofenceViewModelTests.swift index 5a6d249f..5debfea1 100644 --- a/LocationServices/LocationServicesTests/AddGeofenceViewModelTests.swift +++ b/LocationServices/LocationServicesTests/AddGeofenceViewModelTests.swift @@ -225,28 +225,28 @@ final class AddGeofenceViewModelTests: XCTestCase { } } - func testSearchWithSuggesstionWithEmptyText() async throws { + func testSearchWithSuggestionWithEmptyText() async throws { setupViewModel(with: [Constants.testGeofenceModel]) locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = try await viewModel.searchWithSuggesstion(text: "", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult false") } - func testSearchWithSuggesstion() async throws { + func testSearchWithSuggestion() async throws { setupViewModel(with: [Constants.testGeofenceModel]) locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") } - func testSearchWithSuggesstionWithCoordinates() async throws { + func testSearchWithSuggestionWithCoordinates() async throws { setupViewModel(with: [Constants.testGeofenceModel]) locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = try await viewModel.searchWithSuggesstion(text: "40.7487776237092, -73.98554260340953", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "40.7487776237092, -73.98554260340953", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -284,7 +284,7 @@ final class AddGeofenceViewModelTests: XCTestCase { func testGetSearchCellModelWithResults() async throws { setupViewModel(with: [Constants.testGeofenceModel]) locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -294,7 +294,7 @@ final class AddGeofenceViewModelTests: XCTestCase { func testNumberOfRowsInSection() async throws { setupViewModel(with: [Constants.testGeofenceModel]) locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -306,7 +306,7 @@ final class AddGeofenceViewModelTests: XCTestCase { locationService.mockSearchTextResult = .success([search]) locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockGetPlaceResult = .success(search) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -330,7 +330,7 @@ final class AddGeofenceViewModelTests: XCTestCase { setupViewModel(with: [model]) locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockGetPlaceResult = .success(search) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -354,7 +354,7 @@ final class AddGeofenceViewModelTests: XCTestCase { setupViewModel(with: [model]) locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockGetPlaceResult = .success(search) - _ = try await viewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = try await viewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.viewModelDelegate.searchResultCalled }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") diff --git a/LocationServices/LocationServicesTests/DirectionViewModelTests.swift b/LocationServices/LocationServicesTests/DirectionViewModelTests.swift index 66f4a673..8c01ff16 100644 --- a/LocationServices/LocationServicesTests/DirectionViewModelTests.swift +++ b/LocationServices/LocationServicesTests/DirectionViewModelTests.swift @@ -83,28 +83,28 @@ final class DirectionViewModelTests: XCTestCase { XCTAssertEqual(directionViewModel.getSearchCellModel().first?.placeId, nil, "Expected location nil ") } - func testSearchWithSuggesstionWithTextMyLocation() async throws { + func testSearchWithSuggestionWithTextMyLocation() async throws { locationService.mockSearchTextResult = .success([search]) - await directionViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + await directionViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") } - func testSearchWithSuggesstionWithTextFailure() async throws { + func testSearchWithSuggestionWithTextFailure() async throws { locationService.mockSearchTextWithSuggestionResult = .failure(Constants.defaultError) - await directionViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + await directionViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return !self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult false") } - func testSearchWithSuggesstionWithCoordinates() async throws { + func testSearchWithSuggestionWithCoordinates() async throws { locationService.mockSearchWithPositionResult = .failure(Constants.defaultError) locationService.mockSearchWithPositionResult = .failure(Constants.defaultError) - await directionViewModel.searchWithSuggesstion(text: "40.759211, -73.984638", userLat: userLocation.lat, userLong: userLocation.long) + await directionViewModel.searchWithSuggestion(text: "40.759211, -73.984638", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return !self.delegate.hasSearchResult @@ -120,18 +120,9 @@ final class DirectionViewModelTests: XCTestCase { }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") } -// func testSearchWithTextFailure() async throws { -// locationService.mockSearchTextResult = .failure(Constants.defaultError) -// try await directionViewModel.searchWith(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) -// -// XCTWaiter().wait(until: { -// return !self.delegate.hasSearchResult -// }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult false") -// } - func testNumberOfRowsInSection() async throws { locationService.mockSearchTextWithSuggestionResult = .success([search]) - _ = await directionViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) + _ = await directionViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.lat, userLong: userLocation.long) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") diff --git a/LocationServices/LocationServicesTests/DoubleExtensionTests.swift b/LocationServices/LocationServicesTests/DoubleExtensionTests.swift index a3220c57..adc7b156 100644 --- a/LocationServices/LocationServicesTests/DoubleExtensionTests.swift +++ b/LocationServices/LocationServicesTests/DoubleExtensionTests.swift @@ -25,12 +25,12 @@ final class DoubleExtensionTests: XCTestCase { func testConvertKMToM() throws { let km: Double = 1 - XCTAssertEqual(km.convertKMToM(), 1000, "Expected 1000 M") + XCTAssertEqual(km.convertKMToMeters(), 1000, "Expected 1000 M") } func testConvertFormattedKMString() throws { let km: Double = 1 - XCTAssertEqual(km.convertFormattedKMString(), "1000.0 m", "Expected formatted KM 1000.0 m string") + XCTAssertEqual(km.convertFormattedKMString(), "1.00 km", "Expected formatted KM 1 km string") } } diff --git a/LocationServices/LocationServicesTests/GeofenceViewModelTests.swift b/LocationServices/LocationServicesTests/GeofenceViewModelTests.swift index c9c30e3d..858ee0d6 100644 --- a/LocationServices/LocationServicesTests/GeofenceViewModelTests.swift +++ b/LocationServices/LocationServicesTests/GeofenceViewModelTests.swift @@ -100,6 +100,7 @@ final class GeofenceViewModelTests: XCTestCase { } func test_fetchListOfGeofences_signedOut() async throws { + delegate.models = nil UserDefaultsHelper.setAppState(state: .initial) await viewModel.fetchListOfGeofences() XCTAssertNil(delegate?.models) diff --git a/LocationServices/LocationServicesTests/IntExtensionTests.swift b/LocationServices/LocationServicesTests/IntExtensionTests.swift index d4a7050c..b989a437 100644 --- a/LocationServices/LocationServicesTests/IntExtensionTests.swift +++ b/LocationServices/LocationServicesTests/IntExtensionTests.swift @@ -20,21 +20,21 @@ final class IntExtensionTests: XCTestCase { func testConvertIntToM() throws { let km: Int = 1000 - XCTAssertEqual(km.convertToKm(), "1000.0 m", "Expected string km") + XCTAssertEqual(km.fromatToKmString(), "1000.0 m", "Expected string km") } func testConvertInt64ToM() throws { let km: Int64 = 1000 - XCTAssertEqual(km.convertToKm(), "1000.0 m", "Expected string km") + XCTAssertEqual(km.fromatToKmString(), "1000.0 m", "Expected string km") } func testConvertIntToKM() throws { let km: Int = 1001 - XCTAssertEqual(km.convertToKm(), "1.00 km", "Expected string km") + XCTAssertEqual(km.fromatToKmString(), "1.00 km", "Expected string km") } func testConvertInt64ToKM() throws { let km: Int64 = 1001 - XCTAssertEqual(km.convertToKm(), "1.00 km", "Expected string km") + XCTAssertEqual(km.fromatToKmString(), "1.00 km", "Expected string km") } } diff --git a/LocationServices/LocationServicesTests/NavigationVCViewModelTests.swift b/LocationServices/LocationServicesTests/NavigationVCViewModelTests.swift index 48389beb..14cc2673 100644 --- a/LocationServices/LocationServicesTests/NavigationVCViewModelTests.swift +++ b/LocationServices/LocationServicesTests/NavigationVCViewModelTests.swift @@ -67,7 +67,7 @@ final class NavigationVCViewModelTests: XCTestCase { navigationVCViewModel.update(steps: [steps], summaryData: (totalDistance: 0.7, totalDuration: 20)) - XCTAssertEqual(navigationVCViewModel.getSummaryData().totalDistance, "700.0 m", "Expected summary total distance 700.0 m") + XCTAssertEqual(navigationVCViewModel.getSummaryData().totalDistance, "700 m", "Expected summary total distance 700.0 m") } func testGetDataWithZeroSteps() throws { diff --git a/LocationServices/LocationServicesTests/SearchViewModelTests.swift b/LocationServices/LocationServicesTests/SearchViewModelTests.swift index 49832059..b03dbe69 100644 --- a/LocationServices/LocationServicesTests/SearchViewModelTests.swift +++ b/LocationServices/LocationServicesTests/SearchViewModelTests.swift @@ -44,10 +44,10 @@ final class SearchViewModelTests: XCTestCase { // Put teardown code here. This method is called after the invocation of each test method in the class. } - func testSearchWithSuggesstionWithCoordinatesFailure() async throws { + func testSearchWithSuggestionWithCoordinatesFailure() async throws { locationService.mockSearchWithPositionResult = .failure(Constants.defaultError) do { - try await searchViewModel.searchWithSuggesstion(text: "40.75790965683081, -73.98559624758715", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "40.75790965683081, -73.98559624758715", userLat: userLocation.latitude, userLong: userLocation.longitude) } catch { XCTAssertEqual(self.delegate.hasSearchResult, false, "Expected hasSearchResult false") @@ -57,18 +57,18 @@ final class SearchViewModelTests: XCTestCase { }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult false") } - func testSearchWithSuggesstionWithCoordinatesSuccess() async throws { + func testSearchWithSuggestionWithCoordinatesSuccess() async throws { locationService.mockSearchWithPositionResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "40.75790965683081, -73.98559624758715", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "40.75790965683081, -73.98559624758715", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") } - func testSearchWithSuggesstionWithTextSuccess() async throws { + func testSearchWithSuggestionWithTextSuccess() async throws { locationService.mockSearchTextResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult @@ -118,7 +118,7 @@ final class SearchViewModelTests: XCTestCase { func testNumberOfRowsInSection() async throws { locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockSearchTextResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -133,7 +133,7 @@ final class SearchViewModelTests: XCTestCase { locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockGetPlaceResult = .success(search) locationService.mockSearchTextResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -145,7 +145,7 @@ final class SearchViewModelTests: XCTestCase { locationService.mockGetPlaceResult = .success(search) locationService.mockSearchWithPositionResult = .success([search]) locationService.mockSearchTextResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -168,7 +168,7 @@ final class SearchViewModelTests: XCTestCase { name: nil) locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockSearchTextResult = .success([search]) - try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") @@ -191,7 +191,7 @@ final class SearchViewModelTests: XCTestCase { locationService.mockGetPlaceResult = .success(search) locationService.mockSearchTextWithSuggestionResult = .success([search]) locationService.mockSearchTextResult = .success([search]) - _ = try await searchViewModel.searchWithSuggesstion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) + _ = try await searchViewModel.searchWithSuggestion(text: "Times Square", userLat: userLocation.latitude, userLong: userLocation.longitude) XCTWaiter().wait(until: { return self.delegate.hasSearchResult }, timeout: Constants.waitRequestDuration, message: "Expected hasSearchResult true") diff --git a/LocationServices/LocationServicesTests/TrackingViewModelTests.swift b/LocationServices/LocationServicesTests/TrackingViewModelTests.swift index 9c9ba600..48a0e093 100644 --- a/LocationServices/LocationServicesTests/TrackingViewModelTests.swift +++ b/LocationServices/LocationServicesTests/TrackingViewModelTests.swift @@ -22,19 +22,15 @@ final class TrackingViewModelTests: XCTestCase { static let updateGeofenceLatitude: Double = 15 static let updateGeofenceLongitude: Double = 20 - static let updateGeofenceRadius: Int = 30 + static let updateGeofenceRadius: Double = 30 static var geofence: GeofenceDataModel { return GeofenceDataModel(id: cityName, lat: geofenceLatitude, long: geofenceLongitude, radius: Double(geofenceRadius)) } -// static var trackingHistory: TrackingHistoryPresentation { -// return TrackingHistoryPresentation(model: AWSLocationDevicePosition , stepType: .first) -// } - static var updatedGeofence: GeofenceDataModel { - return GeofenceDataModel(id: cityName, lat: updateGeofenceLatitude, long: updateGeofenceLongitude, radius: Double(updateGeofenceRadius)) + return GeofenceDataModel(id: cityName, lat: updateGeofenceLatitude, long: updateGeofenceLongitude, radius: updateGeofenceRadius) } static let defaultError = NSError(domain: "Tracking error", code: -1) @@ -65,8 +61,6 @@ final class TrackingViewModelTests: XCTestCase { } func testTrackLocationUpdate() throws { - //apiTrackingService.mockUpdateTrackerLocationResult = .success(()) - //apiTrackingService.mockGetAllTrackingHistoryResult = .success([]) viewModel.startTracking() viewModel.trackLocationUpdate(location: CLLocation(latitude: userLocation.lat, longitude: userLocation.long)) XCTWaiter().wait(until: { [weak self] in @@ -86,7 +80,6 @@ final class TrackingViewModelTests: XCTestCase { func testFetchListOfGeofencesEmpty() async throws { UserDefaultsHelper.setAppState(state: .initial) - //apiGeofenceService.mockGetGeofenceListResult = .success([Constants.geofence]) await viewModel.fetchListOfGeofences() XCTWaiter().wait(until: { [weak self] in return self?.delegate.hasShownGeofences ?? false @@ -95,7 +88,6 @@ final class TrackingViewModelTests: XCTestCase { func testFetchListOfGeofences() async throws { UserDefaultsHelper.setAppState(state: .loggedIn) - //apiGeofenceService.mockGetGeofenceListResult = .success([Constants.geofence]) await viewModel.fetchListOfGeofences() XCTWaiter().wait(until: { [weak self] in return self?.delegate.hasShownGeofences ?? false @@ -112,7 +104,6 @@ final class TrackingViewModelTests: XCTestCase { } func testUpdateHistory() async throws { - //apiTrackingService.getResult = .success([]) await viewModel.updateHistory() XCTWaiter().wait(until: { [weak self] in return self?.delegate.hasHistoryLoaded ?? false diff --git a/LocationServices/LocationServicesUITests/SearchUITests.swift b/LocationServices/LocationServicesUITests/SearchUITests.swift index 22466856..9a767320 100644 --- a/LocationServices/LocationServicesUITests/SearchUITests.swift +++ b/LocationServices/LocationServicesUITests/SearchUITests.swift @@ -55,21 +55,6 @@ final class SearchUITests: LocationServicesUITests { .checkSearchBarInCorrectPosition() } -// func testSearchScreenStates() throws { -// //don't need this test for ipads -// guard UIDevice.current.userInterfaceIdiom == .phone else { return } -// let app = startApp() -// let _ = UITestExploreScreen(app: app) -// .tapSearchTextField() -// .waitForSearchRootView() -// .lightSwipeDownStateShouldBeChanged() -// .waitForSearchRootView() -// .lightSwipeDownStateShouldBeChanged() -// .waitForSearchRootView() -// .lightSwipeDownStateShouldBeChanged() -// .screenShouldBeClosed() -// } - func testSearch() throws { let app = startApp() let _ = UITestExploreScreen(app: app) @@ -87,85 +72,4 @@ final class SearchUITests: LocationServicesUITests { .type(text: Constants.category) .waitForResultsInTable() } - -// func testSearchWithAddressPoiCard() { -// var app = startApp(allowPermissions: true) -// -// let searchScreen = UITestExploreScreen(app: app) -// .tapSearchTextField() -// .waitForSearchRootView() -// .type(text: Constants.timesSquareAddress) -// .waitForResultsInTable() -// -// let searchResultsOnSearch = searchScreen.getCellsInfo() -// -// _ = searchScreen -// .validateResultsOnMap() -// .tapFirstCell() -// .waitForPoiCardView() -// .waitForPoiCicle() -// .waitForTravelTimeLabel() -// .waitForDirectionButton() -// .tapDirectionButton() -// .waitForRouteTypesContainer() -// -// app = restartApp() -// -// let routingScreen = UITestExploreScreen(app: app) -// .tapRouting() -// .selectDepartureTextField() -// .typeInDepartureTextField(text: Constants.addressName) -// .waitForResultsInTable(minimumCount: 2) -// -// let searchResultsOnRouting = routingScreen.getCellsInfo() -// -// XCTAssertEqual(searchResultsOnSearch, searchResultsOnRouting) -// } - -// func testSearchResultsOnMap() { -// let app = startApp(allowPermissions: true) -// -// let _ = UITestExploreScreen(app: app) -// .tapSearchTextField() -// .waitForSearchRootView() -// .type(text: Constants.timesSquareAddress) -// .waitForResultsInTable() -// .validateResultsOnMap() -// } - -// func testNavigationSearch() { -// let app = startApp(allowPermissions: true) -// let searchScreen = UITestExploreScreen(app: app) -// .waitForMapToBeRendered() -// .tapSearchTextField() -// .waitForSearchRootView() -// .type(text: Constants.addressName) -// .waitForResultsInTable() -// -// let searchResultsOnSearch = searchScreen.getCellsInfo() -// -// let routingScreen = searchScreen -// .close() -// .tapRouting() -// .selectDepartureTextField() -// .typeInDepartureTextField(text: Constants.addressName) -// .waitForResultsInTable(minimumCount: 2) -// -// let searchResultsOnRouting = routingScreen.getCellsInfo() -// -// XCTAssertEqual(searchResultsOnSearch, searchResultsOnRouting) -// } - -// func testPoiCardDirectionButton() { -// let app = startApp(allowPermissions: true) -// -// let _ = UITestExploreScreen(app: app) -// .tapSearchTextField() -// .waitForSearchRootView() -// .type(text: Constants.timesSquareAddress) -// .tapFirstCell() -// .waitForPoiCardView() -// .tapDirectionButton() -// .waitForRouteTypesContainer() -// } }