Work with clones rather than the original features
This commit is contained in:
@@ -120,8 +120,8 @@ describe('ol.control.Select', function() {
|
||||
it('can clear a selection before selecting new features', function() {
|
||||
select.select([[features[0]]], true);
|
||||
select.select([[features[1]]], true);
|
||||
expect(goog.object.getValues(select.layer.featureCache_.idLookup_)[0])
|
||||
.to.eql(features[1]);
|
||||
expect(goog.object.getCount(select.layer.featureCache_.idLookup_))
|
||||
.to.be(1);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -34,6 +34,24 @@ describe('ol.Feature', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#clone()', function() {
|
||||
|
||||
it('creates a clone with a cloned geometry', function() {
|
||||
var feature = new ol.Feature({
|
||||
loc: new ol.geom.Point([10, 20]),
|
||||
foo: 'bar'
|
||||
});
|
||||
feature.setFeatureId('foo');
|
||||
var clone = feature.clone();
|
||||
expect(clone).to.not.be(feature);
|
||||
expect(clone.get('foo')).to.be('bar');
|
||||
expect(clone.getFeatureId()).to.be('foo');
|
||||
expect(clone.getGeometry()).to.not.be(feature.getGeometry());
|
||||
expect(clone.getGeometry().getCoordinates()).to.eql([10, 20]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#get()', function() {
|
||||
|
||||
it('returns values set at construction', function() {
|
||||
|
||||
@@ -55,6 +55,23 @@ describe('ol.geom.GeometryCollection', function() {
|
||||
|
||||
});
|
||||
|
||||
describe('#clone()', function() {
|
||||
|
||||
it('has a working clone method', function() {
|
||||
var point = new ol.geom.Point([10, 20]);
|
||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||
var clone = multi.clone();
|
||||
expect(clone).to.not.be(multi);
|
||||
var components = clone.components;
|
||||
expect(components[0]).to.eql([10, 20]);
|
||||
expect(components[1]).to.eql([[10, 20], [30, 40]]);
|
||||
expect(components[2]).to.eql([outer, inner1, inner2]);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getBounds()', function() {
|
||||
|
||||
it('returns the bounding extent', function() {
|
||||
|
||||
Reference in New Issue
Block a user