# Code coverage report for ./suites/layer/LayerGroupSpec.js

## Statements: 100% (30 / 30) Branches: 100% (0 / 0) Functions: 100% (12 / 12) Lines: 100% (30 / 30)

All files » ./suites/layer/ » LayerGroupSpec.js

    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
    591
    1
    1
    1

    1

    1

    1
    1
    1

    1
    1

    1

    1
    1
    1

    1
    1

    1

    1
    1
    1

    1

    1

    1
    1
    1

    1

    1
    1
    1

     ﻿describe('LayerGroup', function () {
    	describe("#addLayer", function () {
    		it('adds a layer', function() {
    			var lg = L.layerGroup(),
    				marker = L.marker([0, 0]);

    			expect(lg.addLayer(marker)).to.eql(lg);

    			expect(lg.hasLayer(marker)).to.be(true);
    		});
    	});
    	describe("#removeLayer", function () {
    		it('removes a layer', function() {
    			var lg = L.layerGroup(),
    				marker = L.marker([0, 0]);

    			lg.addLayer(marker);
    			expect(lg.removeLayer(marker)).to.eql(lg);

    			expect(lg.hasLayer(marker)).to.be(false);
    		});
    	});
    	describe("#clearLayers", function () {
    		it('removes all layers', function() {
    			var lg = L.layerGroup(),
    				marker = L.marker([0, 0]);

    			lg.addLayer(marker);
    			expect(lg.clearLayers()).to.eql(lg);

    			expect(lg.hasLayer(marker)).to.be(false);
    		});
    	});
    	describe("#getLayers", function () {
    		it('gets all layers', function() {
    			var lg = L.layerGroup(),
    				marker = L.marker([0, 0]);

    			lg.addLayer(marker);

    			expect(lg.getLayers()).to.eql([marker]);
    		});
    	});
    	describe("#eachLayer", function () {
    		it('iterates over all layers', function() {
    			var lg = L.layerGroup(),
    				marker = L.marker([0, 0]),
    				ctx = { foo: 'bar' };

    			lg.addLayer(marker);

    			lg.eachLayer(function(layer) {
    				expect(layer).to.eql(marker);
    				expect(this).to.eql(ctx);
    			}, ctx);
    		});
    	});
    });