Merge pull request #3517 from marcjansen/basic-tests

Add tests for previously untested classes
This commit is contained in:
Marc Jansen
2015-04-14 10:04:25 +02:00
15 changed files with 330 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.buffer');
describe('ol.binary.Buffer', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.binary.Buffer();
expect(instance).to.be.an(ol.binary.Buffer);
});
});
});
goog.require('ol.binary.Buffer');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.control.FullScreen');
describe('ol.control.FullScreen', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.control.FullScreen();
expect(instance).to.be.an(ol.control.FullScreen);
});
});
});
goog.require('ol.control.FullScreen');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.control.MousePosition');
describe('ol.control.MousePosition', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.control.MousePosition();
expect(instance).to.be.an(ol.control.MousePosition);
});
});
});
goog.require('ol.control.MousePosition');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.control.ScaleLine');
describe('ol.control.ScaleLine', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.control.ScaleLine();
expect(instance).to.be.an(ol.control.ScaleLine);
});
});
});
goog.require('ol.control.ScaleLine');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.control.ZoomToExtent');
describe('ol.control.ZoomToExtent', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.control.ZoomToExtent();
expect(instance).to.be.an(ol.control.ZoomToExtent);
});
});
});
goog.require('ol.control.ZoomToExtent');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.DeviceOrientation');
describe('ol.DeviceOrientation', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.DeviceOrientation();
expect(instance).to.be.an(ol.DeviceOrientation);
});
});
});
goog.require('ol.DeviceOrientation');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.format.BinaryFeature');
describe('ol.format.BinaryFeature', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.format.BinaryFeature();
expect(instance).to.be.an(ol.format.BinaryFeature);
});
});
});
goog.require('ol.format.BinaryFeature');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.Geolocation');
describe('ol.Geolocation', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.Geolocation();
expect(instance).to.be.an(ol.Geolocation);
});
});
});
goog.require('ol.Geolocation');

View File

@@ -0,0 +1,101 @@
goog.provide('ol.test.ImageUrlFunction');
describe('ol.ImageUrlFunction', function() {
describe('#createFromParamsFunction', function() {
it('is a defined function', function() {
expect(ol.ImageUrlFunction.createFromParamsFunction).to.not.be(undefined);
expect(ol.ImageUrlFunction.createFromParamsFunction).to.be.a(Function);
});
it('returns a function that throws when called (no arguments)', function() {
var got = ol.ImageUrlFunction.createFromParamsFunction();
expect(function() {
got();
}).to.throwException();
});
it('returns a function that doesn\'t throw when called (valid arguments)',
function() {
var baseUrl = 'foo',
params = {foo: 'bar'},
paramsFunction = sinon.spy(),
got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl,
params, paramsFunction);
expect(function() {
got();
}).to.not.throwException();
}
);
it('passes given baseUrl to given paramsFunction', function() {
var baseUrl = 'foo',
params = {foo: 'bar'},
spy = sinon.spy(),
got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params,
spy);
got();
expect(spy.called).to.be(true);
expect(spy.calledOnce).to.be(true);
expect(spy.calledWith(baseUrl)).to.be(true);
});
it('passes given params to given paramsFunction', function() {
var baseUrl = 'foo',
params = {foo: 'bar'},
spy = sinon.spy(),
got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params,
spy);
got();
expect(spy.called).to.be(true);
expect(spy.calledOnce).to.be(true);
expect(spy.calledWith(baseUrl, params)).to.be(true);
});
it('passes five params to given paramsFunction', function() {
var baseUrl = 'foo',
params = {foo: 'bar'},
extent = [1, 2, 3, 4],
size = [47, 11],
projection = ol.proj.get('CRS:84'),
spy = sinon.spy(),
firstArgs,
got = ol.ImageUrlFunction.createFromParamsFunction(baseUrl, params,
spy);
got(extent, size, projection);
firstArgs = spy.args[0];
expect(spy.called).to.be(true);
expect(spy.calledOnce).to.be(true);
expect(firstArgs.length).to.be(5);
expect(firstArgs).to.eql([baseUrl, params, extent, size, projection]);
});
});
describe('#nullImageUrlFunction', function() {
it('is a defined function', function() {
expect(ol.ImageUrlFunction.nullImageUrlFunction).to.not.be(undefined);
expect(ol.ImageUrlFunction.nullImageUrlFunction).to.be.a(Function);
});
it('always returns undefined', function() {
var got = ol.ImageUrlFunction.nullImageUrlFunction();
expect(got).to.be(undefined);
});
});
});
goog.require('ol.proj');
goog.require('ol.ImageUrlFunction');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.interaction.DragAndDrop');
describe('ol.interaction.DragAndDrop', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.interaction.DragAndDrop();
expect(instance).to.be.an(ol.interaction.DragAndDrop);
});
});
});
goog.require('ol.interaction.DragAndDrop');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.interaction.DragRotateAndZoom');
describe('ol.interaction.DragRotateAndZoom', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.interaction.DragRotateAndZoom();
expect(instance).to.be.an(ol.interaction.DragRotateAndZoom);
});
});
});
goog.require('ol.interaction.DragRotateAndZoom');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.interaction.Snap');
describe('ol.interaction.Snap', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.interaction.Snap();
expect(instance).to.be.an(ol.interaction.Snap);
});
});
});
goog.require('ol.interaction.Snap');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.layer.Heatmap');
describe('ol.layer.Heatmap', function() {
describe('constructor', function() {
it('can be constructed without arguments', function() {
var instance = new ol.layer.Heatmap();
expect(instance).to.be.an(ol.layer.Heatmap);
});
});
});
goog.require('ol.layer.Heatmap');

View File

@@ -0,0 +1,16 @@
goog.provide('ol.test.Overlay');
describe('ol.Overlay', function() {
describe('constructor', function() {
it('can be constructed with minimal arguments', function() {
var instance = new ol.Overlay({});
expect(instance).to.be.an(ol.Overlay);
});
});
});
goog.require('ol.Overlay');

View File

@@ -0,0 +1,21 @@
goog.provide('ol.test.tilegrid.Zoomify');
describe('ol.tilegrid.Zoomify', function() {
describe('constructor', function() {
it('can be constructed with minimal arguments', function() {
var instance = new ol.tilegrid.Zoomify({
resolutions: [],
extent: [],
origin: [],
tileSize: []
});
expect(instance).to.be.an(ol.tilegrid.Zoomify);
});
});
});
goog.require('ol.tilegrid.Zoomify');