Skip to content

Commit

Permalink
Fix errors in Jasmine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
crisner committed Mar 6, 2020
1 parent 451aa3d commit d2d4e3e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion dist/LeafletEnvironmentalLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -30371,7 +30371,7 @@ L.Control.LayersBrowser = L.Control.Layers.extend({
}

map.on('overlayremove', function(e) {
const mapId = this._map._container.id;
const mapId = this._map && this._map._container.id;
var layerInfo = this._getLayerData(e);
var selector = '#' + mapId + '-menu-' + e.name + ' .layer-name';
var listLayerSelector = '#' + mapId + '-' + e.name + ' .layer-list-name';
Expand Down
17 changes: 9 additions & 8 deletions spec/javascripts/basicImplementation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Basic LEL Implementation', function() {

beforeEach(function () {
mapContainer = document.createElement('div');
mapContainer.id = 'map';
map = L.map(mapContainer, { }).setView([43, -83], 8);
});

Expand All @@ -29,26 +30,26 @@ describe('Basic LEL Implementation', function() {
display: ['eonetFiresLayer']
}).addTo(map);

expect(mapContainer.querySelector('#menu-eonetFiresLayer')).toExist();
expect(mapContainer.querySelector('#menu-Unearthing')).toExist();
expect(mapContainer.querySelector('#map-menu-eonetFiresLayer')).toExist();
expect(mapContainer.querySelector('#map-menu-Unearthing')).toExist();
});

it('exclude specific layers', function() {
L.LayerGroup.EnvironmentalLayers({
exclude: ['eonetFiresLayer']
}).addTo(map);

expect(mapContainer.querySelector('#menu-eonetFiresLayer')).not.toExist();
expect(mapContainer.querySelector('#menu-Unearthing')).toExist();
expect(mapContainer.querySelector('#map-menu-eonetFiresLayer')).not.toExist();
expect(mapContainer.querySelector('#map-menu-Unearthing')).toExist();
});

it('display shows layer', function() {
L.LayerGroup.EnvironmentalLayers({
display: ['eonetFiresLayer'],
}).addTo(map);

expect(mapContainer.querySelector('#menu-eonetFiresLayer .leaflet-control-layers-selector').checked).toBe(true);
expect(mapContainer.querySelector('#menu-Unearthing .leaflet-control-layers-selector').checked).toBe(false);
expect(mapContainer.querySelector('#map-menu-eonetFiresLayer .leaflet-control-layers-selector').checked).toBe(true);
expect(mapContainer.querySelector('#map-menu-Unearthing .leaflet-control-layers-selector').checked).toBe(false);
});

it('addLayersToMap shows all included layers', function() {
Expand All @@ -58,8 +59,8 @@ describe('Basic LEL Implementation', function() {
}).addTo(map);

expect(mapContainer.querySelector('.leaflet-control-container .leaflet-control-layers-menu')).toExist();
expect(mapContainer.querySelector('#menu-eonetFiresLayer .leaflet-control-layers-selector').checked).toBe(true);
expect(mapContainer.querySelector('#menu-Unearthing .leaflet-control-layers-selector').checked).toBe(true);
expect(mapContainer.querySelector('#map-menu-eonetFiresLayer .leaflet-control-layers-selector').checked).toBe(true);
expect(mapContainer.querySelector('#map-menu-Unearthing .leaflet-control-layers-selector').checked).toBe(true);
});

it('simpleLayerControl shows simple menu', function() {
Expand Down
2 changes: 1 addition & 1 deletion src/util/layersBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ L.Control.LayersBrowser = L.Control.Layers.extend({
}

map.on('overlayremove', function(e) {
const mapId = this._map._container.id;
const mapId = this._map && this._map._container.id;
var layerInfo = this._getLayerData(e);
var selector = '#' + mapId + '-menu-' + e.name + ' .layer-name';
var listLayerSelector = '#' + mapId + '-' + e.name + ' .layer-list-name';
Expand Down

0 comments on commit d2d4e3e

Please sign in to comment.