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