Symbolizers with method for creating literals
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
goog.provide('ol.test.style.Line');
|
||||
|
||||
describe('ol.style.Line', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('accepts literal values', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
strokeStyle: '#BADA55',
|
||||
strokeWidth: 3
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Line);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
strokeWidth: ol.Expression('widthAttr')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Line);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#createLiteral()', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Line({
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
strokeWidth: ol.Expression('widthAttr')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature(undefined, {
|
||||
value: 42,
|
||||
widthAttr: 1.5
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.LiteralLine);
|
||||
expect(literal.opacity).toBe(42 / 100);
|
||||
expect(literal.strokeWidth).toBe(1.5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Expression');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.style.Line');
|
||||
goog.require('ol.style.LiteralLine');
|
||||
@@ -0,0 +1,51 @@
|
||||
goog.provide('ol.test.style.Polygon');
|
||||
|
||||
describe('ol.style.Polygon', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('accepts literal values', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
fillStyle: '#BADA55',
|
||||
strokeWidth: 3
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
fillStyle: ol.Expression('fillAttr')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#createLiteral()', function() {
|
||||
|
||||
it('evaluates expressions with the given feature', function() {
|
||||
var symbolizer = new ol.style.Polygon({
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
fillStyle: new ol.Expression('fillAttr')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature(undefined, {
|
||||
value: 42,
|
||||
fillAttr: '#ff0000'
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.LiteralPolygon);
|
||||
expect(literal.opacity).toBe(42 / 100);
|
||||
expect(literal.fillStyle).toBe('#ff0000');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Expression');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.style.Polygon');
|
||||
goog.require('ol.style.LiteralPolygon');
|
||||
@@ -0,0 +1,51 @@
|
||||
goog.provide('ol.test.style.Shape');
|
||||
|
||||
describe('ol.style.Shape', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
|
||||
it('accepts literal values', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
size: 4,
|
||||
fillStyle: '#BADA55'
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Shape);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
var symbolizer = new ol.style.Shape({
|
||||
size: new ol.Expression('sizeAttr'),
|
||||
strokeStyle: ol.Expression('color')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Shape);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#createLiteral()', 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')
|
||||
});
|
||||
|
||||
var feature = new ol.Feature(undefined, {
|
||||
sizeAttr: 42,
|
||||
opacityAttr: 0.4
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.LiteralShape);
|
||||
expect(literal.size).toBe(42);
|
||||
expect(literal.opacity).toBe(0.4);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
goog.require('ol.Expression');
|
||||
goog.require('ol.Feature');
|
||||
goog.require('ol.style.Shape');
|
||||
goog.require('ol.style.LiteralShape');
|
||||
Reference in New Issue
Block a user