Allow passing undefined to ol.layer.Vector#setStyle

This commit is contained in:
Éric Lemoine
2014-08-27 09:38:08 +02:00
parent 68b3691cd6
commit 9cc0841efb
2 changed files with 28 additions and 19 deletions

View File

@@ -50,22 +50,21 @@ describe('ol.layer.Vector', function() {
describe('#setStyle()', function() {
var source = new ol.source.Vector();
var style = new ol.style.Style();
var layer, style;
beforeEach(function() {
layer = new ol.layer.Vector({
source: new ol.source.Vector()
});
style = new ol.style.Style();
});
it('allows the style to be set after construction', function() {
var layer = new ol.layer.Vector({
source: source
});
layer.setStyle(style);
expect(layer.getStyle()).to.be(style);
});
it('dispatches the change event', function(done) {
var layer = new ol.layer.Vector({
source: source
});
layer.on('change', function() {
done();
});
@@ -73,15 +72,25 @@ describe('ol.layer.Vector', function() {
});
it('updates the internal style function', function() {
var layer = new ol.layer.Vector({
source: source
});
expect(layer.getStyleFunction()).to.be(ol.style.defaultStyleFunction);
layer.setStyle(style);
expect(layer.getStyleFunction()).not.to.be(
ol.style.defaultStyleFunction);
});
it('allows setting an null style', function() {
layer.setStyle(null);
expect(layer.getStyle()).to.be(null);
expect(layer.getStyleFunction()).to.be(undefined);
});
it('sets the default style when passing undefined', function() {
layer.setStyle(style);
layer.setStyle(undefined);
expect(layer.getStyle()).to.be(ol.style.defaultStyleFunction);
expect(layer.getStyleFunction()).to.be(ol.style.defaultStyleFunction);
});
});
describe('#getStyle()', function() {