Assume latest if no ol.VERSION
This commit is contained in:
@@ -13,11 +13,12 @@ goog.require('ol');
|
|||||||
*/
|
*/
|
||||||
ol.AssertionError = function(code) {
|
ol.AssertionError = function(code) {
|
||||||
|
|
||||||
|
var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {string}
|
* @type {string}
|
||||||
*/
|
*/
|
||||||
this.message = 'Assertion failed. See ' +
|
this.message = 'Assertion failed. See https://openlayers.org/en/' + path +
|
||||||
(ol.VERSION ? 'https://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
|
|
||||||
'/doc/errors/#' + code + ' for details.';
|
'/doc/errors/#' + code + ' for details.';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ goog.require('ol.AssertionError');
|
|||||||
describe('ol.AssertionError', function() {
|
describe('ol.AssertionError', function() {
|
||||||
it('generates a message', function() {
|
it('generates a message', function() {
|
||||||
var error = new ol.AssertionError(42);
|
var error = new ol.AssertionError(42);
|
||||||
expect(error.message).to.be('Assertion failed. See /doc/errors/#42 for details.');
|
expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/latest/doc/errors/#42 for details.');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates a message with a versioned url', function() {
|
it('generates a message with a versioned url', function() {
|
||||||
var origVersion = ol.VERSION;
|
var origVersion = ol.VERSION;
|
||||||
ol.VERSION = 'foo';
|
ol.VERSION = 'foo';
|
||||||
@@ -15,10 +16,12 @@ describe('ol.AssertionError', function() {
|
|||||||
expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/foo/doc/errors/#42 for details.');
|
expect(error.message).to.be('Assertion failed. See https://openlayers.org/en/foo/doc/errors/#42 for details.');
|
||||||
ol.VERSION = origVersion;
|
ol.VERSION = origVersion;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has an error code', function() {
|
it('has an error code', function() {
|
||||||
var error = new ol.AssertionError(42);
|
var error = new ol.AssertionError(42);
|
||||||
expect(error.code).to.be(42);
|
expect(error.code).to.be(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has a name', function() {
|
it('has a name', function() {
|
||||||
var error = new ol.AssertionError(42);
|
var error = new ol.AssertionError(42);
|
||||||
expect(error.name).to.be('AssertionError');
|
expect(error.name).to.be('AssertionError');
|
||||||
|
|||||||
Reference in New Issue
Block a user