Give precedence to feature style

This commit is contained in:
Antoine Abt
2014-07-10 12:11:02 +02:00
parent 0b9936107d
commit 60f1874766
14 changed files with 172 additions and 176 deletions

View File

@@ -411,35 +411,6 @@ describe('ol.Feature', function() {
});
describe('ol.feature.createStyleFunction()', function() {
var style = new ol.style.Style();
it('creates a style function from a single style', function() {
var styleFunction = ol.feature.createStyleFunction(style);
expect(styleFunction()).to.eql([style]);
});
it('creates a style function from an array of styles', function() {
var styleFunction = ol.feature.createStyleFunction([style]);
expect(styleFunction()).to.eql([style]);
});
it('passes through a function', function() {
var original = function() {
return [style];
};
var styleFunction = ol.feature.createStyleFunction(original);
expect(styleFunction).to.be(original);
});
it('throws on (some) unexpected input', function() {
expect(function() {
ol.feature.createStyleFunction({bogus: 'input'});
}).to.throwException();
});
});
describe('ol.feature.createFeatureStyleFunction()', function() {
var style = new ol.style.Style();

View File

@@ -1,5 +1,7 @@
goog.provide('ol.test.layer.Vector');
goog.require('ol.feature');
describe('ol.layer.Vector', function() {
describe('constructor', function() {
@@ -74,9 +76,10 @@ describe('ol.layer.Vector', function() {
var layer = new ol.layer.Vector({
source: source
});
expect(layer.getStyleFunction()).to.be(undefined);
expect(layer.getStyleFunction()).to.be(ol.style.defaults.styleFunction);
layer.setStyle(style);
expect(layer.getStyleFunction()).to.be.a('function');
expect(layer.getStyleFunction()).not.to.be(
ol.feature.defaultStyleFunction);
});
});
@@ -91,7 +94,7 @@ describe('ol.layer.Vector', function() {
source: source
});
expect(layer.getStyle()).to.be(null);
expect(layer.getStyle()).to.be(ol.style.defaults.styleFunction);
layer.setStyle(style);
expect(layer.getStyle()).to.be(style);
@@ -115,3 +118,4 @@ goog.require('ol.layer.Layer');
goog.require('ol.layer.Vector');
goog.require('ol.source.Vector');
goog.require('ol.style.Style');
goog.require('ol.style.defaults');

View File

@@ -0,0 +1,32 @@
goog.provide('ol.test.style.Style');
describe('ol.style.createStyleFunction()', function() {
var style = new ol.style.Style();
it('creates a style function from a single style', function() {
var styleFunction = ol.style.createStyleFunction(style);
expect(styleFunction()).to.eql([style]);
});
it('creates a style function from an array of styles', function() {
var styleFunction = ol.style.createStyleFunction([style]);
expect(styleFunction()).to.eql([style]);
});
it('passes through a function', function() {
var original = function() {
return [style];
};
var styleFunction = ol.style.createStyleFunction(original);
expect(styleFunction).to.be(original);
});
it('throws on (some) unexpected input', function() {
expect(function() {
ol.style.createStyleFunction({bogus: 'input'});
}).to.throwException();
});
});
goog.require('ol.style.Style');