-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix backwards incompatible associated value in shield implementation (#…
…647) * Fix backwards incompatible shield implementation. * Include PR in changelog. * Change code property back to text.
- Loading branch information
1 parent
40fa816
commit 6f41b5e
Showing
3 changed files
with
32 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,26 +40,25 @@ class VisualInstructionComponentTests: XCTestCase { | |
XCTAssertNotNil(component) | ||
if let component = component { | ||
switch component { | ||
case .image(let image, let alternativeText, let shield): | ||
case .image(let image, let alternativeText): | ||
XCTAssertEqual(image.imageBaseURL?.absoluteString, "https://s3.amazonaws.com/mapbox/shields/v3/i-95") | ||
XCTAssertEqual(image.imageURL(scale: 1, format: .svg)?.absoluteString, "https://s3.amazonaws.com/mapbox/shields/v3/[email protected]") | ||
XCTAssertEqual(image.imageURL(scale: 3, format: .svg)?.absoluteString, "https://s3.amazonaws.com/mapbox/shields/v3/[email protected]") | ||
XCTAssertEqual(image.imageURL(scale: 3, format: .png)?.absoluteString, "https://s3.amazonaws.com/mapbox/shields/v3/[email protected]") | ||
XCTAssertEqual(alternativeText.text, "I 95") | ||
XCTAssertNil(alternativeText.abbreviation) | ||
XCTAssertNil(alternativeText.abbreviationPriority) | ||
XCTAssertEqual(shield?.baseURL, URL(string: "https://api.mapbox.com/styles/v1/")!) | ||
XCTAssertEqual(shield?.name, "us-interstate") | ||
XCTAssertEqual(shield?.textColor, "white") | ||
XCTAssertEqual(shield?.text, "95") | ||
XCTAssertEqual(image.shield?.baseURL, URL(string: "https://api.mapbox.com/styles/v1/")!) | ||
XCTAssertEqual(image.shield?.name, "us-interstate") | ||
XCTAssertEqual(image.shield?.textColor, "white") | ||
XCTAssertEqual(image.shield?.text, "95") | ||
default: | ||
XCTFail("Image component should not be decoded as any other kind of component.") | ||
} | ||
} | ||
|
||
component = .image(image: .init(imageBaseURL: URL(string: "https://s3.amazonaws.com/mapbox/shields/v3/i-95")!), | ||
alternativeText: .init(text: "I 95", abbreviation: nil, abbreviationPriority: nil), | ||
shield: .init(baseURL: URL(string: "https://api.mapbox.com/styles/v1/")!, name: "us-interstate", textColor: "white", text: "95")) | ||
let shield = VisualInstruction.Component.ShieldRepresentation(baseURL: URL(string: "https://api.mapbox.com/styles/v1/")!, name: "us-interstate", textColor: "white", text: "95") | ||
component = .image(image: .init(imageBaseURL: URL(string: "https://s3.amazonaws.com/mapbox/shields/v3/i-95")!, shield: shield), | ||
alternativeText: .init(text: "I 95", abbreviation: nil, abbreviationPriority: nil)) | ||
let encoder = JSONEncoder() | ||
var encodedData: Data? | ||
XCTAssertNoThrow(encodedData = try encoder.encode(component)) | ||
|
@@ -126,23 +125,23 @@ class VisualInstructionComponentTests: XCTestCase { | |
XCTAssertNotNil(component) | ||
if let component = component { | ||
switch component { | ||
case .image(let image, let alternativeText, let shield): | ||
case .image(let image, let alternativeText): | ||
XCTAssertNil(image.imageBaseURL?.absoluteString) | ||
XCTAssertEqual(alternativeText.text, "I 95") | ||
XCTAssertNil(alternativeText.abbreviation) | ||
XCTAssertNil(alternativeText.abbreviationPriority) | ||
XCTAssertEqual(shield?.baseURL, URL(string: "https://api.mapbox.com/styles/v1/")!) | ||
XCTAssertEqual(shield?.name, "us-interstate") | ||
XCTAssertEqual(shield?.textColor, "white") | ||
XCTAssertEqual(shield?.text, "95") | ||
XCTAssertEqual(image.shield?.baseURL, URL(string: "https://api.mapbox.com/styles/v1/")!) | ||
XCTAssertEqual(image.shield?.name, "us-interstate") | ||
XCTAssertEqual(image.shield?.textColor, "white") | ||
XCTAssertEqual(image.shield?.text, "95") | ||
default: | ||
XCTFail("Image component should not be decoded as any other kind of component.") | ||
} | ||
} | ||
|
||
component = .image(image: .init(imageBaseURL: nil), | ||
alternativeText: .init(text: "I 95", abbreviation: nil, abbreviationPriority: nil), | ||
shield: .init(baseURL: URL(string: "https://api.mapbox.com/styles/v1/")!, name: "us-interstate", textColor: "white", text: "95")) | ||
let shield = VisualInstruction.Component.ShieldRepresentation(baseURL: URL(string: "https://api.mapbox.com/styles/v1/")!, name: "us-interstate", textColor: "white", text: "95") | ||
component = .image(image: .init(imageBaseURL: nil, shield: shield), | ||
alternativeText: .init(text: "I 95", abbreviation: nil, abbreviationPriority: nil)) | ||
let encoder = JSONEncoder() | ||
var encodedData: Data? | ||
XCTAssertNoThrow(encodedData = try encoder.encode(component)) | ||
|