Merge pull request #4868 from sebasbaumh/refreshSource
Allow to refresh a source and reload its data.
This commit is contained in:
29
test/spec/ol/source/source.test.js
Normal file
29
test/spec/ol/source/source.test.js
Normal file
@@ -0,0 +1,29 @@
|
||||
goog.provide('ol.test.source.Source');
|
||||
|
||||
describe('ol.source.Source', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('returns a source', function() {
|
||||
var source = new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
});
|
||||
expect(source).to.be.a(ol.source.Source);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#refresh()', function() {
|
||||
it('dispatches the change event', function() {
|
||||
var source = new ol.source.Source({
|
||||
projection: ol.proj.get('EPSG:4326')
|
||||
});
|
||||
var changedSpy = sinon.spy();
|
||||
source.on('change', changedSpy);
|
||||
source.refresh();
|
||||
expect(changedSpy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.Source');
|
||||
@@ -170,6 +170,24 @@ describe('ol.source.Tile', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#refresh()', function() {
|
||||
it('checks clearing of internal state', function() {
|
||||
// create a source with one loaded tile
|
||||
var source = new ol.test.source.TileMock({
|
||||
'1/0/0': ol.TileState.LOADED
|
||||
});
|
||||
// check the loaded tile is there
|
||||
var tile = source.getTile(1, 0, 0);
|
||||
expect(tile).to.be.a(ol.Tile);
|
||||
// check tile cache is filled
|
||||
expect(source.tileCache.getCount()).to.eql(1);
|
||||
// refresh the source
|
||||
source.refresh();
|
||||
// check tile cache after refresh (should be empty)
|
||||
expect(source.tileCache.getCount()).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user