Add test for attributionsCollapsible property on source
This commit is contained in:
@@ -9,6 +9,18 @@ import {createXYZ} from '../../../../src/ol/tilegrid.js';
|
|||||||
describe('ol.control.Attribution', function() {
|
describe('ol.control.Attribution', function() {
|
||||||
|
|
||||||
let map;
|
let map;
|
||||||
|
|
||||||
|
const tileLoadFunction = function() {
|
||||||
|
const tile = new Tile([0, 0, -1], 2 /* LOADED */);
|
||||||
|
tile.getImage = function() {
|
||||||
|
const image = new Image();
|
||||||
|
image.width = 256;
|
||||||
|
image.height = 256;
|
||||||
|
return image;
|
||||||
|
};
|
||||||
|
return tile;
|
||||||
|
};
|
||||||
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
const target = document.createElement('div');
|
const target = document.createElement('div');
|
||||||
target.style.width = target.style.height = '100px';
|
target.style.width = target.style.height = '100px';
|
||||||
@@ -49,16 +61,7 @@ describe('ol.control.Attribution', function() {
|
|||||||
});
|
});
|
||||||
map.getLayers().forEach(function(layer) {
|
map.getLayers().forEach(function(layer) {
|
||||||
const source = layer.getSource();
|
const source = layer.getSource();
|
||||||
source.getTile = function() {
|
source.getTile = tileLoadFunction;
|
||||||
const tile = new Tile([0, 0, -1], 2 /* LOADED */);
|
|
||||||
tile.getImage = function() {
|
|
||||||
const image = new Image();
|
|
||||||
image.width = 256;
|
|
||||||
image.height = 256;
|
|
||||||
return image;
|
|
||||||
};
|
|
||||||
return tile;
|
|
||||||
};
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -73,4 +76,23 @@ describe('ol.control.Attribution', function() {
|
|||||||
expect(attribution.length).to.be(2);
|
expect(attribution.length).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('renders attributions as non-collapsible if source is configured with attributionsCollapsible set to false', function() {
|
||||||
|
map.getControls().clear();
|
||||||
|
map.addControl(new Attribution());
|
||||||
|
const source = new TileSource({
|
||||||
|
projection: 'EPSG:3857',
|
||||||
|
tileGrid: createXYZ(),
|
||||||
|
attributions: 'foo',
|
||||||
|
attributionsCollapsible: false
|
||||||
|
});
|
||||||
|
source.getTile = tileLoadFunction;
|
||||||
|
map.addLayer(new TileLayer({
|
||||||
|
source: source
|
||||||
|
}));
|
||||||
|
map.renderSync();
|
||||||
|
|
||||||
|
const attribution = map.getTarget().querySelectorAll('.ol-attribution.ol-uncollapsible');
|
||||||
|
expect(attribution.length).to.be(1);
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user