Converted "vector" branch unit tests to mocha, expect.js and sinon
This commit is contained in:
@@ -20,8 +20,8 @@ describe('ol.style.LineLiteral', function() {
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).toBe(true);
|
||||
expect(literal.equals(differentLiteral)).toBe(false);
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -37,7 +37,7 @@ describe('ol.style.Line', function() {
|
||||
strokeColor: '#BADA55',
|
||||
strokeWidth: 3
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Line);
|
||||
expect(symbolizer).to.be.a(ol.style.Line);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
@@ -45,7 +45,7 @@ describe('ol.style.Line', function() {
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
strokeWidth: ol.Expression('widthAttr')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Line);
|
||||
expect(symbolizer).to.be.a(ol.style.Line);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -64,9 +64,9 @@ describe('ol.style.Line', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.LineLiteral);
|
||||
expect(literal.opacity).toBe(42 / 100);
|
||||
expect(literal.strokeWidth).toBe(1.5);
|
||||
expect(literal).to.be.a(ol.style.LineLiteral);
|
||||
expect(literal.opacity).to.be(42 / 100);
|
||||
expect(literal.strokeWidth).to.be(1.5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -23,8 +23,8 @@ describe('ol.style.PolygonLiteral', function() {
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).toBe(true);
|
||||
expect(literal.equals(differentLiteral)).toBe(false);
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -40,7 +40,7 @@ describe('ol.style.Polygon', function() {
|
||||
fillColor: '#BADA55',
|
||||
strokeWidth: 3
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||
expect(symbolizer).to.be.a(ol.style.Polygon);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
@@ -48,7 +48,7 @@ describe('ol.style.Polygon', function() {
|
||||
opacity: new ol.Expression('value / 100'),
|
||||
fillColor: new ol.Expression('fillAttr')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
||||
expect(symbolizer).to.be.a(ol.style.Polygon);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -67,10 +67,10 @@ describe('ol.style.Polygon', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
||||
expect(literal.opacity).toBe(42 / 100);
|
||||
expect(literal.fillColor).toBe('#ff0000');
|
||||
expect(literal.strokeColor).toBeUndefined();
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.opacity).to.be(42 / 100);
|
||||
expect(literal.fillColor).to.be('#ff0000');
|
||||
expect(literal.strokeColor).to.be(undefined);
|
||||
});
|
||||
|
||||
it('applies default strokeWidth if only strokeColor is given', function() {
|
||||
@@ -79,10 +79,10 @@ describe('ol.style.Polygon', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
||||
expect(literal.strokeColor).toBe('#ff0000');
|
||||
expect(literal.strokeWidth).toBe(1.5);
|
||||
expect(literal.fillColor).toBeUndefined();
|
||||
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||
expect(literal.strokeColor).to.be('#ff0000');
|
||||
expect(literal.strokeWidth).to.be(1.5);
|
||||
expect(literal.fillColor).to.be(undefined);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -8,21 +8,21 @@ describe('ol.style.Rule', function() {
|
||||
|
||||
it('returns true for a rule without filter', function() {
|
||||
rule = new ol.style.Rule({});
|
||||
expect(rule.applies(feature)).toBe(true);
|
||||
expect(rule.applies(feature)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns false when the rule does not apply', function() {
|
||||
rule = new ol.style.Rule({
|
||||
filter: new ol.filter.Filter(function() { return false; })
|
||||
});
|
||||
expect(rule.applies(feature)).toBe(false);
|
||||
expect(rule.applies(feature)).to.be(false);
|
||||
});
|
||||
|
||||
it('returns true when the rule applies', function() {
|
||||
rule = new ol.style.Rule({
|
||||
filter: new ol.filter.Filter(function() { return true; })
|
||||
});
|
||||
expect(rule.applies(feature)).toBe(true);
|
||||
expect(rule.applies(feature)).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ describe('ol.style.ShapeLiteral', function() {
|
||||
strokeWidth: 3,
|
||||
opacity: 1
|
||||
});
|
||||
expect(literal.equals(equalLiteral)).toBe(true);
|
||||
expect(literal.equals(differentLiteral)).toBe(false);
|
||||
expect(literal.equals(equalLiteral)).to.be(true);
|
||||
expect(literal.equals(differentLiteral)).to.be(false);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -46,7 +46,7 @@ describe('ol.style.Shape', function() {
|
||||
size: 4,
|
||||
fillColor: '#BADA55'
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Shape);
|
||||
expect(symbolizer).to.be.a(ol.style.Shape);
|
||||
});
|
||||
|
||||
it('accepts expressions', function() {
|
||||
@@ -54,7 +54,7 @@ describe('ol.style.Shape', function() {
|
||||
size: new ol.Expression('sizeAttr'),
|
||||
strokeColor: new ol.Expression('color')
|
||||
});
|
||||
expect(symbolizer).toBeA(ol.style.Shape);
|
||||
expect(symbolizer).to.be.a(ol.style.Shape);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -74,9 +74,9 @@ describe('ol.style.Shape', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
||||
expect(literal.size).toBe(42);
|
||||
expect(literal.opacity).toBe(0.4);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(42);
|
||||
expect(literal.opacity).to.be(0.4);
|
||||
});
|
||||
|
||||
it('can be called without a feature', function() {
|
||||
@@ -89,12 +89,12 @@ describe('ol.style.Shape', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral();
|
||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
||||
expect(literal.size).toBe(10);
|
||||
expect(literal.opacity).toBe(1);
|
||||
expect(literal.fillColor).toBe('#BADA55');
|
||||
expect(literal.strokeColor).toBe('#013');
|
||||
expect(literal.strokeWidth).toBe(2);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(10);
|
||||
expect(literal.opacity).to.be(1);
|
||||
expect(literal.fillColor).to.be('#BADA55');
|
||||
expect(literal.strokeColor).to.be('#013');
|
||||
expect(literal.strokeWidth).to.be(2);
|
||||
});
|
||||
|
||||
it('applies default type if none provided', function() {
|
||||
@@ -110,9 +110,9 @@ describe('ol.style.Shape', function() {
|
||||
});
|
||||
|
||||
var literal = symbolizer.createLiteral(feature);
|
||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
||||
expect(literal.size).toBe(42);
|
||||
expect(literal.opacity).toBe(0.4);
|
||||
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(literal.size).to.be(42);
|
||||
expect(literal.opacity).to.be(0.4);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -23,10 +23,10 @@ describe('ol.style.Style', function() {
|
||||
});
|
||||
var feature = new ol.Feature();
|
||||
feature.set('foo', 'bar');
|
||||
expect(style.apply(feature).length).toBe(1);
|
||||
expect(style.apply(feature)[0].fillColor).toBe('#BADA55');
|
||||
expect(style.apply(feature).length).to.be(1);
|
||||
expect(style.apply(feature)[0].fillColor).to.be('#BADA55');
|
||||
feature.set('foo', 'baz');
|
||||
expect(style.apply(feature).length).toBe(0);
|
||||
expect(style.apply(feature).length).to.be(0);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -35,27 +35,27 @@ describe('ol.style.Style', function() {
|
||||
var feature = new ol.Feature();
|
||||
|
||||
it('returns an empty array for features without geometry', function() {
|
||||
expect(ol.style.Style.applyDefaultStyle(feature).length).toBe(0);
|
||||
expect(ol.style.Style.applyDefaultStyle(feature).length).to.be(0);
|
||||
});
|
||||
|
||||
it('returns an array with the Shape default for points', function() {
|
||||
feature.setGeometry(new ol.geom.Point([0, 0]));
|
||||
var symbolizers = ol.style.Style.applyDefaultStyle(feature);
|
||||
expect(symbolizers.length).toBe(1);
|
||||
expect(symbolizers[0]).toBeA(ol.style.ShapeLiteral);
|
||||
expect(symbolizers[0].equals(ol.style.ShapeDefaults)).toBe(true);
|
||||
expect(symbolizers.length).to.be(1);
|
||||
expect(symbolizers[0]).to.be.a(ol.style.ShapeLiteral);
|
||||
expect(symbolizers[0].equals(ol.style.ShapeDefaults)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns an array with the Line default for lines', function() {
|
||||
feature.setGeometry(new ol.geom.LineString([[0, 0], [1, 1]]));
|
||||
expect(ol.style.Style.applyDefaultStyle(feature)[0]
|
||||
.equals(ol.style.LineDefaults)).toBe(true);
|
||||
.equals(ol.style.LineDefaults)).to.be(true);
|
||||
});
|
||||
|
||||
it('returns an array with the Polygon default for polygons', function() {
|
||||
feature.setGeometry(new ol.geom.Polygon([[[0, 0], [1, 1], [0, 0]]]));
|
||||
expect(ol.style.Style.applyDefaultStyle(feature)[0]
|
||||
.equals(ol.style.PolygonDefaults)).toBe(true);
|
||||
.equals(ol.style.PolygonDefaults)).to.be(true);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user