More test cleanup

This commit is contained in:
Tim Schaub
2017-07-03 15:39:02 -06:00
parent a2c043d1b4
commit 3bdddeac1d
14 changed files with 219 additions and 285 deletions
+10 -18
View File
@@ -7,22 +7,13 @@ goog.require('ol.interaction.Extent');
goog.require('ol.pointer.PointerEvent');
describe('ol.interaction.Extent', function() {
var target, map, interaction;
var map, interaction;
var width = 360;
var height = 180;
beforeEach(function(done) {
target = document.createElement('div');
var style = target.style;
style.position = 'absolute';
style.left = '-1000px';
style.top = '-1000px';
style.width = width + 'px';
style.height = height + 'px';
document.body.appendChild(target);
beforeEach(function() {
var target = createMapDiv(width, height);
map = new ol.Map({
target: target,
@@ -33,18 +24,18 @@ describe('ol.interaction.Extent', function() {
resolution: 1
})
});
map.once('postrender', function() {
done();
});
map.renderSync();
interaction = new ol.interaction.Extent();
map.addInteraction(interaction);
});
afterEach(function() {
map.dispose();
document.body.removeChild(target);
if (map) {
disposeMap(map);
}
map = null;
interaction = null;
});
/**
@@ -92,6 +83,7 @@ describe('ol.interaction.Extent', function() {
expect(interaction.snapToVertex_([230, 40], map)).to.eql([50, 50]);
expect(interaction.snapToVertex_([231, 41], map)).to.eql([50, 50]);
});
it('snap to edge works', function() {
interaction.setExtent([-50, -50, 50, 50]);
+11 -9
View File
@@ -22,7 +22,7 @@ var blue = 'data:image/gif;base64,R0lGODlhAQABAPAAAAAA/////yH5BAAAAAAALAAAAA' +
where('Uint8ClampedArray').describe('ol.source.Raster', function() {
var target, map, redSource, greenSource, blueSource, raster;
var map, target, redSource, greenSource, blueSource, raster;
beforeEach(function() {
target = document.createElement('div');
@@ -79,13 +79,14 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
});
afterEach(function() {
map.setTarget(null);
map.dispose();
if (map) {
disposeMap(map);
}
map = null;
raster.dispose();
greenSource.dispose();
redSource.dispose();
blueSource.dispose();
document.body.removeChild(target);
});
describe('constructor', function() {
@@ -304,9 +305,10 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
});
describe('tile loading', function() {
beforeEach(function() {
map.setTarget(null);
map.dispose();
var map2;
afterEach(function() {
disposeMap(map2);
map2 = null;
});
it('is initiated on the underlying source', function(done) {
@@ -323,7 +325,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
}
});
map = new ol.Map({
map2 = new ol.Map({
target: target,
view: new ol.View({
center: [0, 0],
@@ -340,7 +342,7 @@ where('Uint8ClampedArray').describe('ol.source.Raster', function() {
expect(tileCache.getCount()).to.equal(0);
map.once('moveend', function() {
map2.once('moveend', function() {
expect(tileCache.getCount()).to.equal(1);
var state = tileCache.peekLast().getState();
expect(state === ol.TileState.LOADED || state === ol.TileState.LOADED).to.be(true);