Administrator
2022-09-14 58d006e05dcf2a20d0ec5367dd03d66a61db6849
提交 | 用户 | 时间
58d006 1 describe("Adding layers", function() {
A 2   var map_with_layers, single_layer, multiple_layers = [];
3
4   beforeEach(function() {
5     map_with_layers = map_with_layers || new GMaps({
6       el : '#map-with-layers',
7       lat: -12.0433,
8       lng: -77.0283,
9       zoom: 12
10     });
11   });
12
13   describe("Single layer", function() {
14     beforeEach(function() {
15       single_layer = single_layer || map_with_layers.addLayer('traffic');
16     })
17
18     it("should be added in the current map", function() {
19       expect(single_layer.getMap()).toEqual(map_with_layers.map);
20     });
21
22     it("should be removed from the current map", function() {
23       map_with_layers.removeLayer('traffic');
24       
25       expect(single_layer.getMap()).toBeNull();
26     });
27   });
28
29   describe("Multiple layers", function() {
30     beforeEach(function() {
31       if (multiple_layers.length == 0) {
32         multiple_layers.push(map_with_layers.addLayer('transit'));
33         multiple_layers.push(map_with_layers.addLayer('bicycling'));
34       }
35     });
36
37     it("should be added in the current map", function() {
38       expect(multiple_layers[0].getMap()).toEqual(map_with_layers.map);
39       expect(multiple_layers[1].getMap()).toEqual(map_with_layers.map);
40     });
41     
42     it("should be removed from the current map", function() {
43       map_with_layers.removeLayer('transit');
44       map_with_layers.removeLayer('bicycling');
45
46       expect(multiple_layers[0].getMap()).toBeNull();
47       expect(multiple_layers[1].getMap()).toBeNull();
48     });
49   });
50 });