Add hasFeature method to ol.source.Vector

This commit is contained in:
Ilia Choly
2018-04-17 14:01:55 -04:00
parent bd66034d7d
commit b8d3bb5766
2 changed files with 44 additions and 0 deletions

View File

@@ -85,6 +85,35 @@ describe('ol.source.Vector', function() {
});
describe('#hasFeature', function() {
it('returns true for added feature without id', function() {
const feature = new Feature();
vectorSource.addFeature(feature);
expect(vectorSource.hasFeature(feature)).to.be(true);
});
it('returns true for added feature with id', function() {
const feature = new Feature();
feature.setId('1');
vectorSource.addFeature(feature);
expect(vectorSource.hasFeature(feature)).to.be(true);
});
it('return false for removed feature', function() {
const feature = new Feature();
vectorSource.addFeature(feature);
vectorSource.removeFeature(feature);
expect(vectorSource.hasFeature(feature)).to.be(false);
});
it('returns false for non-added feature', function() {
const feature = new Feature();
expect(vectorSource.hasFeature(feature)).to.be(false);
});
});
});
describe('when populated with 3 features', function() {