Skip to content

Commit

Permalink
make sure VisualInstructionTests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Jill Cardamon committed Mar 31, 2021
1 parent 8d410a3 commit 92880c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Sources/MapboxDirections/Intersection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ extension Intersection: Codable {
usableIndications.append(lane.validIndication!)
}
}
usableLaneIndication = usableIndications.reduce(temp) { return ($0).union($1) }
usableLaneIndication = usableIndications.reduce(temp) { return $0.union($1) }
} else {
approachLanes = nil
usableApproachLanes = nil
Expand Down
2 changes: 1 addition & 1 deletion Sources/MapboxDirections/VisualInstructionComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ extension VisualInstruction.Component: Codable {
textRepresentation = .init(text: "", abbreviation: nil, abbreviationPriority: nil)
try container.encode(indications, forKey: .directions)
try container.encode(isUsable, forKey: .isActive)
try container.encode(preferredDirection, forKey: .activeDirection)
try container.encodeIfPresent(preferredDirection, forKey: .activeDirection)
case .guidanceView(let image, let alternativeText):
try container.encode(Kind.guidanceView, forKey: .kind)
textRepresentation = alternativeText
Expand Down
6 changes: 4 additions & 2 deletions Tests/MapboxDirectionsTests/VisualInstructionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,15 @@ class VisualInstructionsTests: XCTestCase {
XCTAssertEqual(laneIndicationComponents?.count, 2)

if let laneIndicationComponents = laneIndicationComponents, laneIndicationComponents.count > 1 {
if case let VisualInstruction.Component.lane(indications, isUsable) = laneIndicationComponents[0] {
if case let VisualInstruction.Component.lane(indications, isUsable, preferredDirection) = laneIndicationComponents[0] {
XCTAssertEqual(indications, .straightAhead)
XCTAssertFalse(isUsable)
XCTAssertEqual(preferredDirection, nil)
}
if case let VisualInstruction.Component.lane(indications, isUsable) = laneIndicationComponents[1] {
if case let VisualInstruction.Component.lane(indications, isUsable, preferredDirection) = laneIndicationComponents[1] {
XCTAssertEqual(indications, .right)
XCTAssertTrue(isUsable)
XCTAssertEqual(preferredDirection, nil)
}
}
}
Expand Down

0 comments on commit 92880c5

Please sign in to comment.