Merge pull request #7160 from tschaub/updates

Assorted test updates
This commit is contained in:
Tim Schaub
2017-08-18 21:29:15 -04:00
committed by GitHub
6 changed files with 20 additions and 26 deletions

View File

@@ -20,9 +20,8 @@
"karma": "node tasks/test.js start test/karma.config.js",
"transform-src": "jscodeshift --transform transforms/module.js src",
"transform-examples": "jscodeshift --transform transforms/module.js examples",
"transform-test-spec": "jscodeshift --transform transforms/module.js test/spec",
"transform-test-rendering": "jscodeshift --transform transforms/module.js test/rendering",
"transform": "npm run transform-src && npm run transform-examples && npm run transform-test-spec && npm run transform-test-rendering && npm run lint -- --fix"
"transform-test": "jscodeshift --transform transforms/module.js test",
"transform": "npm run transform-src && npm run transform-examples && npm run transform-test && npm run lint -- --fix"
},
"main": "dist/ol.js",
"repository": {

View File

@@ -1,6 +1,5 @@
goog.require('ol.proj');
goog.require('ol.proj.EPSG3857');
describe('ol.proj.EPSG3857', function() {

View File

@@ -1,5 +1,3 @@
goog.provide('ol.test.source.TileSource'); // eslint-disable-line openlayers-internal/valid-provide
goog.require('ol');
goog.require('ol.Tile');
goog.require('ol.TileRange');
@@ -18,7 +16,7 @@ goog.require('ol.tilegrid.TileGrid');
* @param {Object.<string, ol.TileState>} tileStates Lookup of tile key to
* tile state.
*/
ol.test.source.TileSource.Mock = function(tileStates) {
var MockTile = function(tileStates) {
var tileGrid = new ol.tilegrid.TileGrid({
resolutions: [360 / 256, 180 / 256, 90 / 256, 45 / 256],
origin: [-180, -180],
@@ -35,13 +33,13 @@ ol.test.source.TileSource.Mock = function(tileStates) {
}
};
ol.inherits(ol.test.source.TileSource.Mock, ol.source.Tile);
ol.inherits(MockTile, ol.source.Tile);
/**
* @inheritDoc
*/
ol.test.source.TileSource.Mock.prototype.getTile = function(z, x, y) {
MockTile.prototype.getTile = function(z, x, y) {
var key = this.getKeyZXY(z, x, y);
if (this.tileCache.containsKey(key)) {
return /** @type {!ol.Tile} */ (this.tileCache.get(key));
@@ -121,7 +119,7 @@ describe('ol.source.Tile', function() {
});
it('does not call the callback if no tiles are loaded', function() {
var source = new ol.test.source.TileSource.Mock({});
var source = new MockTile({});
var grid = source.getTileGrid();
var extent = [-180, -180, 180, 180];
var zoom = 3;
@@ -132,7 +130,7 @@ describe('ol.source.Tile', function() {
});
it('does not call getTile() if no tiles are loaded', function() {
var source = new ol.test.source.TileSource.Mock({});
var source = new MockTile({});
sinon.spy(source, 'getTile');
var grid = source.getTileGrid();
var extent = [-180, -180, 180, 180];
@@ -146,7 +144,7 @@ describe('ol.source.Tile', function() {
it('calls callback for each loaded tile', function() {
var source = new ol.test.source.TileSource.Mock({
var source = new MockTile({
'1/0/0': 2, // LOADED
'1/0/1': 2, // LOADED
'1/1/0': 1, // LOADING,
@@ -162,7 +160,7 @@ describe('ol.source.Tile', function() {
it('returns true if range is fully loaded', function() {
// a source with no loaded tiles
var source = new ol.test.source.TileSource.Mock({
var source = new MockTile({
'1/0/0': 2, // LOADED,
'1/0/1': 2, // LOADED,
'1/1/0': 2, // LOADED,
@@ -182,7 +180,7 @@ describe('ol.source.Tile', function() {
it('returns false if range is not fully loaded', function() {
// a source with no loaded tiles
var source = new ol.test.source.TileSource.Mock({
var source = new MockTile({
'1/0/0': 2, // LOADED,
'1/0/1': 2, // LOADED,
'1/1/0': 1, // LOADING,
@@ -202,7 +200,7 @@ describe('ol.source.Tile', function() {
it('allows callback to override loaded check', function() {
// a source with no loaded tiles
var source = new ol.test.source.TileSource.Mock({
var source = new MockTile({
'1/0/0': 2, // LOADED,
'1/0/1': 2, // LOADED,
'1/1/0': 2, // LOADED,
@@ -274,7 +272,7 @@ 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.TileSource.Mock({
var source = new MockTile({
'1/0/0': 2 // LOADED
});
// check the loaded tile is there
@@ -292,19 +290,19 @@ describe('ol.source.Tile', function() {
});
describe('ol.test.source.TileSource.Mock', function() {
describe('MockTile', function() {
describe('constructor', function() {
it('creates a tile source', function() {
var source = new ol.test.source.TileSource.Mock({});
var source = new MockTile({});
expect(source).to.be.a(ol.source.Tile);
expect(source).to.be.a(ol.test.source.TileSource.Mock);
expect(source).to.be.a(MockTile);
});
});
describe('#getTile()', function() {
it('returns a tile with state based on constructor arg', function() {
var source = new ol.test.source.TileSource.Mock({
var source = new MockTile({
'0/0/0': 2, // LOADED,
'1/0/0': 2 // LOADED
});

View File

@@ -29,7 +29,7 @@ describe('ol.style.IconImageCache', function() {
for (i = 0; i < 4; ++i) {
src = i + '';
iconImage = new ol.style.IconImage(src, null);
iconImage = new ol.style.IconImage(null, src);
cache.set(src, null, null, iconImage);
}

View File

@@ -1,10 +1,8 @@
goog.require('ol.TileUrlFunction');
goog.require('ol.tilecoord');
goog.require('ol.tilegrid');
goog.require('ol.tilegrid.TileGrid');
describe('ol.TileUrlFunction', function() {
describe('expandUrl', function() {

View File

@@ -514,4 +514,4 @@ goog.require('ol.renderer.webgl.Map');
}
});
})(this);
})(window);