Add frontend assets and plugin bundles
Add the legacy frontend themes, scripts, and plugin assets required by the main SPOTA interfaces.
This commit is contained in:
274
assets/plugins/gmaps/test/spec/EventSpec.js
Normal file
274
assets/plugins/gmaps/test/spec/EventSpec.js
Normal file
@@ -0,0 +1,274 @@
|
||||
describe("Creating event listeners", function() {
|
||||
var map_events, marker, line, polygon, callbacks_native, callbacks_gmaps;
|
||||
var added_marker, added_line, added_polygon;
|
||||
var marker_added_event, marker_removed_event,
|
||||
polyline_added_event, polyline_removed_event,
|
||||
polygon_added_event, polygon_removed_event;
|
||||
|
||||
beforeEach(function() {
|
||||
map_events = map_events || new GMaps({
|
||||
el : '#events',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
zoom : 12
|
||||
});
|
||||
|
||||
marker = marker || map_events.addMarker({
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
title : 'New marker'
|
||||
});
|
||||
|
||||
line = line || map_events.drawPolyline({
|
||||
path : [[-12.0440, -77.0247], [-12.0544, -77.0302], [-12.0551, -77.0303], [-12.0759, -77.0276], [-12.0763, -77.0279], [-12.0768, -77.0289], [-12.0885, -77.0241], [-12.0908, -77.0227]],
|
||||
strokeColor : '#131540',
|
||||
strokeOpacity : 0.6,
|
||||
strokeWeight : 6
|
||||
});
|
||||
|
||||
polygon = polygon || map_events.drawPolygon({
|
||||
paths : [[-12.0403,-77.0337],[-12.0402,-77.0399],[-12.0500,-77.0244],[-12.0448,-77.0215]],
|
||||
strokeColor : '#25D359',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#25D359',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
});
|
||||
|
||||
describe("for google.maps events", function() {
|
||||
beforeEach(function() {
|
||||
callbacks_native = callbacks_native || {
|
||||
map : {
|
||||
onclick : function() {
|
||||
console.log('callbacks_native.map.onclick');
|
||||
}
|
||||
},
|
||||
marker : {
|
||||
onclick : function() {
|
||||
console.log('callbacks_native.marker.onclick');
|
||||
}
|
||||
},
|
||||
line : {
|
||||
onclick : function() {
|
||||
console.log('callbacks_native.line.onclick');
|
||||
}
|
||||
},
|
||||
polygon : {
|
||||
onclick : function() {
|
||||
console.log('callbacks_native.polygon.onclick');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(callbacks_native.map, 'onclick').andCallThrough();
|
||||
spyOn(callbacks_native.marker, 'onclick').andCallThrough();
|
||||
spyOn(callbacks_native.line, 'onclick').andCallThrough();
|
||||
spyOn(callbacks_native.polygon, 'onclick').andCallThrough();
|
||||
});
|
||||
|
||||
describe("To a map", function() {
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
var click_event = GMaps.on('click', map_events.map, callbacks_native.map.onclick);
|
||||
|
||||
expect(map_events.map['__e3_']['click'][click_event['id']]).toBeDefined();
|
||||
expect(map_events.map['__e3_']['click'][click_event['id']]).toEqual(click_event);
|
||||
});
|
||||
});
|
||||
|
||||
describe("To a marker", function() {
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
var click_event = GMaps.on('click', marker, callbacks_native.marker.onclick);
|
||||
|
||||
expect(marker['__e3_']['click'][click_event['id']]).toBeDefined();
|
||||
expect(marker['__e3_']['click'][click_event['id']]).toEqual(click_event);
|
||||
});
|
||||
});
|
||||
|
||||
describe("To a line", function() {
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
var click_event = GMaps.on('click', line, callbacks_native.line.onclick);
|
||||
|
||||
expect(line['__e3_']['click'][click_event['id']]).toBeDefined();
|
||||
expect(line['__e3_']['click'][click_event['id']]).toEqual(click_event);
|
||||
});
|
||||
});
|
||||
|
||||
describe("To a polygon", function() {
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
var click_event = GMaps.on('click', polygon, callbacks_native.polygon.onclick);
|
||||
|
||||
expect(polygon['__e3_']['click'][click_event['id']]).toBeDefined();
|
||||
expect(polygon['__e3_']['click'][click_event['id']]).toEqual(click_event);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("for GMaps events", function() {
|
||||
beforeEach(function() {
|
||||
callbacks_gmaps = {
|
||||
marker_added : function() {
|
||||
console.log('callbacks_gmaps.marker_added called');
|
||||
},
|
||||
marker_removed : function() {
|
||||
console.log('callbacks_gmaps.marker_removed called');
|
||||
},
|
||||
polyline_added : function() {
|
||||
console.log('callbacks_gmaps.polyline_added called');
|
||||
},
|
||||
polyline_removed : function() {
|
||||
console.log('callbacks_gmaps.polyline_removed called');
|
||||
},
|
||||
polygon_added : function() {
|
||||
console.log('callbacks_gmaps.polygon_added called');
|
||||
},
|
||||
polygon_removed : function() {
|
||||
console.log('callbacks_gmaps.polygon_removed called');
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(callbacks_gmaps, 'marker_added').andCallThrough();
|
||||
spyOn(callbacks_gmaps, 'marker_removed').andCallThrough();
|
||||
spyOn(callbacks_gmaps, 'polyline_added').andCallThrough();
|
||||
spyOn(callbacks_gmaps, 'polyline_removed').andCallThrough();
|
||||
spyOn(callbacks_gmaps, 'polygon_added').andCallThrough();
|
||||
spyOn(callbacks_gmaps, 'polygon_removed').andCallThrough();
|
||||
});
|
||||
|
||||
describe("#marker_added", function() {
|
||||
beforeEach(function() {
|
||||
marker_added_event = GMaps.on('marker_added', map_events, callbacks_gmaps.marker_added);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['marker_added'][0]).toEqual(marker_added_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
added_marker = added_marker || map_events.addMarker({
|
||||
lat : -12.0433,
|
||||
lng : -77.0273,
|
||||
title : 'New marker'
|
||||
});
|
||||
|
||||
expect(callbacks_gmaps.marker_added).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('marker_added', map_events);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#marker_removed", function() {
|
||||
beforeEach(function() {
|
||||
marker_removed_event = GMaps.on('marker_removed', map_events, callbacks_gmaps.marker_removed);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['marker_removed'][0]).toEqual(marker_removed_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
map_events.removeMarker(added_marker);
|
||||
|
||||
expect(callbacks_gmaps.marker_removed).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('marker_removed', map_events);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#polyline_added", function() {
|
||||
beforeEach(function() {
|
||||
polyline_added_event = GMaps.on('polyline_added', map_events, callbacks_gmaps.polyline_added);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['polyline_added'][0]).toEqual(polyline_added_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
added_line = added_line || map_events.drawPolyline({
|
||||
path : [[-12.0420, -77.0247], [-12.0544, -77.0102], [-12.0751, -77.0903], [-12.0759, -77.0276], [-12.0763, -77.0279], [-12.0768, -77.0289], [-12.0885, -77.0241], [-12.0908, -77.0227]],
|
||||
strokeColor : '#271804',
|
||||
strokeOpacity : 0.1,
|
||||
strokeWeight : 1
|
||||
});
|
||||
|
||||
expect(callbacks_gmaps.polyline_added).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('polyline_added', map_events);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#polyline_removed", function() {
|
||||
beforeEach(function() {
|
||||
polyline_removed_event = GMaps.on('polyline_removed', map_events, callbacks_gmaps.polyline_removed);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['polyline_removed'][0]).toEqual(polyline_removed_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
map_events.removePolyline(added_line);
|
||||
|
||||
expect(callbacks_gmaps.polyline_removed).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('polyline_removed', map_events);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#polygon_added", function() {
|
||||
beforeEach(function() {
|
||||
polygon_added_event = GMaps.on('polygon_added', map_events, callbacks_gmaps.polygon_added);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['polygon_added'][0]).toEqual(polygon_added_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
added_polygon = added_polygon || map_events.drawPolygon({
|
||||
paths : [[-12.0203,-77.0137],[-12.0402,-77.0109],[-12.0500,-77.0144],[-12.0848,-77.0115]],
|
||||
strokeColor : '#D32559',
|
||||
strokeOpacity : 0.7,
|
||||
strokeWeight : 8,
|
||||
fillColor : '#D32559',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
|
||||
expect(callbacks_gmaps.polygon_added).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('polygon_added', map_events);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#polygon_removed", function() {
|
||||
beforeEach(function() {
|
||||
polygon_removed_event = GMaps.on('polygon_removed', map_events, callbacks_gmaps.polygon_removed);
|
||||
});
|
||||
|
||||
it("should add the listener to the listeners collection", function() {
|
||||
expect(map_events.registered_events['polygon_removed'][0]).toEqual(polygon_removed_event);
|
||||
});
|
||||
|
||||
it("should trigger the listener created", function() {
|
||||
map_events.removePolygon(added_polygon);
|
||||
|
||||
expect(callbacks_gmaps.polygon_removed).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
GMaps.off('polygon_removed', map_events);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
225
assets/plugins/gmaps/test/spec/GeometrySpec.js
Normal file
225
assets/plugins/gmaps/test/spec/GeometrySpec.js
Normal file
@@ -0,0 +1,225 @@
|
||||
describe("Drawing geometry overlays", function() {
|
||||
var map_with_polygons, line, rectangle, circle, polygon;
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_polygons = map_with_polygons || new GMaps({
|
||||
el : '#map-with-polygons',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
zoom : 12
|
||||
});
|
||||
});
|
||||
|
||||
describe("A line", function() {
|
||||
beforeEach(function() {
|
||||
line = line || map_with_polygons.drawPolyline({
|
||||
path : [[-12.0440, -77.0247], [-12.0544, -77.0302], [-12.0551, -77.0303], [-12.0759, -77.0276], [-12.0763, -77.0279], [-12.0768, -77.0289], [-12.0885, -77.0241], [-12.0908, -77.0227]],
|
||||
strokeColor : '#131540',
|
||||
strokeOpacity : 0.6,
|
||||
strokeWeight : 6
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the line to the polylines collection", function() {
|
||||
expect(map_with_polygons.polylines.length).toEqual(1);
|
||||
expect(map_with_polygons.polylines[0]).toEqual(line);
|
||||
});
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(line.getMap()).toEqual(map_with_polygons.map);
|
||||
});
|
||||
|
||||
it("should return the defined path", function() {
|
||||
var first_point = line.getPath().getAt(0);
|
||||
|
||||
expect(parseFloat(first_point.lat().toFixed(4))).toEqual(-12.0440);
|
||||
expect(parseFloat(first_point.lng().toFixed(4))).toEqual(-77.0247);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A rectangle", function() {
|
||||
beforeEach(function() {
|
||||
rectangle = rectangle || map_with_polygons.drawRectangle({
|
||||
bounds : [[-12.0303,-77.0237],[-12.0348,-77.0115]],
|
||||
strokeColor : '#BBD8E9',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#BBD8E9',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the rectangle to the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(1);
|
||||
expect(map_with_polygons.polygons[0]).toEqual(rectangle);
|
||||
});
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(rectangle.getMap()).toEqual(map_with_polygons.map);
|
||||
});
|
||||
|
||||
it("should have the defined bounds", function() {
|
||||
// Fix for floating-point bug
|
||||
var SWLat = parseFloat(rectangle.getBounds().getSouthWest().lat().toFixed(4));
|
||||
var SWLng = parseFloat(rectangle.getBounds().getSouthWest().lng().toFixed(4));
|
||||
|
||||
var NELat = parseFloat(rectangle.getBounds().getNorthEast().lat().toFixed(4));
|
||||
var NELng = parseFloat(rectangle.getBounds().getNorthEast().lng().toFixed(4));
|
||||
|
||||
expect(SWLat).toEqual(-12.0303);
|
||||
expect(SWLng).toEqual(-77.0237);
|
||||
expect(NELat).toEqual(-12.0348);
|
||||
expect(NELng).toEqual(-77.0115);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A polygon", function() {
|
||||
beforeEach(function() {
|
||||
polygon = polygon || map_with_polygons.drawPolygon({
|
||||
paths : [[-12.0403,-77.0337],[-12.0402,-77.0399],[-12.0500,-77.0244],[-12.0448,-77.0215]],
|
||||
strokeColor : '#25D359',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#25D359',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the polygon to the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(2);
|
||||
expect(map_with_polygons.polygons[1]).toEqual(polygon);
|
||||
});
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(polygon.getMap()).toEqual(map_with_polygons.map);
|
||||
});
|
||||
|
||||
it("should return the defined path", function() {
|
||||
var first_point = polygon.getPath().getAt(0);
|
||||
|
||||
expect(parseFloat(first_point.lat().toFixed(4))).toEqual(-12.0403);
|
||||
expect(parseFloat(first_point.lng().toFixed(4))).toEqual(-77.0337);
|
||||
});
|
||||
});
|
||||
|
||||
describe("A circle", function() {
|
||||
beforeEach(function() {
|
||||
circle = circle || map_with_polygons.drawCircle({
|
||||
lat : -12.040504866577001,
|
||||
lng : -77.02024422636042,
|
||||
radius : 350,
|
||||
strokeColor : '#432070',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#432070',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the circle to the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(3);
|
||||
expect(map_with_polygons.polygons[2]).toEqual(circle);
|
||||
});
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(circle.getMap()).toEqual(map_with_polygons.map);
|
||||
});
|
||||
|
||||
it("should have the defined radius", function() {
|
||||
expect(circle.getRadius()).toEqual(350);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("Removing geometry overlays", function() {
|
||||
var map_with_polygons, line, rectangle, circle, polygon;
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_polygons = map_with_polygons || new GMaps({
|
||||
el : '#map-with-polygons',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
zoom : 12
|
||||
});
|
||||
});
|
||||
|
||||
describe("A line", function() {
|
||||
beforeEach(function() {
|
||||
line = map_with_polygons.drawPolyline({
|
||||
path : [[-12.0440, -77.0247], [-12.0544, -77.0302], [-12.0551, -77.0303], [-12.0759, -77.0276], [-12.0763, -77.0279], [-12.0768, -77.0289], [-12.0885, -77.0241], [-12.0908, -77.0227]],
|
||||
strokeColor : '#131540',
|
||||
strokeOpacity : 0.6,
|
||||
strokeWeight : 6
|
||||
});
|
||||
|
||||
map_with_polygons.removePolyline(line);
|
||||
});
|
||||
|
||||
it("should remove the line from the polylines collection", function() {
|
||||
expect(map_with_polygons.polylines.length).toEqual(0);
|
||||
expect(line.getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("A rectangle", function() {
|
||||
beforeEach(function() {
|
||||
rectangle = map_with_polygons.drawRectangle({
|
||||
bounds : [[-12.0303,-77.0237],[-12.0348,-77.0115]],
|
||||
strokeColor : '#BBD8E9',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#BBD8E9',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
|
||||
map_with_polygons.removePolygon(rectangle);
|
||||
});
|
||||
|
||||
it("should remove the rectangle from the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(0);
|
||||
expect(rectangle.getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("A polygon", function() {
|
||||
beforeEach(function() {
|
||||
polygon = map_with_polygons.drawPolygon({
|
||||
paths : [[-12.0403,-77.0337],[-12.0402,-77.0399],[-12.0500,-77.0244],[-12.0448,-77.0215]],
|
||||
strokeColor : '#25D359',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#25D359',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
|
||||
map_with_polygons.removePolygon(polygon);
|
||||
});
|
||||
|
||||
it("should remove the polygon from the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(0);
|
||||
expect(polygon.getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("A circle", function() {
|
||||
beforeEach(function() {
|
||||
circle = map_with_polygons.drawCircle({
|
||||
lat : -12.040504866577001,
|
||||
lng : -77.02024422636042,
|
||||
radius : 350,
|
||||
strokeColor : '#432070',
|
||||
strokeOpacity : 1,
|
||||
strokeWeight : 3,
|
||||
fillColor : '#432070',
|
||||
fillOpacity : 0.6
|
||||
});
|
||||
|
||||
map_with_polygons.removePolygon(circle);
|
||||
});
|
||||
|
||||
it("should remove the circle from the polygons collection", function() {
|
||||
expect(map_with_polygons.polygons.length).toEqual(0);
|
||||
expect(circle.getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
50
assets/plugins/gmaps/test/spec/LayerSpec.js
Normal file
50
assets/plugins/gmaps/test/spec/LayerSpec.js
Normal file
@@ -0,0 +1,50 @@
|
||||
describe("Adding layers", function() {
|
||||
var map_with_layers, single_layer, multiple_layers = [];
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_layers = map_with_layers || new GMaps({
|
||||
el : '#map-with-layers',
|
||||
lat: -12.0433,
|
||||
lng: -77.0283,
|
||||
zoom: 12
|
||||
});
|
||||
});
|
||||
|
||||
describe("Single layer", function() {
|
||||
beforeEach(function() {
|
||||
single_layer = single_layer || map_with_layers.addLayer('traffic');
|
||||
})
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(single_layer.getMap()).toEqual(map_with_layers.map);
|
||||
});
|
||||
|
||||
it("should be removed from the current map", function() {
|
||||
map_with_layers.removeLayer('traffic');
|
||||
|
||||
expect(single_layer.getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Multiple layers", function() {
|
||||
beforeEach(function() {
|
||||
if (multiple_layers.length == 0) {
|
||||
multiple_layers.push(map_with_layers.addLayer('transit'));
|
||||
multiple_layers.push(map_with_layers.addLayer('bicycling'));
|
||||
}
|
||||
});
|
||||
|
||||
it("should be added in the current map", function() {
|
||||
expect(multiple_layers[0].getMap()).toEqual(map_with_layers.map);
|
||||
expect(multiple_layers[1].getMap()).toEqual(map_with_layers.map);
|
||||
});
|
||||
|
||||
it("should be removed from the current map", function() {
|
||||
map_with_layers.removeLayer('transit');
|
||||
map_with_layers.removeLayer('bicycling');
|
||||
|
||||
expect(multiple_layers[0].getMap()).toBeNull();
|
||||
expect(multiple_layers[1].getMap()).toBeNull();
|
||||
});
|
||||
});
|
||||
});
|
||||
178
assets/plugins/gmaps/test/spec/MapSpec.js
Normal file
178
assets/plugins/gmaps/test/spec/MapSpec.js
Normal file
@@ -0,0 +1,178 @@
|
||||
describe("Creating a map", function() {
|
||||
var basic_map, advanced_map, map_with_events, map_with_custom_controls;
|
||||
|
||||
it("should throw an error if element is not defined", function() {
|
||||
expect(function() { new GMaps({}); }).toThrow(new Error('No element defined.'));
|
||||
});
|
||||
|
||||
describe("With basic options", function() {
|
||||
beforeEach(function() {
|
||||
basic_map = basic_map || new GMaps({
|
||||
el : '#basic-map',
|
||||
lat: -12.0433,
|
||||
lng: -77.0283,
|
||||
zoom: 12
|
||||
});
|
||||
});
|
||||
|
||||
it("should create a GMaps object", function() {
|
||||
expect(basic_map).toBeDefined();
|
||||
});
|
||||
|
||||
it("should have centered the map at the initial coordinates", function() {
|
||||
var lat = basic_map.getCenter().lat();
|
||||
var lng = basic_map.getCenter().lng();
|
||||
|
||||
expect(lat).toEqual(-12.0433);
|
||||
expect(lng).toEqual(-77.0283);
|
||||
});
|
||||
|
||||
it("should have the correct zoom", function() {
|
||||
expect(basic_map.getZoom()).toEqual(12);
|
||||
});
|
||||
});
|
||||
|
||||
describe("With advanced controls", function() {
|
||||
beforeEach(function() {
|
||||
advanced_map = advanced_map || new GMaps({
|
||||
el : '#advanced-map',
|
||||
lat: -12.0433,
|
||||
lng: -77.0283,
|
||||
zoomControl : true,
|
||||
panControl : false,
|
||||
streetViewControl : false,
|
||||
mapTypeControl: false,
|
||||
overviewMapControl: false
|
||||
});
|
||||
});
|
||||
|
||||
it("should show the defined controls", function() {
|
||||
expect(advanced_map.map.zoomControl).toBeTruthy();
|
||||
expect(advanced_map.map.panControl).toBeFalsy();
|
||||
expect(advanced_map.map.streetViewControl).toBeFalsy();
|
||||
expect(advanced_map.map.mapTypeControl).toBeFalsy();
|
||||
expect(advanced_map.map.overviewMapControl).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe("With events", function() {
|
||||
var callbacks, current_zoom = 0, current_center = null;
|
||||
|
||||
beforeEach(function() {
|
||||
callbacks = {
|
||||
onclick : function(e) {
|
||||
var lat = e.latLng.lat();
|
||||
var lng = e.latLng.lng();
|
||||
|
||||
map_with_events.addMarker({
|
||||
lat : lat,
|
||||
lng : lng,
|
||||
title : 'New Marker'
|
||||
});
|
||||
},
|
||||
onzoomchanged : function() {
|
||||
console.log('onzoomchanged');
|
||||
current_zoom = this.getZoom();
|
||||
},
|
||||
oncenterchanged : function() {
|
||||
console.log('oncenterchanged');
|
||||
current_center = this.getCenter();
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(callbacks, 'onclick').andCallThrough();
|
||||
spyOn(callbacks, 'onzoomchanged').andCallThrough();
|
||||
spyOn(callbacks, 'oncenterchanged').andCallThrough();
|
||||
|
||||
map_with_events = map_with_events || new GMaps({
|
||||
el : '#map-with-events',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
click : callbacks.onclick,
|
||||
zoom_changed : callbacks.onzoomchanged,
|
||||
center_changed : callbacks.oncenterchanged
|
||||
});
|
||||
});
|
||||
|
||||
it("should respond to zoom_changed event", function() {
|
||||
map_with_events.map.setZoom(16);
|
||||
|
||||
expect(callbacks.onzoomchanged).toHaveBeenCalled();
|
||||
expect(current_zoom).toEqual(16);
|
||||
});
|
||||
|
||||
it("should respond to center_changed event", function() {
|
||||
map_with_events.map.setCenter(new google.maps.LatLng(-12.0907, -77.0227));
|
||||
|
||||
// Fix for floating-point bug
|
||||
var lat = parseFloat(current_center.lat().toFixed(4));
|
||||
var lng = parseFloat(current_center.lng().toFixed(4));
|
||||
|
||||
expect(callbacks.oncenterchanged).toHaveBeenCalled();
|
||||
expect(lat).toEqual(-12.0907);
|
||||
expect(lng).toEqual(-77.0227);
|
||||
});
|
||||
|
||||
it("should respond to click event", function() {
|
||||
google.maps.event.trigger(map_with_events.map, 'click', {
|
||||
latLng : new google.maps.LatLng(-12.0433, -77.0283)
|
||||
});
|
||||
|
||||
expect(callbacks.onclick).toHaveBeenCalled();
|
||||
expect(map_with_events.markers.length).toEqual(1);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
document.getElementById('map-with-events').innerHTML = '';
|
||||
map_with_events = null;
|
||||
});
|
||||
});
|
||||
|
||||
describe("With custom controls", function() {
|
||||
var callbacks, markers_in_map = 0;
|
||||
|
||||
beforeEach(function() {
|
||||
callbacks = {
|
||||
onclick : function() {
|
||||
map_with_custom_controls.addMarker({
|
||||
lat : map_with_custom_controls.getCenter().lat(),
|
||||
lng : map_with_custom_controls.getCenter().lng()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
spyOn(callbacks, 'onclick').andCallThrough();
|
||||
|
||||
map_with_custom_controls = new GMaps({
|
||||
el : '#map-with-custom-controls',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283
|
||||
});
|
||||
|
||||
map_with_custom_controls.addControl({
|
||||
position : 'top_right',
|
||||
content : 'Add marker at the center',
|
||||
style : {
|
||||
margin: '5px',
|
||||
padding: '1px 6px',
|
||||
border: 'solid 1px #717B87',
|
||||
background: '#fff'
|
||||
},
|
||||
events : {
|
||||
click: callbacks.onclick
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the control to the controls collection", function() {
|
||||
expect(map_with_custom_controls.controls.length).toEqual(1);
|
||||
});
|
||||
|
||||
it("should respond to click event attached to the custom control", function() {
|
||||
google.maps.event.trigger(map_with_custom_controls.controls[0], 'click');
|
||||
|
||||
expect(callbacks.onclick).toHaveBeenCalled();
|
||||
expect(map_with_custom_controls.markers.length).toEqual(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
60
assets/plugins/gmaps/test/spec/MarkerSpec.js
Normal file
60
assets/plugins/gmaps/test/spec/MarkerSpec.js
Normal file
@@ -0,0 +1,60 @@
|
||||
describe("Creating a marker", function() {
|
||||
var map, marker;
|
||||
|
||||
beforeEach(function() {
|
||||
map = map || new GMaps({
|
||||
el : '#map-with-markers',
|
||||
lat : -12.0533,
|
||||
lng: -77.0293,
|
||||
zoom: 14
|
||||
});
|
||||
});
|
||||
|
||||
describe("With basic options", function() {
|
||||
beforeEach(function() {
|
||||
marker = map.addMarker({
|
||||
lat : -12.0533,
|
||||
lng: -77.0293,
|
||||
title : 'New marker'
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the marker to the markers collection", function() {
|
||||
expect(map.markers.length).toEqual(1);
|
||||
expect(map.markers[0]).toEqual(marker);
|
||||
});
|
||||
|
||||
it("should create a marker with defined position", function() {
|
||||
// Fix for floating-point bug
|
||||
expect(parseFloat(marker.getPosition().lat().toFixed(4))).toEqual(-12.0533);
|
||||
expect(parseFloat(marker.getPosition().lng().toFixed(4))).toEqual(-77.0293);
|
||||
});
|
||||
});
|
||||
|
||||
describe("With events", function() {
|
||||
var callbacks;
|
||||
|
||||
beforeEach(function() {
|
||||
callbacks = {
|
||||
onclick : function() {
|
||||
console.log(this.title);
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(callbacks, 'onclick').andCallThrough();
|
||||
|
||||
marker = map.addMarker({
|
||||
lat : -12.0533,
|
||||
lng: -77.0193,
|
||||
title : 'New marker',
|
||||
click : callbacks.onclick
|
||||
});
|
||||
});
|
||||
|
||||
it("should respond to click event", function() {
|
||||
google.maps.event.trigger(marker, 'click');
|
||||
|
||||
expect(callbacks.onclick).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
30
assets/plugins/gmaps/test/spec/OverlaySpec.js
Normal file
30
assets/plugins/gmaps/test/spec/OverlaySpec.js
Normal file
@@ -0,0 +1,30 @@
|
||||
describe("Drawing HTML overlays", function() {
|
||||
var map_with_overlays, overlay;
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_overlays = map_with_overlays || new GMaps({
|
||||
el : '#map-with-overlays',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
zoom : 12
|
||||
});
|
||||
|
||||
overlay = overlay || map_with_overlays.drawOverlay({
|
||||
lat: map_with_overlays.getCenter().lat(),
|
||||
lng: map_with_overlays.getCenter().lng(),
|
||||
layer: 'overlayLayer',
|
||||
content: '<div class="overlay">Lima</div>',
|
||||
verticalAlign: 'top',
|
||||
horizontalAlign: 'center'
|
||||
});
|
||||
});
|
||||
|
||||
it("should add the overlay to the overlays collection", function() {
|
||||
expect(map_with_overlays.overlays.length).toEqual(1);
|
||||
expect(map_with_overlays.overlays[0]).toEqual(overlay);
|
||||
});
|
||||
|
||||
it("should add the overlay in the current map", function() {
|
||||
expect(overlay.getMap()).toEqual(map_with_overlays.map);
|
||||
});
|
||||
});
|
||||
86
assets/plugins/gmaps/test/spec/RouteSpec.js
Normal file
86
assets/plugins/gmaps/test/spec/RouteSpec.js
Normal file
@@ -0,0 +1,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", 500);
|
||||
|
||||
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_flag;
|
||||
|
||||
runs(function() {
|
||||
routes_flag = false;
|
||||
|
||||
map_with_routes.getRoutes({
|
||||
origin : [-12.0440, -77.0247],
|
||||
destination : [-12.0908, -77.0227],
|
||||
callback : function(r) {
|
||||
routes = r;
|
||||
|
||||
routes_flag = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return routes_flag;
|
||||
}, "#getRoutes should return the found routes as an argument", 500);
|
||||
|
||||
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();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
84
assets/plugins/gmaps/test/spec/StreetViewSpec.js
Normal file
84
assets/plugins/gmaps/test/spec/StreetViewSpec.js
Normal file
@@ -0,0 +1,84 @@
|
||||
describe("Create a Street View Panorama", function() {
|
||||
var map_with_streetview, attached_panorama, standalone_panorama, panorama_with_events;
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_streetview = map_with_streetview || new GMaps({
|
||||
el : '#map-with-streetview',
|
||||
lat : 42.3455,
|
||||
lng : -71.0983,
|
||||
zoom : 12
|
||||
});
|
||||
});
|
||||
|
||||
describe("Standalone", function() {
|
||||
beforeEach(function() {
|
||||
standalone_panorama = standalone_panorama || GMaps.createPanorama({
|
||||
el : '#streetview-standalone-panorama',
|
||||
lat : 42.3455,
|
||||
lng : -71.0983,
|
||||
pov : {
|
||||
heading : 60,
|
||||
pitch : -10,
|
||||
zoom : 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should create a Street View panorama", function() {
|
||||
expect(standalone_panorama).toBeDefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Attached to the current map", function() {
|
||||
beforeEach(function() {
|
||||
attached_panorama = attached_panorama || map_with_streetview.createPanorama({
|
||||
el : '#streetview-panorama',
|
||||
pov : {
|
||||
heading : 60,
|
||||
pitch : -10,
|
||||
zoom : 1
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it("should be equal to the current map Street View panorama", function() {
|
||||
expect(map_with_streetview.getStreetView()).toEqual(attached_panorama);
|
||||
});
|
||||
});
|
||||
|
||||
describe("With events", function() {
|
||||
var callbacks;
|
||||
|
||||
beforeEach(function() {
|
||||
callbacks = {
|
||||
onpovchanged : function() {
|
||||
console.log(this);
|
||||
}
|
||||
};
|
||||
|
||||
spyOn(callbacks, 'onpovchanged').andCallThrough();
|
||||
|
||||
panorama_with_events = panorama_with_events || GMaps.createPanorama({
|
||||
el : '#streetview-with-events',
|
||||
lat : 42.3455,
|
||||
lng : -71.0983,
|
||||
pov : {
|
||||
heading : 60,
|
||||
pitch : -10,
|
||||
zoom : 1
|
||||
},
|
||||
pov_changed : callbacks.onpovchanged
|
||||
});
|
||||
});
|
||||
|
||||
it("should respond to pov_changed event", function() {
|
||||
panorama_with_events.setPov({
|
||||
heading : 80,
|
||||
pitch : -10,
|
||||
zoom : 1
|
||||
});
|
||||
|
||||
expect(callbacks.onpovchanged).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
43
assets/plugins/gmaps/test/spec/StyleSpec.js
Normal file
43
assets/plugins/gmaps/test/spec/StyleSpec.js
Normal file
@@ -0,0 +1,43 @@
|
||||
describe("Adding Map Styles", function() {
|
||||
var map_with_styles;
|
||||
|
||||
beforeEach(function() {
|
||||
map_with_styles = map_with_styles || new GMaps({
|
||||
el : '#map-with-styles',
|
||||
lat : -12.0433,
|
||||
lng : -77.0283,
|
||||
zoom : 12
|
||||
});
|
||||
|
||||
map_with_styles.addStyle({
|
||||
styledMapName : {
|
||||
name : 'Lighter'
|
||||
},
|
||||
mapTypeId : 'lighter',
|
||||
styles : [
|
||||
{
|
||||
elementType : 'geometry',
|
||||
stylers : [
|
||||
{ lightness : 50 }
|
||||
]
|
||||
},
|
||||
{
|
||||
elementType : 'labels',
|
||||
stylers : [
|
||||
{ visibility : 'off' }
|
||||
]
|
||||
},
|
||||
]
|
||||
});
|
||||
});
|
||||
|
||||
it("should add a MapType to the current map", function() {
|
||||
expect(map_with_styles.map.mapTypes.get('lighter')).toBeDefined();
|
||||
});
|
||||
|
||||
it("should update the styles in the current map", function() {
|
||||
map_with_styles.setStyle('lighter');
|
||||
|
||||
expect(map_with_styles.getMapTypeId()).toEqual('lighter');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user