Merge pull request #5619 from ahocevar/remove-goog-asserts

Remove goog.asserts.*
This commit is contained in:
Andreas Hocevar
2016-08-04 23:02:38 +02:00
committed by GitHub
157 changed files with 1429 additions and 1676 deletions

View File

@@ -673,17 +673,14 @@ describe('ol.format.WFS', function() {
[-12416429, 6604910]
]]));
var error = false;
try {
expect(function() {
format.writeTransaction(null, [updateFeature], null, {
featureNS: 'http://foo',
featureType: 'FAULTS',
featurePrefix: 'foo',
gmlOptions: {srsName: 'EPSG:900913'}
});
} catch (e) {
error = true;
}
expect(error).to.be(true);
}).to.throwException();
});
});

View File

@@ -35,22 +35,24 @@ describe('ol.layer.VectorTile', function() {
});
describe('constructor (options)', function() {
var layer = new ol.layer.VectorTile({
renderMode: 'vector',
source: new ol.source.VectorTile({})
});
expect(layer.getRenderMode()).to.be('vector');
layer = new ol.layer.VectorTile({
renderMode: 'image',
source: new ol.source.VectorTile({})
});
expect(layer.getRenderMode()).to.be('image');
expect(function() {
layer = new ol.layer.VectorTile({
renderMode: 'foo',
it('works with options', function() {
var layer = new ol.layer.VectorTile({
renderMode: 'vector',
source: new ol.source.VectorTile({})
});
}).to.throwException();
expect(layer.getRenderMode()).to.be('vector');
layer = new ol.layer.VectorTile({
renderMode: 'image',
source: new ol.source.VectorTile({})
});
expect(layer.getRenderMode()).to.be('image');
expect(function() {
layer = new ol.layer.VectorTile({
renderMode: 'foo',
source: new ol.source.VectorTile({})
});
}).to.throwException();
});
});
});

View File

@@ -111,6 +111,12 @@ describe('ol.math.solveLinearSystem', function() {
expect(result).to.be(null);
});
it('raises an exception when the matrix is malformed', function() {
var origAssert = console.assert;
console.assert = function(assertion, message) {
if (!assertion) {
throw new Error(message);
}
};
expect(function() {
ol.math.solveLinearSystem([
[2, 1, 3, 1],
@@ -126,6 +132,7 @@ describe('ol.math.solveLinearSystem', function() {
[6, 8, 18, 5, 0]
]);
}).to.throwException();
console.assert = origAssert;
});
});

37
test/spec/ol/ol.test.js Normal file
View File

@@ -0,0 +1,37 @@
goog.provide('ol.test');
describe('ol', function() {
describe('ol.assert', function() {
it('throws an exception', function() {
expect(function() {
ol.assert(false, 42);
}).to.throwException();
});
});
describe('ol.AssertionError', function() {
it('generates a message', function() {
var error = new ol.AssertionError(42);
expect(error.message).to.be('Assertion failed. See /doc/errors/#42 for details.');
});
it('generates a message with a versioned url', function() {
var origVersion = ol.VERSION;
ol.VERSION = 'foo';
var error = new ol.AssertionError(42);
expect(error.message).to.be('Assertion failed. See http://openlayers.org/en/foo/doc/errors/#42 for details.');
ol.VERSION = origVersion;
});
it('has an error code', function() {
var error = new ol.AssertionError(42);
expect(error.code).to.be(42);
});
it('has a name', function() {
var error = new ol.AssertionError(42);
expect(error.name).to.be('AssertionError');
})
});
});
goog.require('ol');

View File

@@ -9,11 +9,20 @@ describe('ol.structs.PriorityQueue', function() {
describe('when empty', function() {
var pq;
var pq, origAssert;
beforeEach(function() {
origAssert = console.assert;
console.assert = function(assertion, message) {
if (!assertion) {
throw new Error(message);
}
}
pq = new ol.structs.PriorityQueue(
identity, identity);
});
afterEach(function() {
console.assert = origAssert;
});
it('is valid', function() {
expect(function() {

View File

@@ -58,9 +58,11 @@ describe('ol.TileRange', function() {
});
describe('with mixed z', function() {
expect(function() {
return new ol.TileRange.boundingTileRange([3, 1, 3], [4, 2, 0]);
}).to.throwException();
it('returns the expected TileRange', function() {
expect(function() {
return new ol.TileRange.boundingTileRange([3, 1, 3], [4, 2, 0]);
}).to.throwException();
});
});
});