Skip to content

Commit

Permalink
Updated tests
Browse files Browse the repository at this point in the history
In the iOS 11 and macOS 10.13 SDKs, JSONSerialization adds an extra digit of precision. Also, in the macOS 10.13 SDK, the RGB components of NSColor’s class properties differ from those of UIColor’s similarly named class properties.
  • Loading branch information
1ec5 committed Nov 21, 2017
1 parent d280f4f commit 179016c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
19 changes: 15 additions & 4 deletions MapboxStaticTests/ClassicOverlayTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,14 @@ class ClassicOverlayTests: XCTestCase {
options.overlays = [markerOverlay]
options.scale = 1

let hexColor: String
#if os(macOS)
hexColor = "865226"
#else
hexColor = "996633"
#endif
stub(condition: isHost("api.mapbox.com")
&& isPath("/v4/mapbox.streets/pin-m-cafe+996633(-122.681944,45.52)/auto/200x200.png")
&& isPath("/v4/mapbox.streets/pin-m-cafe+\(hexColor)(-122.681944,45.52)/auto/200x200.png")
&& containsQueryParams(["access_token": BogusToken])) { request in
let path = Bundle(for: type(of: self)).path(forResource: "marker", ofType: "png")!
return fixture(filePath: path, headers: ["Content-Type": "image/png"])
Expand Down Expand Up @@ -96,7 +102,7 @@ class ClassicOverlayTests: XCTestCase {
options.overlays = [geoJSONOverlay]
options.scale = 1

let geoJSONString = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"stroke-width\":3,\"stroke-opacity\":1,\"stroke\":\"#00f\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.6978445053101,45.51863175803531],[-122.6909136772156,45.52165369248977],[-122.68630027771,45.51891742047702],[-122.6850986480713,45.51631633525551],[-122.6823306083679,45.51950377568216]]}}]}"
let geoJSONString = "{\"type\":\"FeatureCollection\",\"features\":[{\"type\":\"Feature\",\"properties\":{\"stroke-width\":3,\"stroke-opacity\":1,\"stroke\":\"#00f\"},\"geometry\":{\"type\":\"LineString\",\"coordinates\":[[-122.69784450531006,45.518631758035312],[-122.69091367721559,45.521653692489771],[-122.68630027770996,45.518917420477024],[-122.68509864807127,45.51631633525551],[-122.68233060836793,45.519503775682161]]}}]}"

stub(condition: isHost("api.mapbox.com")
&& isPath("/v4/mapbox.streets/geojson(\(geoJSONString))/auto/200x200.png")
Expand Down Expand Up @@ -140,10 +146,15 @@ class ClassicOverlayTests: XCTestCase {
options.overlays = [path]
options.scale = 1

let hexColor: String
#if os(macOS)
hexColor = "fb0006"
#else
hexColor = "ff0000"
#endif
let encodedPolyline = "upztG`jxkVn@al@bo@pFWzuAaTcAyZgn@"

stub(condition: isHost("api.mapbox.com")
&& isPath("/v4/mapbox.streets/path-2+000000-0.75+ff0000-0.25(\(encodedPolyline))/auto/200x200.png")
&& isPath("/v4/mapbox.streets/path-2+000000-0.75+\(hexColor)-0.25(\(encodedPolyline))/auto/200x200.png")
&& containsQueryParams(["access_token": BogusToken])) { request in
let path = Bundle(for: type(of: self)).path(forResource: "path", ofType: "png")!
return fixture(filePath: path, headers: ["Content-Type": "image/png"])
Expand Down
8 changes: 7 additions & 1 deletion MapboxStaticTests/ClassicSnapshotTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,14 @@ class ClassicSnapshotTests: XCTestCase {
options.color = .brown
options.scale = 1

let hexColor: String
#if os(macOS)
hexColor = "865226"
#else
hexColor = "996633"
#endif
stub(condition: isHost("api.mapbox.com")
&& isPath("/v4/marker/pin-m-cafe+996633.png")
&& isPath("/v4/marker/pin-m-cafe+\(hexColor).png")
&& containsQueryParams(["access_token": BogusToken])) { request in
let path = Bundle(for: type(of: self)).path(forResource: "cafe", ofType: "png")!
return fixture(filePath: path, headers: ["Content-Type": "image/png"])
Expand Down

0 comments on commit 179016c

Please sign in to comment.