Collections cannot contain Collections.
By having both the constructor and the setComponents checking a white- and a blacklist for allowed types, we ensure that no Collections can be added through these methods to the list of components.
This commit is contained in:
@@ -29,6 +29,16 @@ describe("ol.geom.Collection", function() {
|
||||
expect( c ).toBeA( ol.geom.Collection );
|
||||
});
|
||||
|
||||
it("cannot construct instances when passed illegal components", function() {
|
||||
// collection cannot contain collections
|
||||
expect(function(){
|
||||
c = new ol.geom.Collection([
|
||||
new ol.geom.Collection()
|
||||
]);
|
||||
}).toThrow();
|
||||
|
||||
});
|
||||
|
||||
it("inherits from ol.geom.Geometry", function() {
|
||||
expect( c ).toBeA( ol.geom.Geometry );
|
||||
});
|
||||
@@ -81,7 +91,7 @@ describe("ol.geom.Collection", function() {
|
||||
]),
|
||||
0
|
||||
);
|
||||
|
||||
|
||||
var components = c.getComponents();
|
||||
|
||||
expect( components.length ).toBe( 4 );
|
||||
@@ -92,6 +102,17 @@ describe("ol.geom.Collection", function() {
|
||||
|
||||
});
|
||||
|
||||
it("cannot add instances of 'ol.geom.Collection'", function(){
|
||||
expect(function(){
|
||||
c.addComponent(
|
||||
new ol.geom.Collection([
|
||||
new ol.geom.Point(5,25),
|
||||
new ol.geom.Point(6,36)
|
||||
])
|
||||
);
|
||||
}).toThrow();
|
||||
});
|
||||
|
||||
it("has a method to remove components", function() {
|
||||
c.setComponents([
|
||||
new ol.geom.Point(0,10),
|
||||
|
||||
Reference in New Issue
Block a user