提交 | 用户 | 时间
|
58d006
|
1 |
var map_with_routes, route, routes; |
A |
2 |
|
|
3 |
describe("Drawing a route", function() { |
|
4 |
beforeEach(function() { |
|
5 |
map_with_routes = map_with_routes || new GMaps({ |
|
6 |
el : '#map-with-routes', |
|
7 |
lat : -12.0433, |
|
8 |
lng : -77.0283, |
|
9 |
zoom : 12 |
|
10 |
}); |
|
11 |
}); |
|
12 |
|
|
13 |
it("should add a line in the current map", function() { |
|
14 |
var route_flag; |
|
15 |
|
|
16 |
runs(function() { |
|
17 |
route_flag = false; |
|
18 |
|
|
19 |
map_with_routes.drawRoute({ |
|
20 |
origin : [-12.044012922866312, -77.02470665341184], |
|
21 |
destination : [-12.090814532191756, -77.02271108990476], |
|
22 |
travelMode : 'driving', |
|
23 |
strokeColor : '#131540', |
|
24 |
strokeOpacity : 0.6, |
|
25 |
strokeWeight : 6, |
|
26 |
callback : function() { |
|
27 |
route_flag = true; |
|
28 |
} |
|
29 |
}); |
|
30 |
}); |
|
31 |
|
|
32 |
waitsFor(function() { |
|
33 |
return route_flag; |
|
34 |
}, "The drawn route should create a line in the current map", 3500); |
|
35 |
|
|
36 |
runs(function() { |
|
37 |
expect(map_with_routes.polylines.length).toEqual(1); |
|
38 |
expect(map_with_routes.polylines[0].get('strokeColor')).toEqual('#131540'); |
|
39 |
expect(map_with_routes.polylines[0].get('strokeOpacity')).toEqual(0.6); |
|
40 |
expect(map_with_routes.polylines[0].getMap()).toEqual(map_with_routes.map); |
|
41 |
}); |
|
42 |
}); |
|
43 |
}); |
|
44 |
|
|
45 |
describe("Getting routes", function() { |
|
46 |
beforeEach(function() { |
|
47 |
map_with_routes = map_with_routes || new GMaps({ |
|
48 |
el : '#map-with-routes', |
|
49 |
lat : -12.0433, |
|
50 |
lng : -77.0283, |
|
51 |
zoom : 12 |
|
52 |
}); |
|
53 |
}); |
|
54 |
|
|
55 |
it("should return an array of routes", function() { |
|
56 |
var routes, routes_flag; |
|
57 |
|
|
58 |
runs(function() { |
|
59 |
routes_flag = false; |
|
60 |
|
|
61 |
map_with_routes.getRoutes({ |
|
62 |
origin : "grand central station, new york, ny", |
|
63 |
destination : "350 5th Ave, New York, NY, 10118", |
|
64 |
callback : function(r) { |
|
65 |
routes = r; |
|
66 |
|
|
67 |
routes_flag = true; |
|
68 |
} |
|
69 |
}); |
|
70 |
}); |
|
71 |
|
|
72 |
waitsFor(function() { |
|
73 |
return routes_flag; |
|
74 |
}, "#getRoutes should return the found routes as an argument", 3500); |
|
75 |
|
|
76 |
runs(function() { |
|
77 |
expect(routes).toBeDefined(); |
|
78 |
expect(map_with_routes.routes).toEqual(routes); |
|
79 |
|
|
80 |
if (routes.length > 0) { |
|
81 |
expect(routes[0].legs[0].distance).toBeDefined(); |
|
82 |
expect(routes[0].legs[0].duration).toBeDefined(); |
|
83 |
} |
|
84 |
}); |
|
85 |
}); |
|
86 |
}); |