Add tests for vector layer

This commit is contained in:
Tim Schaub
2014-02-07 09:33:29 -07:00
parent 499ba4ac8f
commit 5c21f24df5

View File

@@ -0,0 +1,54 @@
goog.provide('ol.test.layer.Vector');
describe('ol.layer.Vector', function() {
describe('constructor', function() {
var source = new ol.source.Vector();
var style = new ol.style.Style();
it('creates a new layer', function() {
var layer = new ol.layer.Vector({source: source});
expect(layer).to.be.a(ol.layer.Vector);
expect(layer).to.be.a(ol.layer.Layer);
});
it('accepts a style option with a single style', function() {
var layer = new ol.layer.Vector({
source: source,
style: style
});
var styleFunction = layer.getStyleFunction();
expect(styleFunction()).to.eql([style]);
});
it('accepts a style option with an array of styles', function() {
var layer = new ol.layer.Vector({
source: source,
style: [style]
});
var styleFunction = layer.getStyleFunction();
expect(styleFunction()).to.eql([style]);
});
it('accepts a style option with a style function', function() {
var layer = new ol.layer.Vector({
source: source,
style: function(feature, resolution) {
return [style];
}
});
var styleFunction = layer.getStyleFunction();
expect(styleFunction()).to.eql([style]);
});
});
});
goog.require('ol.layer.Layer');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');