Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion package/ios/GoogleMapsAPIKey.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum GoogleMapsAPIKey {
}
#endif

enum MapProviderConfigurationError: LocalizedError {
enum MapProviderConfigurationError: LocalizedError, CustomStringConvertible {
case missingGoogleMapsIosApiKey
case googleMapsSdkNotLinked
case unsupportedIOSProvider(MapProvider)
Expand All @@ -41,4 +41,8 @@ enum MapProviderConfigurationError: LocalizedError {
return "Map provider \"\(provider)\" is not supported on iOS."
}
}

var description: String {
errorDescription ?? "Map provider configuration failed."
}
}
32 changes: 32 additions & 0 deletions package/iosTests/MapProviderConfigurationErrorTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import XCTest

@testable import NitroMaps

final class MapProviderConfigurationErrorTests: XCTestCase {
func testMissingGoogleMapsAPIKeyUsesLocalizedDescription() {
let error = MapProviderConfigurationError.missingGoogleMapsIosApiKey

XCTAssertEqual(
String(describing: error),
"react-native-better-maps: provider=\"google\" on iOS requires GoogleMapsIosApiKey in the host app Info.plist."
)
XCTAssertEqual(String(describing: error), error.localizedDescription)
}

func testUnlinkedGoogleMapsSDKUsesLocalizedDescription() {
let error = MapProviderConfigurationError.googleMapsSdkNotLinked

XCTAssertEqual(
String(describing: error),
"react-native-better-maps: provider=\"google\" on iOS requires the Google Maps SDK to be linked. Configure iosGoogleMapsApiKey or googleMapsApiKey in the config plugin, or set betterMaps.iosGoogleProvider=true in Podfile.properties.json, then run pod install."
)
XCTAssertEqual(String(describing: error), error.localizedDescription)
}

func testUnsupportedProviderUsesLocalizedDescription() {
let error = MapProviderConfigurationError.unsupportedIOSProvider(.mapbox)

XCTAssertEqual(String(describing: error), "Map provider \"mapbox\" is not supported on iOS.")
XCTAssertEqual(String(describing: error), error.localizedDescription)
}
}