Tests for get/setStyleFunction
It would be nice to also test the following:
it('does not return user set property with the same name', function() {
var feature = new ol.Feature({
whatever: 'some value',
styleFunction: 'another value'
});
expect(feature.getStyleFunction()).to.be(undefined);
});
Unfortunately, in uncompiled code (or if we export `setStyleFunction`) this does not work. Same goes for user set `id` properties (this will set our internal `id_` property). See #1672.
This commit is contained in:
@@ -207,6 +207,59 @@ describe('ol.Feature', function() {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('#getStyleFunction()', function() {
|
||||||
|
|
||||||
|
var styleFunction = function(feature, resolution) {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
it('returns undefined after construction', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
expect(feature.getStyleFunction()).to.be(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns the function passed to setStyleFunction', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.setStyleFunction(styleFunction);
|
||||||
|
expect(feature.getStyleFunction()).to.be(styleFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('does not get confused with user "styleFunction" property', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.set('styleFunction', 'foo');
|
||||||
|
expect(feature.getStyleFunction()).to.be(undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: also assert that 'styleFunction' passed to the constructor is
|
||||||
|
// not confused with the internal 'styleFunction_'.
|
||||||
|
// See https://github.com/openlayers/ol3/issues/1672
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('#setStyleFunction()', function() {
|
||||||
|
|
||||||
|
var styleFunction = function(feature, resolution) {
|
||||||
|
return null;
|
||||||
|
};
|
||||||
|
|
||||||
|
it('sets the style function', function() {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.setStyleFunction(styleFunction);
|
||||||
|
expect(feature.getStyleFunction()).to.be(styleFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('dispatches a change event', function(done) {
|
||||||
|
var feature = new ol.Feature();
|
||||||
|
feature.on('change', function() {
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
feature.setStyleFunction(styleFunction);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('ol.feature.createStyleFunction()', function() {
|
describe('ol.feature.createStyleFunction()', function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user