# Code coverage report for ./suites/control/Control.AttributionSpec.js

## Statements: 100% (42 / 42) Branches: 100% (0 / 0) Functions: 100% (14 / 14) Lines: 100% (42 / 42)

All files » ./suites/control/ » Control.AttributionSpec.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
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    691

    1

    1
    8
    8

    8

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

    1
    1
    1
    1

     describe("Control.Attribution", function () {

    	var map, control, container;

    	beforeEach(function () {
    		map = L.map(document.createElement('div'));
    		control = new L.Control.Attribution({
    			prefix: 'prefix'
    		}).addTo(map);
    		container = control.getContainer();
    	});

    	it("contains just prefix if no attributions added", function () {
    		expect(container.innerHTML).to.eql('prefix');
    	});

    	describe('#addAttribution', function () {
    		it('adds one attribution correctly', function () {
    			control.addAttribution('foo');
    			expect(container.innerHTML).to.eql('prefix | foo');
    		});

    		it('adds no duplicate attributions', function () {
    			control.addAttribution('foo');
    			control.addAttribution('foo');
    			expect(container.innerHTML).to.eql('prefix | foo');
    		});

    		it('adds several attributions listed with comma', function () {
    			control.addAttribution('foo');
    			control.addAttribution('bar');
    			expect(container.innerHTML).to.eql('prefix | foo, bar');
    		});
    	});

    	describe('#removeAttribution', function () {
    		it('removes attribution correctly', function () {
    			control.addAttribution('foo');
    			control.addAttribution('bar');
    			control.removeAttribution('foo');
    			expect(container.innerHTML).to.eql('prefix | bar');
    		});
    		it('does nothing if removing attribution that was not present', function () {
    			control.addAttribution('foo');
    			control.addAttribution('baz');
    			control.removeAttribution('bar');
    			control.removeAttribution('baz');
    			control.removeAttribution('baz');
    			control.removeAttribution('');
    			expect(container.innerHTML).to.eql('prefix | foo');
    		});
    	});

    	describe('#setPrefix', function () {
    		it('changes prefix', function () {
    			control.setPrefix('bla');
    			expect(container.innerHTML).to.eql('bla');
    		});
    	});

    	describe('control.attribution factory', function () {
    		it('creates Control.Attribution instance', function () {
    			var options = {prefix: 'prefix'};
    			expect(L.control.attribution(options)).to.eql(new L.Control.Attribution(options));
    		});
    	});

    });