Enforce that either stroke or fill is provided

This commit is contained in:
Tim Schaub
2013-03-06 02:18:27 +01:00
parent c0c8faaf9f
commit ac10bb6ca5
3 changed files with 117 additions and 40 deletions

View File

@@ -52,7 +52,7 @@ describe('ol.style.Shape', function() {
it('accepts expressions', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
strokeStyle: ol.Expression('color')
strokeStyle: new ol.Expression('color')
});
expect(symbolizer).toBeA(ol.style.Shape);
});
@@ -64,7 +64,44 @@ describe('ol.style.Shape', function() {
it('evaluates expressions with the given feature', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
opacity: new ol.Expression('opacityAttr')
opacity: new ol.Expression('opacityAttr'),
fillStyle: '#BADA55'
});
var feature = new ol.Feature({
sizeAttr: 42,
opacityAttr: 0.4
});
var literal = symbolizer.createLiteral(feature);
expect(literal).toBeA(ol.style.ShapeLiteral);
expect(literal.size).toBe(42);
expect(literal.opacity).toBe(0.4);
});
it('can be called without a feature', function() {
var symbolizer = new ol.style.Shape({
size: 10,
opacity: 1,
fillStyle: '#BADA55',
strokeStyle: '#013',
strokeWidth: 2
});
var literal = symbolizer.createLiteral();
expect(literal).toBeA(ol.style.ShapeLiteral);
expect(literal.size).toBe(10);
expect(literal.opacity).toBe(1);
expect(literal.fillStyle).toBe('#BADA55');
expect(literal.strokeStyle).toBe('#013');
expect(literal.strokeWidth).toBe(2);
});
it('applies default type if none provided', function() {
var symbolizer = new ol.style.Shape({
size: new ol.Expression('sizeAttr'),
opacity: new ol.Expression('opacityAttr'),
fillStyle: '#BADA55'
});
var feature = new ol.Feature({