diff --git a/test/spec/ol/layer/vectorlayer.test.js b/test/spec/ol/layer/vectorlayer.test.js new file mode 100644 index 0000000000..3d25c62ac6 --- /dev/null +++ b/test/spec/ol/layer/vectorlayer.test.js @@ -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');