Merge pull request #3758 from ahocevar/remove-featureoverlay

Removal of ol.FeatureOverlay
This commit is contained in:
Andreas Hocevar
2015-06-10 14:33:28 +02:00
33 changed files with 556 additions and 713 deletions

View File

@@ -427,10 +427,77 @@ describe('ol.source.Vector', function() {
});
});
describe('with useSpatialIndex set to false', function() {
var source;
beforeEach(function() {
source = new ol.source.Vector({useSpatialIndex: false});
});
it('returns a features collection', function() {
expect(source.getFeaturesCollection()).to.be.a(ol.Collection);
});
it('#forEachFeatureInExtent loops through all features', function() {
source.addFeatures([new ol.Feature(), new ol.Feature()]);
var spy = sinon.spy();
source.forEachFeatureInExtent([0, 0, 0, 0], spy);
expect(spy.callCount).to.be(2);
});
});
describe('with a collection of features', function() {
var collection, source;
beforeEach(function() {
collection = new ol.Collection();
source = new ol.source.Vector({
features: collection
});
});
it('#getFeaturesCollection returns the configured collection', function() {
expect(source.getFeaturesCollection()).to.equal(collection);
});
it('adding/removing features keeps the collection in sync', function() {
var feature = new ol.Feature();
source.addFeature(feature);
expect(collection.getLength()).to.be(1);
source.removeFeature(feature);
expect(collection.getLength()).to.be(0);
});
it('#clear() features keeps the collection in sync', function() {
var feature = new ol.Feature();
source.addFeatures([feature]);
expect(collection.getLength()).to.be(1);
source.clear();
expect(collection.getLength()).to.be(0);
source.addFeatures([feature]);
expect(collection.getLength()).to.be(1);
source.clear(true);
expect(collection.getLength()).to.be(0);
});
it('keeps the source\'s features in sync with the collection', function() {
var feature = new ol.Feature();
collection.push(feature);
expect(source.getFeatures().length).to.be(1);
collection.remove(feature);
expect(source.getFeatures().length).to.be(0);
collection.extend([feature]);
expect(source.getFeatures().length).to.be(1);
collection.clear();
expect(source.getFeatures().length).to.be(0);
});
});
});
goog.require('goog.events');
goog.require('ol.Collection');
goog.require('ol.Feature');
goog.require('ol.geom.Point');
goog.require('ol.proj');