Common code for creating a style function

This commit is contained in:
Tim Schaub
2014-02-07 13:25:21 -07:00
parent 6abb691224
commit c64c24d3dc
5 changed files with 72 additions and 82 deletions

View File

@@ -209,8 +209,39 @@ 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();
});
});
goog.require('goog.events');
goog.require('goog.object');
goog.require('ol.Feature');
goog.require('ol.feature');
goog.require('ol.geom.Point');
goog.require('ol.style.Style');