Merge pull request #7372 from notnotse/iconimagecache-setmaxcachesize

Add method to set max cache size in ol.style.IconImageCache
This commit is contained in:
Andreas Hocevar
2017-12-01 18:00:36 +01:00
committed by GitHub
3 changed files with 39 additions and 1 deletions

View File

@@ -66,4 +66,25 @@ describe('ol.style.IconImageCache', function() {
expect(cache.get('4', null, null)).to.not.be(null);
});
});
describe('#setSize', function() {
it('sets max cache size and expires cache', function() {
var cache = ol.style.iconImageCache;
var i, src, iconImage;
for (i = 0; i < 3; ++i) {
src = i + '';
iconImage = new ol.style.IconImage(null, src);
cache.set(src, null, null, iconImage);
}
expect(cache.cacheSize_).to.eql(3);
cache.setSize(2);
expect(cache.maxCacheSize_).to.eql(2);
expect(cache.cacheSize_).to.eql(2);
});
});
});