Add function to dispose whole layer group
This commit is contained in:
@@ -7,7 +7,15 @@ import {getIntersection} from '../../../../../src/ol/extent.js';
|
|||||||
import {getUid} from '../../../../../src/ol/util.js';
|
import {getUid} from '../../../../../src/ol/util.js';
|
||||||
|
|
||||||
describe('ol.layer.Group', function () {
|
describe('ol.layer.Group', function () {
|
||||||
|
function disposeHierarchy(layer) {
|
||||||
|
if (layer instanceof LayerGroup) {
|
||||||
|
layer.getLayers().forEach((l) => disposeHierarchy(l));
|
||||||
|
}
|
||||||
|
layer.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
describe('constructor (defaults)', function () {
|
describe('constructor (defaults)', function () {
|
||||||
|
/** @type {LayerGroup} */
|
||||||
let group;
|
let group;
|
||||||
|
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
@@ -67,8 +75,7 @@ describe('ol.layer.Group', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
group.dispose();
|
disposeHierarchy(group);
|
||||||
layer.dispose();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is dispatched by the group when layer opacity changes', function () {
|
it('is dispatched by the group when layer opacity changes', function () {
|
||||||
@@ -104,8 +111,7 @@ describe('ol.layer.Group', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
group.dispose();
|
disposeHierarchy(group);
|
||||||
layer.dispose();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('is dispatched by the group when group opacity changes', function () {
|
it('is dispatched by the group when group opacity changes', function () {
|
||||||
@@ -167,8 +173,7 @@ describe('ol.layer.Group', function () {
|
|||||||
expect(group.getLayers().getLength()).to.be(1);
|
expect(group.getLayers().getLength()).to.be(1);
|
||||||
expect(group.getLayers().item(0)).to.be(layer);
|
expect(group.getLayers().item(0)).to.be(layer);
|
||||||
|
|
||||||
layer.dispose();
|
disposeHierarchy(group);
|
||||||
group.dispose();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts an extent option', function () {
|
it('accepts an extent option', function () {
|
||||||
@@ -210,8 +215,7 @@ describe('ol.layer.Group', function () {
|
|||||||
expect(group.getLayers().getLength()).to.be(1);
|
expect(group.getLayers().getLength()).to.be(1);
|
||||||
expect(group.getLayers().item(0)).to.be(layer);
|
expect(group.getLayers().item(0)).to.be(layer);
|
||||||
|
|
||||||
layer.dispose();
|
disposeHierarchy(group);
|
||||||
group.dispose();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -223,7 +227,7 @@ describe('ol.layer.Group', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function () {
|
afterEach(function () {
|
||||||
group.dispose();
|
disposeHierarchy(group);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns a layerState from the properties values', function () {
|
it('returns a layerState from the properties values', function () {
|
||||||
@@ -323,9 +327,7 @@ describe('ol.layer.Group', function () {
|
|||||||
group.setLayers(layers);
|
group.setLayers(layers);
|
||||||
expect(group.getLayers()).to.be(layers);
|
expect(group.getLayers()).to.be(layers);
|
||||||
|
|
||||||
group.dispose();
|
disposeHierarchy(group);
|
||||||
layer.dispose();
|
|
||||||
layers.dispose();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user