OverlaySpec.js
1.87 KB
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
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);
});
describe("With events", function() {
var callbacks, overlayWithClick;
beforeEach(function() {
callbacks = {
onclick: function() {
console.log('Clicked the overlay');
}
};
spyOn(callbacks, 'onclick').andCallThrough();
overlayWithClick = map_with_overlays.drawOverlay({
lat: map_with_overlays.getCenter().lat(),
lng: map_with_overlays.getCenter().lng(),
content: '<p>Clickable overlay</p>',
click: callbacks.onclick
});
});
it("should respond to click event", function() {
var domIsReady = false;
google.maps.event.addListenerOnce(overlayWithClick, "ready", function () {
domIsReady = true;
});
waitsFor(function () {
return domIsReady;
}, "the overlay's DOM element to be ready", 10000);
runs(function () {
google.maps.event.trigger(overlayWithClick.el, "click");
expect(callbacks.onclick).toHaveBeenCalled();
});
});
});
});