Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix guidance views json parsing. #432

Merged
merged 2 commits into from
Jun 17, 2020
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Fixed an issue where decoding and reencoding a JSON-formatted response from the Mapbox Directions API would cause the `voiceLocale` property to be omitted from route objects. ([#424](https://github.com/mapbox/mapbox-directions-swift/pull/424))
* Added the `Route(legs:shape:distance:expectedTravelTime:)` and `Route(from:)` initializers. ([#430](https://github.com/mapbox/mapbox-directions-swift/pull/430))
* Fixed an issue where `VisualInstruction.Component.guidanceView` lacked an image URL. ([#432](https://github.com/mapbox/mapbox-directions-swift/pull/432))

## v0.32.0

Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxDirections/VisualInstructionComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ extension VisualInstruction.Component: Codable {
case abbreviatedText = "abbr"
case abbreviatedTextPriority = "abbr_priority"
case imageBaseURL
case imageURL = "url"
case imageURL
1ec5 marked this conversation as resolved.
Show resolved Hide resolved
case directions
case isActive = "active"
}
Expand Down
8 changes: 7 additions & 1 deletion Tests/MapboxDirectionsTests/VisualInstructionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class VisualInstructionsTests: XCTestCase {
[
"text": "CA01610_1_E",
"type": "guidance-view",
"url": "https://www.mapbox.com/navigation"
"imageURL": "https://www.mapbox.com/navigation"
],
],
"type": "fork",
Expand All @@ -49,13 +49,19 @@ class VisualInstructionsTests: XCTestCase {
XCTAssertEqual(banner.primaryInstruction.maneuverDirection, .right)
XCTAssertNil(banner.secondaryInstruction)
XCTAssertNotNil(banner.quaternaryInstruction)
XCTAssertEqual(banner.quaternaryInstruction?.components.count, 1)
XCTAssertEqual(banner.drivingSide, .default)
}

let componentGuidanceViewImage = banner?.quaternaryInstruction?.components.first
XCTAssertNotNil(componentGuidanceViewImage)


let component = VisualInstruction.Component.text(text: .init(text: "Weinstock Strasse", abbreviation: nil, abbreviationPriority: nil))
let primaryInstruction = VisualInstruction(text: "Weinstock Strasse", maneuverType: .turn, maneuverDirection: .right, components: [component])

let guideViewComponent = VisualInstruction.Component.guidanceView(image: GuidanceViewImageRepresentation(imageURL: URL(string: "https://www.mapbox.com/navigation")), alternativeText: VisualInstruction.Component.TextRepresentation(text: "CA01610_1_E", abbreviation: nil, abbreviationPriority: nil))
XCTAssert(componentGuidanceViewImage == guideViewComponent)
let quaternaryInstruction = VisualInstruction(text: "CA01610_1_E", maneuverType: .reachFork, maneuverDirection: .right, components: [guideViewComponent])

banner = VisualInstructionBanner(distanceAlongStep: 393.3, primary: primaryInstruction, secondary: nil, tertiary: nil, quaternary: quaternaryInstruction, drivingSide: .right)
Expand Down