@@ -5,36 +5,22 @@ import MapboxDirections
5
5
import XCTest
6
6
7
7
extension Fixture {
8
- class func downloadRouteFixture( coordinates: [ CLLocationCoordinate2D ] , fileName: String , completion: @escaping ( ) -> Void ) {
9
- let accessToken = " <# Mapbox Access Token #> "
10
- let directions = Directions ( accessToken: accessToken)
11
-
12
- let options = RouteOptions ( coordinates: coordinates, profileIdentifier: . automobileAvoidingTraffic)
13
- options. includesSteps = true
14
- options. routeShapeResolution = . full
15
- let filePath = ( NSTemporaryDirectory ( ) as NSString ) . appendingPathComponent ( fileName)
16
-
17
- _ = directions. calculate ( options, completionHandler: { _, routes, _ in
18
- guard let route = routes? . first else { return }
19
-
20
- NSKeyedArchiver . archiveRootObject ( route, toFile: filePath)
21
- print ( " Route downloaded to \( filePath) " )
22
- completion ( )
23
- } )
24
- }
25
-
26
8
class var blankStyle : URL {
27
9
let path = Bundle . module. path ( forResource: " EmptyStyle " , ofType: " json " )
28
10
return URL ( fileURLWithPath: path!)
29
11
}
30
-
12
+
13
+ class func routeWithBannerInstructions( ) -> Route {
14
+ route ( from: " route-with-banner-instructions " , bundle: . module, waypoints: [ Waypoint ( coordinate: CLLocationCoordinate2D ( latitude: 37.795042 , longitude: - 122.413165 ) ) , Waypoint ( coordinate: CLLocationCoordinate2D ( latitude: 37.7727 , longitude: - 122.433378 ) ) ] )
15
+ }
16
+ }
17
+
18
+ // MARK: - Private
19
+
20
+ private extension Fixture {
31
21
class func route( from jsonFile: String , bundle: Bundle , waypoints: [ Waypoint ] ) -> Route {
32
22
let response = JSONFromFileNamed ( name: jsonFile, bundle: bundle)
33
23
let jsonRoute = ( response [ " routes " ] as! [ AnyObject ] ) . first as! [ String : Any ]
34
24
return Route ( json: jsonRoute, waypoints: waypoints, options: RouteOptions ( waypoints: waypoints) )
35
25
}
36
-
37
- class func routeWithBannerInstructions( ) -> Route {
38
- route ( from: " route-with-banner-instructions " , bundle: . module, waypoints: [ Waypoint ( coordinate: CLLocationCoordinate2D ( latitude: 37.795042 , longitude: - 122.413165 ) ) , Waypoint ( coordinate: CLLocationCoordinate2D ( latitude: 37.7727 , longitude: - 122.433378 ) ) ] )
39
- }
40
26
}
0 commit comments