Converted "vector" branch unit tests to mocha, expect.js and sinon
This commit is contained in:
@@ -5,7 +5,7 @@ describe('ol.Expression', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('creates an expression', function() {
|
it('creates an expression', function() {
|
||||||
var exp = new ol.Expression('foo');
|
var exp = new ol.Expression('foo');
|
||||||
expect(exp).toBeA(ol.Expression);
|
expect(exp).to.be.a(ol.Expression);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ describe('ol.Expression', function() {
|
|||||||
for (var i = 0, ii = cases.length; i < ii; ++i) {
|
for (var i = 0, ii = cases.length; i < ii; ++i) {
|
||||||
c = cases[i];
|
c = cases[i];
|
||||||
exp = new ol.Expression(c.source);
|
exp = new ol.Expression(c.source);
|
||||||
expect(exp.evaluate()).toBe(c.result);
|
expect(exp.evaluate()).to.be(c.result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,8 +41,8 @@ describe('ol.Expression', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var exp = new ol.Expression('this.works ? "yes" : "no"');
|
var exp = new ol.Expression('this.works ? "yes" : "no"');
|
||||||
expect(exp.evaluate(new Thing())).toBe('yes');
|
expect(exp.evaluate(new Thing())).to.be('yes');
|
||||||
expect(exp.evaluate({})).toBe('no');
|
expect(exp.evaluate({})).to.be('no');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts an optional scope argument', function() {
|
it('accepts an optional scope argument', function() {
|
||||||
@@ -57,18 +57,18 @@ describe('ol.Expression', function() {
|
|||||||
|
|
||||||
// access two members in the scope
|
// access two members in the scope
|
||||||
exp = new ol.Expression('greeting + punctuation');
|
exp = new ol.Expression('greeting + punctuation');
|
||||||
expect(exp.evaluate({}, scope)).toBe('hello world!');
|
expect(exp.evaluate({}, scope)).to.be('hello world!');
|
||||||
|
|
||||||
// call a function in the scope
|
// call a function in the scope
|
||||||
exp = new ol.Expression(
|
exp = new ol.Expression(
|
||||||
'pick([10, 42, "chicken"], 2) + Math.floor(Math.PI)');
|
'pick([10, 42, "chicken"], 2) + Math.floor(Math.PI)');
|
||||||
expect(exp.evaluate({}, scope)).toBe('chicken3');
|
expect(exp.evaluate({}, scope)).to.be('chicken3');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws on error', function() {
|
it('throws on error', function() {
|
||||||
var exp = new ol.Expression('@*)$(&');
|
var exp = new ol.Expression('@*)$(&');
|
||||||
expect(function() {exp.evaluate()}).toThrow();
|
expect(function() {exp.evaluate()}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ describe('ol.Feature', function() {
|
|||||||
|
|
||||||
it('creates a new feature', function() {
|
it('creates a new feature', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
expect(feature).toBeA(ol.Feature);
|
expect(feature).to.be.a(ol.Feature);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('takes attribute values', function() {
|
it('takes attribute values', function() {
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
});
|
});
|
||||||
expect(feature.get('foo')).toBe('bar');
|
expect(feature.get('foo')).to.be('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('will set the default geometry', function() {
|
it('will set the default geometry', function() {
|
||||||
@@ -22,8 +22,8 @@ describe('ol.Feature', function() {
|
|||||||
foo: 'bar'
|
foo: 'bar'
|
||||||
});
|
});
|
||||||
var geometry = feature.getGeometry();
|
var geometry = feature.getGeometry();
|
||||||
expect(geometry).toBeA(ol.geom.Point);
|
expect(geometry).to.be.a(ol.geom.Point);
|
||||||
expect(feature.get('loc')).toBe(geometry);
|
expect(feature.get('loc')).to.be(geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -35,19 +35,19 @@ describe('ol.Feature', function() {
|
|||||||
a: 'first',
|
a: 'first',
|
||||||
b: 'second'
|
b: 'second'
|
||||||
});
|
});
|
||||||
expect(feature.get('a')).toBe('first');
|
expect(feature.get('a')).to.be('first');
|
||||||
expect(feature.get('b')).toBe('second');
|
expect(feature.get('b')).to.be('second');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns undefined for unset attributes', function() {
|
it('returns undefined for unset attributes', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
expect(feature.get('a')).toBeUndefined();
|
expect(feature.get('a')).to.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns values set by set', function() {
|
it('returns values set by set', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.set('a', 'b');
|
feature.set('a', 'b');
|
||||||
expect(feature.get('a')).toBe('b');
|
expect(feature.get('a')).to.be('b');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -65,11 +65,11 @@ describe('ol.Feature', function() {
|
|||||||
var attributes = feature.getAttributes();
|
var attributes = feature.getAttributes();
|
||||||
|
|
||||||
var keys = goog.object.getKeys(attributes);
|
var keys = goog.object.getKeys(attributes);
|
||||||
expect(keys.sort()).toEqual(['foo', 'loc', 'ten']);
|
expect(keys.sort()).to.eql(['foo', 'loc', 'ten']);
|
||||||
|
|
||||||
expect(attributes.foo).toBe('bar');
|
expect(attributes.foo).to.be('bar');
|
||||||
expect(attributes.loc).toBe(point);
|
expect(attributes.loc).to.be(point);
|
||||||
expect(attributes.ten).toBe(10);
|
expect(attributes.ten).to.be(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -81,33 +81,33 @@ describe('ol.Feature', function() {
|
|||||||
|
|
||||||
it('returns null for no geometry', function() {
|
it('returns null for no geometry', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
expect(feature.getGeometry()).toBeNull();
|
expect(feature.getGeometry()).to.be(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets the geometry set at construction', function() {
|
it('gets the geometry set at construction', function() {
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
geom: point
|
geom: point
|
||||||
});
|
});
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets any geometry set by setGeometry', function() {
|
it('gets any geometry set by setGeometry', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.setGeometry(point);
|
feature.setGeometry(point);
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
|
|
||||||
var point2 = new ol.geom.Point([1, 2]);
|
var point2 = new ol.geom.Point([1, 2]);
|
||||||
feature.setGeometry(point2);
|
feature.setGeometry(point2);
|
||||||
expect(feature.getGeometry()).toBe(point2);
|
expect(feature.getGeometry()).to.be(point2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets the first geometry set by set', function() {
|
it('gets the first geometry set by set', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.set('foo', point);
|
feature.set('foo', point);
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
|
|
||||||
feature.set('bar', new ol.geom.Point([1, 2]));
|
feature.set('bar', new ol.geom.Point([1, 2]));
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -120,7 +120,7 @@ describe('ol.Feature', function() {
|
|||||||
b: 'second'
|
b: 'second'
|
||||||
});
|
});
|
||||||
feature.set('a', 'new');
|
feature.set('a', 'new');
|
||||||
expect(feature.get('a')).toBe('new');
|
expect(feature.get('a')).to.be('new');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be used to set the geometry', function() {
|
it('can be used to set the geometry', function() {
|
||||||
@@ -129,8 +129,8 @@ describe('ol.Feature', function() {
|
|||||||
loc: new ol.geom.Point([1, 2])
|
loc: new ol.geom.Point([1, 2])
|
||||||
});
|
});
|
||||||
feature.set('loc', point);
|
feature.set('loc', point);
|
||||||
expect(feature.get('loc')).toBe(point);
|
expect(feature.get('loc')).to.be(point);
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be used to set attributes with arbitrary names', function() {
|
it('can be used to set attributes with arbitrary names', function() {
|
||||||
@@ -138,14 +138,14 @@ describe('ol.Feature', function() {
|
|||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
|
|
||||||
feature.set('toString', 'string');
|
feature.set('toString', 'string');
|
||||||
expect(feature.get('toString')).toBe('string');
|
expect(feature.get('toString')).to.be('string');
|
||||||
expect(typeof feature.toString).toBe('function');
|
expect(typeof feature.toString).to.be('function');
|
||||||
|
|
||||||
feature.set('getGeometry', 'x');
|
feature.set('getGeometry', 'x');
|
||||||
expect(feature.get('getGeometry')).toBe('x');
|
expect(feature.get('getGeometry')).to.be('x');
|
||||||
|
|
||||||
feature.set('geom', new ol.geom.Point([1, 2]));
|
feature.set('geom', new ol.geom.Point([1, 2]));
|
||||||
expect(feature.getGeometry()).toBeA(ol.geom.Point);
|
expect(feature.getGeometry()).to.be.a(ol.geom.Point);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -158,37 +158,37 @@ describe('ol.Feature', function() {
|
|||||||
it('sets the default geometry', function() {
|
it('sets the default geometry', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.setGeometry(point);
|
feature.setGeometry(point);
|
||||||
expect(feature.get(ol.Feature.DEFAULT_GEOMETRY)).toBe(point);
|
expect(feature.get(ol.Feature.DEFAULT_GEOMETRY)).to.be(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('replaces previous default geometry', function() {
|
it('replaces previous default geometry', function() {
|
||||||
var feature = new ol.Feature({
|
var feature = new ol.Feature({
|
||||||
geom: point
|
geom: point
|
||||||
});
|
});
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
|
|
||||||
var point2 = new ol.geom.Point([1, 2]);
|
var point2 = new ol.geom.Point([1, 2]);
|
||||||
feature.setGeometry(point2);
|
feature.setGeometry(point2);
|
||||||
expect(feature.getGeometry()).toBe(point2);
|
expect(feature.getGeometry()).to.be(point2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets any geometry set by setGeometry', function() {
|
it('gets any geometry set by setGeometry', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.setGeometry(point);
|
feature.setGeometry(point);
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
|
|
||||||
var point2 = new ol.geom.Point([1, 2]);
|
var point2 = new ol.geom.Point([1, 2]);
|
||||||
feature.setGeometry(point2);
|
feature.setGeometry(point2);
|
||||||
expect(feature.getGeometry()).toBe(point2);
|
expect(feature.getGeometry()).to.be(point2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('gets the first geometry set by set', function() {
|
it('gets the first geometry set by set', function() {
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.set('foo', point);
|
feature.set('foo', point);
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
|
|
||||||
feature.set('bar', new ol.geom.Point([1, 2]));
|
feature.set('bar', new ol.geom.Point([1, 2]));
|
||||||
expect(feature.getGeometry()).toBe(point);
|
expect(feature.getGeometry()).to.be(point);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ describe('ol.filter.Extent', function() {
|
|||||||
describe('#getExtent()', function() {
|
describe('#getExtent()', function() {
|
||||||
|
|
||||||
it('returns the configured extent', function() {
|
it('returns the configured extent', function() {
|
||||||
expect(filter.getExtent()).toBe(extent);
|
expect(filter.getExtent()).to.be(extent);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -22,9 +22,9 @@ describe('ol.filter.Extent', function() {
|
|||||||
|
|
||||||
it('returns true if a feature intersects, false if not', function() {
|
it('returns true if a feature intersects, false if not', function() {
|
||||||
expect(filter.applies(new ol.Feature({g: new ol.geom.Point([44, 89])})))
|
expect(filter.applies(new ol.Feature({g: new ol.geom.Point([44, 89])})))
|
||||||
.toBe(true);
|
.to.be(true);
|
||||||
expect(filter.applies(new ol.Feature({g: new ol.geom.Point([46, 91])})))
|
expect(filter.applies(new ol.Feature({g: new ol.geom.Point([46, 91])})))
|
||||||
.toBe(false);
|
.to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ describe('ol.filter.Geometry', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('creates a new filter', function() {
|
it('creates a new filter', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POINT);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POINT);
|
||||||
expect(filter).toBeA(ol.filter.Geometry);
|
expect(filter).to.be.a(ol.filter.Geometry);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -14,33 +14,33 @@ describe('ol.filter.Geometry', function() {
|
|||||||
|
|
||||||
it('works for point', function() {
|
it('works for point', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POINT);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POINT);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.POINT);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.POINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for linestring', function() {
|
it('works for linestring', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.LINESTRING);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.LINESTRING);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.LINESTRING);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.LINESTRING);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for polygon', function() {
|
it('works for polygon', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POLYGON);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.POLYGON);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.POLYGON);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.POLYGON);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for multi-point', function() {
|
it('works for multi-point', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.MULTIPOINT);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.MULTIPOINT);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.MULTIPOINT);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.MULTIPOINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for multi-linestring', function() {
|
it('works for multi-linestring', function() {
|
||||||
var filter = new ol.filter.Geometry(
|
var filter = new ol.filter.Geometry(
|
||||||
ol.filter.GeometryType.MULTILINESTRING);
|
ol.filter.GeometryType.MULTILINESTRING);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.MULTILINESTRING);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.MULTILINESTRING);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for multi-polygon', function() {
|
it('works for multi-polygon', function() {
|
||||||
var filter = new ol.filter.Geometry(ol.filter.GeometryType.MULTIPOLYGON);
|
var filter = new ol.filter.Geometry(ol.filter.GeometryType.MULTIPOLYGON);
|
||||||
expect(filter.getType()).toBe(ol.filter.GeometryType.MULTIPOLYGON);
|
expect(filter.getType()).to.be(ol.filter.GeometryType.MULTIPOLYGON);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,8 +14,8 @@ describe('ol.geom.GeometryCollection', function() {
|
|||||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||||
expect(multi).toBeA(ol.geom.GeometryCollection);
|
expect(multi).to.be.a(ol.geom.GeometryCollection);
|
||||||
expect(multi).toBeA(ol.geom.Geometry);
|
expect(multi).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -28,10 +28,10 @@ describe('ol.geom.GeometryCollection', function() {
|
|||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||||
|
|
||||||
expect(multi.components.length).toBe(3);
|
expect(multi.components.length).to.be(3);
|
||||||
expect(multi.components[0]).toBeA(ol.geom.Point);
|
expect(multi.components[0]).to.be.a(ol.geom.Point);
|
||||||
expect(multi.components[1]).toBeA(ol.geom.LineString);
|
expect(multi.components[1]).to.be.a(ol.geom.LineString);
|
||||||
expect(multi.components[2]).toBeA(ol.geom.Polygon);
|
expect(multi.components[2]).to.be.a(ol.geom.Polygon);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -43,14 +43,14 @@ describe('ol.geom.GeometryCollection', function() {
|
|||||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
var multi = new ol.geom.GeometryCollection([point, line, poly]);
|
||||||
expect(multi.dimension).toBe(2);
|
expect(multi.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var multi = new ol.geom.GeometryCollection([
|
var multi = new ol.geom.GeometryCollection([
|
||||||
new ol.geom.Point([30, 40, 50])
|
new ol.geom.Point([30, 40, 50])
|
||||||
]);
|
]);
|
||||||
expect(multi.dimension).toBe(3);
|
expect(multi.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -62,10 +62,10 @@ describe('ol.geom.GeometryCollection', function() {
|
|||||||
var line = new ol.geom.LineString([[1, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[1, 20], [30, 40]]);
|
||||||
var multi = new ol.geom.GeometryCollection([point, line]);
|
var multi = new ol.geom.GeometryCollection([point, line]);
|
||||||
var bounds = multi.getBounds();
|
var bounds = multi.getBounds();
|
||||||
expect(bounds.minX).toBe(1);
|
expect(bounds.minX).to.be(1);
|
||||||
expect(bounds.minY).toBe(2);
|
expect(bounds.minY).to.be(2);
|
||||||
expect(bounds.maxX).toBe(30);
|
expect(bounds.maxX).to.be(30);
|
||||||
expect(bounds.maxY).toBe(40);
|
expect(bounds.maxY).to.be(40);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,13 +6,13 @@ describe('ol.geom.LinearRing', function() {
|
|||||||
|
|
||||||
it('creates a ring from an array', function() {
|
it('creates a ring from an array', function() {
|
||||||
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
||||||
expect(ring).toBeA(ol.geom.LinearRing);
|
expect(ring).to.be.a(ol.geom.LinearRing);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given mismatched dimension', function() {
|
it('throws when given mismatched dimension', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var ring = new ol.geom.LinearRing([[10, 20], [30, 40, 50]]);
|
var ring = new ol.geom.LinearRing([[10, 20], [30, 40, 50]]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -21,12 +21,12 @@ describe('ol.geom.LinearRing', function() {
|
|||||||
|
|
||||||
it('can be 2', function() {
|
it('can be 2', function() {
|
||||||
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
||||||
expect(ring.dimension).toBe(2);
|
expect(ring.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var ring = new ol.geom.LinearRing([[10, 20, 30], [40, 50, 60]]);
|
var ring = new ol.geom.LinearRing([[10, 20, 30], [40, 50, 60]]);
|
||||||
expect(ring.dimension).toBe(3);
|
expect(ring.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -35,7 +35,7 @@ describe('ol.geom.LinearRing', function() {
|
|||||||
|
|
||||||
it('is an array', function() {
|
it('is an array', function() {
|
||||||
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
var ring = new ol.geom.LinearRing([[10, 20], [30, 40]]);
|
||||||
expect(ring.getCoordinates()).toEqual([[10, 20], [30, 40]]);
|
expect(ring.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ describe('ol.geom.LineString', function() {
|
|||||||
|
|
||||||
it('creates a linestring from an array', function() {
|
it('creates a linestring from an array', function() {
|
||||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||||
expect(line).toBeA(ol.geom.LineString);
|
expect(line).to.be.a(ol.geom.LineString);
|
||||||
expect(line).toBeA(ol.geom.Geometry);
|
expect(line).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given mismatched dimension', function() {
|
it('throws when given mismatched dimension', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var line = new ol.geom.LineString([[10, 20], [30, 40, 50]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40, 50]]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts shared vertices', function() {
|
it('accepts shared vertices', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
var l1 = new ol.geom.LineString([[10, 20], [30, 40]], vertices);
|
var l1 = new ol.geom.LineString([[10, 20], [30, 40]], vertices);
|
||||||
var l2 = new ol.geom.LineString([[50, 60], [70, 80]], vertices);
|
var l2 = new ol.geom.LineString([[50, 60], [70, 80]], vertices);
|
||||||
expect(l1.getCoordinates()).toEqual([[10, 20], [30, 40]]);
|
expect(l1.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||||
expect(l2.getCoordinates()).toEqual([[50, 60], [70, 80]]);
|
expect(l2.getCoordinates()).to.eql([[50, 60], [70, 80]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -30,12 +30,12 @@ describe('ol.geom.LineString', function() {
|
|||||||
|
|
||||||
it('can be 2', function() {
|
it('can be 2', function() {
|
||||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||||
expect(line.dimension).toBe(2);
|
expect(line.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var line = new ol.geom.LineString([[10, 20, 30], [40, 50, 60]]);
|
var line = new ol.geom.LineString([[10, 20, 30], [40, 50, 60]]);
|
||||||
expect(line.dimension).toBe(3);
|
expect(line.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -45,10 +45,10 @@ describe('ol.geom.LineString', function() {
|
|||||||
it('returns the bounding extent', function() {
|
it('returns the bounding extent', function() {
|
||||||
var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [20, 30], [30, 40]]);
|
||||||
var bounds = line.getBounds();
|
var bounds = line.getBounds();
|
||||||
expect(bounds.minX).toBe(10);
|
expect(bounds.minX).to.be(10);
|
||||||
expect(bounds.minY).toBe(20);
|
expect(bounds.minY).to.be(20);
|
||||||
expect(bounds.maxX).toBe(30);
|
expect(bounds.maxX).to.be(30);
|
||||||
expect(bounds.maxY).toBe(40);
|
expect(bounds.maxY).to.be(40);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -57,7 +57,7 @@ describe('ol.geom.LineString', function() {
|
|||||||
|
|
||||||
it('returns an array', function() {
|
it('returns an array', function() {
|
||||||
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
var line = new ol.geom.LineString([[10, 20], [30, 40]]);
|
||||||
expect(line.getCoordinates()).toEqual([[10, 20], [30, 40]]);
|
expect(line.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -74,24 +74,24 @@ describe('ol.geom.LineString', function() {
|
|||||||
var id1 = l1.getSharedId();
|
var id1 = l1.getSharedId();
|
||||||
var id2 = l2.getSharedId();
|
var id2 = l2.getSharedId();
|
||||||
|
|
||||||
expect(vertices.coordinates).toEqual(
|
expect(vertices.coordinates).to.eql(
|
||||||
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
|
[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]);
|
||||||
|
|
||||||
expect(vertices.getStart(id1)).toBe(0);
|
expect(vertices.getStart(id1)).to.be(0);
|
||||||
expect(vertices.getCount(id1)).toBe(2);
|
expect(vertices.getCount(id1)).to.be(2);
|
||||||
expect(vertices.get(id1, 0, 0)).toBe(10);
|
expect(vertices.get(id1, 0, 0)).to.be(10);
|
||||||
expect(vertices.get(id1, 0, 1)).toBe(20);
|
expect(vertices.get(id1, 0, 1)).to.be(20);
|
||||||
expect(vertices.get(id1, 1, 0)).toBe(30);
|
expect(vertices.get(id1, 1, 0)).to.be(30);
|
||||||
expect(vertices.get(id1, 1, 1)).toBe(40);
|
expect(vertices.get(id1, 1, 1)).to.be(40);
|
||||||
|
|
||||||
expect(vertices.getStart(id2)).toBe(4);
|
expect(vertices.getStart(id2)).to.be(4);
|
||||||
expect(vertices.getCount(id2)).toBe(3);
|
expect(vertices.getCount(id2)).to.be(3);
|
||||||
expect(vertices.get(id2, 0, 0)).toBe(50);
|
expect(vertices.get(id2, 0, 0)).to.be(50);
|
||||||
expect(vertices.get(id2, 0, 1)).toBe(60);
|
expect(vertices.get(id2, 0, 1)).to.be(60);
|
||||||
expect(vertices.get(id2, 1, 0)).toBe(70);
|
expect(vertices.get(id2, 1, 0)).to.be(70);
|
||||||
expect(vertices.get(id2, 1, 1)).toBe(80);
|
expect(vertices.get(id2, 1, 1)).to.be(80);
|
||||||
expect(vertices.get(id2, 2, 0)).toBe(90);
|
expect(vertices.get(id2, 2, 0)).to.be(90);
|
||||||
expect(vertices.get(id2, 2, 1)).toBe(100);
|
expect(vertices.get(id2, 2, 1)).to.be(100);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
var multi = new ol.geom.MultiLineString([
|
var multi = new ol.geom.MultiLineString([
|
||||||
[[10, 20], [30, 40]],
|
[[10, 20], [30, 40]],
|
||||||
[[20, 30], [40, 50]]]);
|
[[20, 30], [40, 50]]]);
|
||||||
expect(multi).toBeA(ol.geom.MultiLineString);
|
expect(multi).to.be.a(ol.geom.MultiLineString);
|
||||||
expect(multi).toBeA(ol.geom.Geometry);
|
expect(multi).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given with insufficient dimensions', function() {
|
it('throws when given with insufficient dimensions', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var multi = new ol.geom.MultiLineString([1]);
|
var multi = new ol.geom.MultiLineString([1]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -27,9 +27,9 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
[[10, 20], [30, 40]],
|
[[10, 20], [30, 40]],
|
||||||
[[20, 30], [40, 50]]]);
|
[[20, 30], [40, 50]]]);
|
||||||
|
|
||||||
expect(multi.components.length).toBe(2);
|
expect(multi.components.length).to.be(2);
|
||||||
expect(multi.components[0]).toBeA(ol.geom.LineString);
|
expect(multi.components[0]).to.be.a(ol.geom.LineString);
|
||||||
expect(multi.components[1]).toBeA(ol.geom.LineString);
|
expect(multi.components[1]).to.be.a(ol.geom.LineString);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -41,14 +41,14 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
var multi = new ol.geom.MultiLineString([
|
var multi = new ol.geom.MultiLineString([
|
||||||
[[10, 20], [30, 40]],
|
[[10, 20], [30, 40]],
|
||||||
[[20, 30], [40, 50]]]);
|
[[20, 30], [40, 50]]]);
|
||||||
expect(multi.dimension).toBe(2);
|
expect(multi.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var multi = new ol.geom.MultiLineString([
|
var multi = new ol.geom.MultiLineString([
|
||||||
[[10, 20, 30], [30, 40, 50]],
|
[[10, 20, 30], [30, 40, 50]],
|
||||||
[[20, 30, 40], [40, 50, 60]]]);
|
[[20, 30, 40], [40, 50, 60]]]);
|
||||||
expect(multi.dimension).toBe(3);
|
expect(multi.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -60,10 +60,10 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
[[10, 20], [30, 40]],
|
[[10, 20], [30, 40]],
|
||||||
[[20, 30], [40, 50]]]);
|
[[20, 30], [40, 50]]]);
|
||||||
var bounds = multi.getBounds();
|
var bounds = multi.getBounds();
|
||||||
expect(bounds.minX).toBe(10);
|
expect(bounds.minX).to.be(10);
|
||||||
expect(bounds.minY).toBe(20);
|
expect(bounds.minY).to.be(20);
|
||||||
expect(bounds.maxX).toBe(40);
|
expect(bounds.maxX).to.be(40);
|
||||||
expect(bounds.maxY).toBe(50);
|
expect(bounds.maxY).to.be(50);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -76,7 +76,7 @@ describe('ol.geom.MultiLineString', function() {
|
|||||||
[[20, 30], [40, 50]]
|
[[20, 30], [40, 50]]
|
||||||
];
|
];
|
||||||
var multi = new ol.geom.MultiLineString(coordinates);
|
var multi = new ol.geom.MultiLineString(coordinates);
|
||||||
expect(multi.getCoordinates()).toEqual(coordinates);
|
expect(multi.getCoordinates()).to.eql(coordinates);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ describe('ol.geom.MultiPoint', function() {
|
|||||||
|
|
||||||
it('creates a multi-point from an array', function() {
|
it('creates a multi-point from an array', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||||
expect(multi).toBeA(ol.geom.MultiPoint);
|
expect(multi).to.be.a(ol.geom.MultiPoint);
|
||||||
expect(multi).toBeA(ol.geom.Geometry);
|
expect(multi).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given with insufficient dimensions', function() {
|
it('throws when given with insufficient dimensions', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var multi = new ol.geom.MultiPoint([1]);
|
var multi = new ol.geom.MultiPoint([1]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -23,9 +23,9 @@ describe('ol.geom.MultiPoint', function() {
|
|||||||
it('is an array of points', function() {
|
it('is an array of points', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||||
|
|
||||||
expect(multi.components.length).toBe(2);
|
expect(multi.components.length).to.be(2);
|
||||||
expect(multi.components[0]).toBeA(ol.geom.Point);
|
expect(multi.components[0]).to.be.a(ol.geom.Point);
|
||||||
expect(multi.components[1]).toBeA(ol.geom.Point);
|
expect(multi.components[1]).to.be.a(ol.geom.Point);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -35,12 +35,12 @@ describe('ol.geom.MultiPoint', function() {
|
|||||||
|
|
||||||
it('can be 2', function() {
|
it('can be 2', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||||
expect(multi.dimension).toBe(2);
|
expect(multi.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20, 30], [30, 40, 50]]);
|
var multi = new ol.geom.MultiPoint([[10, 20, 30], [30, 40, 50]]);
|
||||||
expect(multi.dimension).toBe(3);
|
expect(multi.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -50,10 +50,10 @@ describe('ol.geom.MultiPoint', function() {
|
|||||||
it('returns the bounding extent', function() {
|
it('returns the bounding extent', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||||
var bounds = multi.getBounds();
|
var bounds = multi.getBounds();
|
||||||
expect(bounds.minX).toBe(10);
|
expect(bounds.minX).to.be(10);
|
||||||
expect(bounds.minY).toBe(20);
|
expect(bounds.minY).to.be(20);
|
||||||
expect(bounds.maxX).toBe(30);
|
expect(bounds.maxX).to.be(30);
|
||||||
expect(bounds.maxY).toBe(40);
|
expect(bounds.maxY).to.be(40);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -62,7 +62,7 @@ describe('ol.geom.MultiPoint', function() {
|
|||||||
|
|
||||||
it('returns an array', function() {
|
it('returns an array', function() {
|
||||||
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
var multi = new ol.geom.MultiPoint([[10, 20], [30, 40]]);
|
||||||
expect(multi.getCoordinates()).toEqual([[10, 20], [30, 40]]);
|
expect(multi.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ describe('ol.geom.MultiPolygon', function() {
|
|||||||
var multi = new ol.geom.MultiPolygon([
|
var multi = new ol.geom.MultiPolygon([
|
||||||
[outer1, inner1a, inner1b],
|
[outer1, inner1a, inner1b],
|
||||||
[outer2]]);
|
[outer2]]);
|
||||||
expect(multi).toBeA(ol.geom.MultiPolygon);
|
expect(multi).to.be.a(ol.geom.MultiPolygon);
|
||||||
expect(multi).toBeA(ol.geom.Geometry);
|
expect(multi).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given with insufficient dimensions', function() {
|
it('throws when given with insufficient dimensions', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var multi = new ol.geom.MultiPolygon([1]);
|
var multi = new ol.geom.MultiPolygon([1]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -32,9 +32,9 @@ describe('ol.geom.MultiPolygon', function() {
|
|||||||
[outer1, inner1a, inner1b],
|
[outer1, inner1a, inner1b],
|
||||||
[outer2]]);
|
[outer2]]);
|
||||||
|
|
||||||
expect(multi.components.length).toBe(2);
|
expect(multi.components.length).to.be(2);
|
||||||
expect(multi.components[0]).toBeA(ol.geom.Polygon);
|
expect(multi.components[0]).to.be.a(ol.geom.Polygon);
|
||||||
expect(multi.components[1]).toBeA(ol.geom.Polygon);
|
expect(multi.components[1]).to.be.a(ol.geom.Polygon);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -46,12 +46,12 @@ describe('ol.geom.MultiPolygon', function() {
|
|||||||
var multi = new ol.geom.MultiPolygon([
|
var multi = new ol.geom.MultiPolygon([
|
||||||
[outer1, inner1a, inner1b],
|
[outer1, inner1a, inner1b],
|
||||||
[outer2]]);
|
[outer2]]);
|
||||||
expect(multi.dimension).toBe(2);
|
expect(multi.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var multi = new ol.geom.MultiPolygon([[[[10, 20, 30], [40, 50, 60]]]]);
|
var multi = new ol.geom.MultiPolygon([[[[10, 20, 30], [40, 50, 60]]]]);
|
||||||
expect(multi.dimension).toBe(3);
|
expect(multi.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -63,10 +63,10 @@ describe('ol.geom.MultiPolygon', function() {
|
|||||||
[outer1, inner1a, inner1b],
|
[outer1, inner1a, inner1b],
|
||||||
[outer2]]);
|
[outer2]]);
|
||||||
var bounds = multi.getBounds();
|
var bounds = multi.getBounds();
|
||||||
expect(bounds.minX).toBe(0);
|
expect(bounds.minX).to.be(0);
|
||||||
expect(bounds.minY).toBe(0);
|
expect(bounds.minY).to.be(0);
|
||||||
expect(bounds.maxX).toBe(20);
|
expect(bounds.maxX).to.be(20);
|
||||||
expect(bounds.maxY).toBe(50);
|
expect(bounds.maxY).to.be(50);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -79,7 +79,7 @@ describe('ol.geom.MultiPolygon', function() {
|
|||||||
[outer2]
|
[outer2]
|
||||||
];
|
];
|
||||||
var multi = new ol.geom.MultiPolygon(coordinates);
|
var multi = new ol.geom.MultiPolygon(coordinates);
|
||||||
expect(multi.getCoordinates()).toEqual(coordinates);
|
expect(multi.getCoordinates()).to.eql(coordinates);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ describe('ol.geom.Point', function() {
|
|||||||
|
|
||||||
it('creates a point from an array', function() {
|
it('creates a point from an array', function() {
|
||||||
var point = new ol.geom.Point([10, 20]);
|
var point = new ol.geom.Point([10, 20]);
|
||||||
expect(point).toBeA(ol.geom.Point);
|
expect(point).to.be.a(ol.geom.Point);
|
||||||
expect(point).toBeA(ol.geom.Geometry);
|
expect(point).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts shared vertices', function() {
|
it('accepts shared vertices', function() {
|
||||||
@@ -15,15 +15,15 @@ describe('ol.geom.Point', function() {
|
|||||||
var p1 = new ol.geom.Point([10, 20], vertices);
|
var p1 = new ol.geom.Point([10, 20], vertices);
|
||||||
var p2 = new ol.geom.Point([30, 40], vertices);
|
var p2 = new ol.geom.Point([30, 40], vertices);
|
||||||
var p3 = new ol.geom.Point([50, 60], vertices);
|
var p3 = new ol.geom.Point([50, 60], vertices);
|
||||||
expect(p1.getCoordinates()).toEqual([10, 20]);
|
expect(p1.getCoordinates()).to.eql([10, 20]);
|
||||||
expect(p2.getCoordinates()).toEqual([30, 40]);
|
expect(p2.getCoordinates()).to.eql([30, 40]);
|
||||||
expect(p3.getCoordinates()).toEqual([50, 60]);
|
expect(p3.getCoordinates()).to.eql([50, 60]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given with insufficient dimensions', function() {
|
it('throws when given with insufficient dimensions', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var point = new ol.geom.Point([1]);
|
var point = new ol.geom.Point([1]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -32,12 +32,12 @@ describe('ol.geom.Point', function() {
|
|||||||
|
|
||||||
it('can be 2', function() {
|
it('can be 2', function() {
|
||||||
var point = new ol.geom.Point([10, 20]);
|
var point = new ol.geom.Point([10, 20]);
|
||||||
expect(point.dimension).toBe(2);
|
expect(point.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var point = new ol.geom.Point([10, 20, 30]);
|
var point = new ol.geom.Point([10, 20, 30]);
|
||||||
expect(point.dimension).toBe(3);
|
expect(point.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -47,10 +47,10 @@ describe('ol.geom.Point', function() {
|
|||||||
it('returns the bounding extent', function() {
|
it('returns the bounding extent', function() {
|
||||||
var point = new ol.geom.Point([10, 20]);
|
var point = new ol.geom.Point([10, 20]);
|
||||||
var bounds = point.getBounds();
|
var bounds = point.getBounds();
|
||||||
expect(bounds.minX).toBe(10);
|
expect(bounds.minX).to.be(10);
|
||||||
expect(bounds.minY).toBe(20);
|
expect(bounds.minY).to.be(20);
|
||||||
expect(bounds.maxX).toBe(10);
|
expect(bounds.maxX).to.be(10);
|
||||||
expect(bounds.maxY).toBe(20);
|
expect(bounds.maxY).to.be(20);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -59,7 +59,7 @@ describe('ol.geom.Point', function() {
|
|||||||
|
|
||||||
it('returns an array', function() {
|
it('returns an array', function() {
|
||||||
var point = new ol.geom.Point([10, 20]);
|
var point = new ol.geom.Point([10, 20]);
|
||||||
expect(point.getCoordinates()).toEqual([10, 20]);
|
expect(point.getCoordinates()).to.eql([10, 20]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -78,23 +78,23 @@ describe('ol.geom.Point', function() {
|
|||||||
var id2 = p2.getSharedId();
|
var id2 = p2.getSharedId();
|
||||||
var id3 = p3.getSharedId();
|
var id3 = p3.getSharedId();
|
||||||
|
|
||||||
expect(vertices.coordinates).toEqual(
|
expect(vertices.coordinates).to.eql(
|
||||||
[10, 20, 30, 40, 50, 60]);
|
[10, 20, 30, 40, 50, 60]);
|
||||||
|
|
||||||
expect(vertices.getStart(id1)).toBe(0);
|
expect(vertices.getStart(id1)).to.be(0);
|
||||||
expect(vertices.getCount(id1)).toBe(1);
|
expect(vertices.getCount(id1)).to.be(1);
|
||||||
expect(vertices.get(id1, 0, 0)).toBe(10);
|
expect(vertices.get(id1, 0, 0)).to.be(10);
|
||||||
expect(vertices.get(id1, 0, 1)).toBe(20);
|
expect(vertices.get(id1, 0, 1)).to.be(20);
|
||||||
|
|
||||||
expect(vertices.getStart(id2)).toBe(2);
|
expect(vertices.getStart(id2)).to.be(2);
|
||||||
expect(vertices.getCount(id2)).toBe(1);
|
expect(vertices.getCount(id2)).to.be(1);
|
||||||
expect(vertices.get(id2, 0, 0)).toBe(30);
|
expect(vertices.get(id2, 0, 0)).to.be(30);
|
||||||
expect(vertices.get(id2, 0, 1)).toBe(40);
|
expect(vertices.get(id2, 0, 1)).to.be(40);
|
||||||
|
|
||||||
expect(vertices.getStart(id3)).toBe(4);
|
expect(vertices.getStart(id3)).to.be(4);
|
||||||
expect(vertices.getCount(id3)).toBe(1);
|
expect(vertices.getCount(id3)).to.be(1);
|
||||||
expect(vertices.get(id3, 0, 0)).toBe(50);
|
expect(vertices.get(id3, 0, 0)).to.be(50);
|
||||||
expect(vertices.get(id3, 0, 1)).toBe(60);
|
expect(vertices.get(id3, 0, 1)).to.be(60);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,14 +10,14 @@ describe('ol.geom.Polygon', function() {
|
|||||||
|
|
||||||
it('creates a polygon from an array', function() {
|
it('creates a polygon from an array', function() {
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
expect(poly).toBeA(ol.geom.Polygon);
|
expect(poly).to.be.a(ol.geom.Polygon);
|
||||||
expect(poly).toBeA(ol.geom.Geometry);
|
expect(poly).to.be.a(ol.geom.Geometry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws when given mismatched dimension', function() {
|
it('throws when given mismatched dimension', function() {
|
||||||
expect(function() {
|
expect(function() {
|
||||||
var poly = new ol.geom.Polygon([[[10, 20], [30, 40, 50]]]);
|
var poly = new ol.geom.Polygon([[[10, 20], [30, 40, 50]]]);
|
||||||
}).toThrow();
|
}).to.throwException();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts shared vertices', function() {
|
it('accepts shared vertices', function() {
|
||||||
@@ -25,9 +25,9 @@ describe('ol.geom.Polygon', function() {
|
|||||||
var p1 = new ol.geom.Polygon([outer], vertices);
|
var p1 = new ol.geom.Polygon([outer], vertices);
|
||||||
var p2 = new ol.geom.Polygon([outer, inner1], vertices);
|
var p2 = new ol.geom.Polygon([outer, inner1], vertices);
|
||||||
var p3 = new ol.geom.Polygon([outer, inner2], vertices);
|
var p3 = new ol.geom.Polygon([outer, inner2], vertices);
|
||||||
expect(p1.getCoordinates()).toEqual([outer]);
|
expect(p1.getCoordinates()).to.eql([outer]);
|
||||||
expect(p2.getCoordinates()).toEqual([outer, inner1]);
|
expect(p2.getCoordinates()).to.eql([outer, inner1]);
|
||||||
expect(p3.getCoordinates()).toEqual([outer, inner2]);
|
expect(p3.getCoordinates()).to.eql([outer, inner2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -37,10 +37,10 @@ describe('ol.geom.Polygon', function() {
|
|||||||
it('is an array of LinearRing', function() {
|
it('is an array of LinearRing', function() {
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
|
|
||||||
expect(poly.rings.length).toBe(3);
|
expect(poly.rings.length).to.be(3);
|
||||||
expect(poly.rings[0]).toBeA(ol.geom.LinearRing);
|
expect(poly.rings[0]).to.be.a(ol.geom.LinearRing);
|
||||||
expect(poly.rings[1]).toBeA(ol.geom.LinearRing);
|
expect(poly.rings[1]).to.be.a(ol.geom.LinearRing);
|
||||||
expect(poly.rings[2]).toBeA(ol.geom.LinearRing);
|
expect(poly.rings[2]).to.be.a(ol.geom.LinearRing);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -49,12 +49,12 @@ describe('ol.geom.Polygon', function() {
|
|||||||
|
|
||||||
it('can be 2', function() {
|
it('can be 2', function() {
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
expect(poly.dimension).toBe(2);
|
expect(poly.dimension).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be 3', function() {
|
it('can be 3', function() {
|
||||||
var poly = new ol.geom.Polygon([[[10, 20, 30], [40, 50, 60]]]);
|
var poly = new ol.geom.Polygon([[[10, 20, 30], [40, 50, 60]]]);
|
||||||
expect(poly.dimension).toBe(3);
|
expect(poly.dimension).to.be(3);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -64,10 +64,10 @@ describe('ol.geom.Polygon', function() {
|
|||||||
it('returns the bounding extent', function() {
|
it('returns the bounding extent', function() {
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
var bounds = poly.getBounds();
|
var bounds = poly.getBounds();
|
||||||
expect(bounds.minX).toBe(0);
|
expect(bounds.minX).to.be(0);
|
||||||
expect(bounds.minY).toBe(0);
|
expect(bounds.minY).to.be(0);
|
||||||
expect(bounds.maxX).toBe(10);
|
expect(bounds.maxX).to.be(10);
|
||||||
expect(bounds.maxY).toBe(10);
|
expect(bounds.maxY).to.be(10);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -76,7 +76,7 @@ describe('ol.geom.Polygon', function() {
|
|||||||
|
|
||||||
it('returns an array', function() {
|
it('returns an array', function() {
|
||||||
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
var poly = new ol.geom.Polygon([outer, inner1, inner2]);
|
||||||
expect(poly.getCoordinates()).toEqual([outer, inner1, inner2]);
|
expect(poly.getCoordinates()).to.eql([outer, inner1, inner2]);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('creates an instance', function() {
|
it('creates an instance', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
expect(vertices).toBeA(ol.geom.SharedVertices);
|
expect(vertices).to.be.a(ol.geom.SharedVertices);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts options', function() {
|
it('accepts options', function() {
|
||||||
@@ -14,8 +14,8 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
offset: [1, 2, 3, 4]
|
offset: [1, 2, 3, 4]
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(vertices.getDimension()).toBe(4);
|
expect(vertices.getDimension()).to.be(4);
|
||||||
expect(vertices.getOffset()).toEqual([1, 2, 3, 4]);
|
expect(vertices.getOffset()).to.eql([1, 2, 3, 4]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -24,26 +24,26 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var vertices = new ol.geom.SharedVertices({offset: [3, -1]});
|
var vertices = new ol.geom.SharedVertices({offset: [3, -1]});
|
||||||
vertices.add([[3, -1], [0, 0]]);
|
vertices.add([[3, -1], [0, 0]]);
|
||||||
vertices.add([[10, 20]]);
|
vertices.add([[10, 20]]);
|
||||||
expect(vertices.coordinates).toEqual([0, 0, -3, 1, 7, 21]);
|
expect(vertices.coordinates).to.eql([0, 0, -3, 1, 7, 21]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#add()', function() {
|
describe('#add()', function() {
|
||||||
it('adds vertex arrays to the shared coordinates', function() {
|
it('adds vertex arrays to the shared coordinates', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
expect(vertices.coordinates.length).toBe(0);
|
expect(vertices.coordinates.length).to.be(0);
|
||||||
|
|
||||||
vertices.add([[1, 2], [3, 4]]);
|
vertices.add([[1, 2], [3, 4]]);
|
||||||
expect(vertices.coordinates).toEqual([1, 2, 3, 4]);
|
expect(vertices.coordinates).to.eql([1, 2, 3, 4]);
|
||||||
|
|
||||||
vertices.add([[5, 6]]);
|
vertices.add([[5, 6]]);
|
||||||
expect(vertices.coordinates).toEqual([1, 2, 3, 4, 5, 6]);
|
expect(vertices.coordinates).to.eql([1, 2, 3, 4, 5, 6]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an identifier for coordinate access', function() {
|
it('returns an identifier for coordinate access', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
var id = vertices.add([[1, 2], [3, 4]]);
|
var id = vertices.add([[1, 2], [3, 4]]);
|
||||||
expect(typeof id).toBe('number');
|
expect(typeof id).to.be('number');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the index of the added vertices', function() {
|
it('returns the index of the added vertices', function() {
|
||||||
@@ -53,12 +53,12 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var second = vertices.add([[3, 4], [5, 6]]);
|
var second = vertices.add([[3, 4], [5, 6]]);
|
||||||
var third = vertices.add([[7, 8], [9, 10], [11, 12]]);
|
var third = vertices.add([[7, 8], [9, 10], [11, 12]]);
|
||||||
|
|
||||||
expect(vertices.coordinates).toEqual(
|
expect(vertices.coordinates).to.eql(
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
|
||||||
|
|
||||||
expect(first).toBe(0);
|
expect(first).to.be(0);
|
||||||
expect(second).toBe(1);
|
expect(second).to.be(1);
|
||||||
expect(third).toBe(2);
|
expect(third).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -69,36 +69,36 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var first = vertices.add([[1, 2], [3, 4]]);
|
var first = vertices.add([[1, 2], [3, 4]]);
|
||||||
var second = vertices.add([[5, 6]]);
|
var second = vertices.add([[5, 6]]);
|
||||||
|
|
||||||
expect(vertices.get(first, 0, 0)).toBe(1);
|
expect(vertices.get(first, 0, 0)).to.be(1);
|
||||||
expect(vertices.get(first, 0, 1)).toBe(2);
|
expect(vertices.get(first, 0, 1)).to.be(2);
|
||||||
expect(vertices.get(first, 1, 0)).toBe(3);
|
expect(vertices.get(first, 1, 0)).to.be(3);
|
||||||
expect(vertices.get(first, 1, 1)).toBe(4);
|
expect(vertices.get(first, 1, 1)).to.be(4);
|
||||||
expect(vertices.get(second, 0, 0)).toBe(5);
|
expect(vertices.get(second, 0, 0)).to.be(5);
|
||||||
expect(vertices.get(second, 0, 1)).toBe(6);
|
expect(vertices.get(second, 0, 1)).to.be(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works for non-2d vertices', function() {
|
it('works for non-2d vertices', function() {
|
||||||
var vertices = new ol.geom.SharedVertices({dimension: 3});
|
var vertices = new ol.geom.SharedVertices({dimension: 3});
|
||||||
var id = vertices.add([[1, 2, 3], [4, 5, 6]]);
|
var id = vertices.add([[1, 2, 3], [4, 5, 6]]);
|
||||||
|
|
||||||
expect(vertices.get(id, 0, 0)).toBe(1);
|
expect(vertices.get(id, 0, 0)).to.be(1);
|
||||||
expect(vertices.get(id, 0, 1)).toBe(2);
|
expect(vertices.get(id, 0, 1)).to.be(2);
|
||||||
expect(vertices.get(id, 0, 2)).toBe(3);
|
expect(vertices.get(id, 0, 2)).to.be(3);
|
||||||
expect(vertices.get(id, 1, 0)).toBe(4);
|
expect(vertices.get(id, 1, 0)).to.be(4);
|
||||||
expect(vertices.get(id, 1, 1)).toBe(5);
|
expect(vertices.get(id, 1, 1)).to.be(5);
|
||||||
expect(vertices.get(id, 1, 2)).toBe(6);
|
expect(vertices.get(id, 1, 2)).to.be(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('works when an offset is provided', function() {
|
it('works when an offset is provided', function() {
|
||||||
var vertices = new ol.geom.SharedVertices({offset: [3, 3]});
|
var vertices = new ol.geom.SharedVertices({offset: [3, 3]});
|
||||||
var id = vertices.add([[1, 2], [3, 4], [5, 6]]);
|
var id = vertices.add([[1, 2], [3, 4], [5, 6]]);
|
||||||
|
|
||||||
expect(vertices.get(id, 0, 0)).toBe(1);
|
expect(vertices.get(id, 0, 0)).to.be(1);
|
||||||
expect(vertices.get(id, 0, 1)).toBe(2);
|
expect(vertices.get(id, 0, 1)).to.be(2);
|
||||||
expect(vertices.get(id, 1, 0)).toBe(3);
|
expect(vertices.get(id, 1, 0)).to.be(3);
|
||||||
expect(vertices.get(id, 1, 1)).toBe(4);
|
expect(vertices.get(id, 1, 1)).to.be(4);
|
||||||
expect(vertices.get(id, 2, 0)).toBe(5);
|
expect(vertices.get(id, 2, 0)).to.be(5);
|
||||||
expect(vertices.get(id, 2, 1)).toBe(6);
|
expect(vertices.get(id, 2, 1)).to.be(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -109,8 +109,8 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var first = vertices.add([[2, 3], [3, 4], [4, 5]]);
|
var first = vertices.add([[2, 3], [3, 4], [4, 5]]);
|
||||||
var second = vertices.add([[5, 6], [6, 6]]);
|
var second = vertices.add([[5, 6], [6, 6]]);
|
||||||
|
|
||||||
expect(vertices.getCount(first)).toBe(3);
|
expect(vertices.getCount(first)).to.be(3);
|
||||||
expect(vertices.getCount(second)).toBe(2);
|
expect(vertices.getCount(second)).to.be(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -121,31 +121,31 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var second = vertices.add([[5, 6], [6, 6]]);
|
var second = vertices.add([[5, 6], [6, 6]]);
|
||||||
var third = vertices.add([[7, 8]]);
|
var third = vertices.add([[7, 8]]);
|
||||||
|
|
||||||
expect(vertices.getCounts()).toEqual([3, 2, 1]);
|
expect(vertices.getCounts()).to.eql([3, 2, 1]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getDimension()', function() {
|
describe('#getDimension()', function() {
|
||||||
it('returns 2 by default', function() {
|
it('returns 2 by default', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
expect(vertices.getDimension()).toBe(2);
|
expect(vertices.getDimension()).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the dimension provided to the constructor', function() {
|
it('returns the dimension provided to the constructor', function() {
|
||||||
var vertices = new ol.geom.SharedVertices({dimension: 10});
|
var vertices = new ol.geom.SharedVertices({dimension: 10});
|
||||||
expect(vertices.getDimension()).toBe(10);
|
expect(vertices.getDimension()).to.be(10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('#getOffset()', function() {
|
describe('#getOffset()', function() {
|
||||||
it('returns null by default', function() {
|
it('returns null by default', function() {
|
||||||
var vertices = new ol.geom.SharedVertices();
|
var vertices = new ol.geom.SharedVertices();
|
||||||
expect(vertices.getOffset()).toBeNull();
|
expect(vertices.getOffset()).to.be(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns the offset provided to the constructor', function() {
|
it('returns the offset provided to the constructor', function() {
|
||||||
var vertices = new ol.geom.SharedVertices({offset: [1, 2]});
|
var vertices = new ol.geom.SharedVertices({offset: [1, 2]});
|
||||||
expect(vertices.getOffset()).toEqual([1, 2]);
|
expect(vertices.getOffset()).to.eql([1, 2]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -156,13 +156,13 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var second = vertices.add([[8, 9], [10, 11]]);
|
var second = vertices.add([[8, 9], [10, 11]]);
|
||||||
var third = vertices.add([[12, 13]]);
|
var third = vertices.add([[12, 13]]);
|
||||||
|
|
||||||
expect(vertices.coordinates).toEqual(
|
expect(vertices.coordinates).to.eql(
|
||||||
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
|
[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]);
|
||||||
// 0 1 2 3 4 5 6 7 8 9 10 11
|
// 0 1 2 3 4 5 6 7 8 9 10 11
|
||||||
|
|
||||||
expect(vertices.getStart(first)).toBe(0);
|
expect(vertices.getStart(first)).to.be(0);
|
||||||
expect(vertices.getStart(second)).toBe(6);
|
expect(vertices.getStart(second)).to.be(6);
|
||||||
expect(vertices.getStart(third)).toBe(10);
|
expect(vertices.getStart(third)).to.be(10);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var second = vertices.add([[5, 6], [6, 6]]);
|
var second = vertices.add([[5, 6], [6, 6]]);
|
||||||
var third = vertices.add([[7, 8]]);
|
var third = vertices.add([[7, 8]]);
|
||||||
|
|
||||||
expect(vertices.getStarts()).toEqual([0, 6, 10]);
|
expect(vertices.getStarts()).to.eql([0, 6, 10]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -183,7 +183,7 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var first = vertices.add([[1, 2], [3, 4]]);
|
var first = vertices.add([[1, 2], [3, 4]]);
|
||||||
var second = vertices.add([[5, 6]]);
|
var second = vertices.add([[5, 6]]);
|
||||||
var third = vertices.add([[7, 8], [9, 10], [11, 12]]);
|
var third = vertices.add([[7, 8], [9, 10], [11, 12]]);
|
||||||
expect(vertices.coordinates).toEqual(
|
expect(vertices.coordinates).to.eql(
|
||||||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
|
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -193,7 +193,7 @@ describe('ol.geom.SharedVertices', function() {
|
|||||||
var coordinates = vertices.coordinates;
|
var coordinates = vertices.coordinates;
|
||||||
|
|
||||||
var second = vertices.add([[5, 6]]);
|
var second = vertices.add([[5, 6]]);
|
||||||
expect(vertices.coordinates).toBe(coordinates);
|
expect(vertices.coordinates).to.be(coordinates);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe('ol.layer.Vector', function() {
|
|||||||
source: new ol.source.Vector({})
|
source: new ol.source.Vector({})
|
||||||
});
|
});
|
||||||
layer.addFeatures([new ol.Feature(), new ol.Feature()]);
|
layer.addFeatures([new ol.Feature(), new ol.Feature()]);
|
||||||
expect(layer.getFeatures().length).toEqual(2);
|
expect(layer.getFeatures().length).to.eql(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -54,19 +54,19 @@ describe('ol.layer.Vector', function() {
|
|||||||
var extentFilter = new ol.filter.Extent(new ol.Extent(16, 48, 16.3, 48.3));
|
var extentFilter = new ol.filter.Extent(new ol.Extent(16, 48, 16.3, 48.3));
|
||||||
|
|
||||||
it('can filter by geometry type using its GeometryType index', function() {
|
it('can filter by geometry type using its GeometryType index', function() {
|
||||||
spyOn(geomFilter, 'applies');
|
sinon.spy(geomFilter, 'applies');
|
||||||
var lineStrings = layer.getFeatures(geomFilter);
|
var lineStrings = layer.getFeatures(geomFilter);
|
||||||
expect(geomFilter.applies).not.toHaveBeenCalled();
|
expect(geomFilter.applies.called).to.not.be.ok();
|
||||||
expect(lineStrings.length).toEqual(4);
|
expect(lineStrings.length).to.eql(4);
|
||||||
expect(lineStrings).toContain(features[4]);
|
expect(lineStrings).to.contain(features[4]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can filter by extent using its RTree', function() {
|
it('can filter by extent using its RTree', function() {
|
||||||
spyOn(extentFilter, 'applies');
|
sinon.spy(extentFilter, 'applies');
|
||||||
var subset = layer.getFeatures(extentFilter);
|
var subset = layer.getFeatures(extentFilter);
|
||||||
expect(extentFilter.applies).not.toHaveBeenCalled();
|
expect(extentFilter.applies.called).to.not.be.ok();
|
||||||
expect(subset.length).toEqual(4);
|
expect(subset.length).to.eql(4);
|
||||||
expect(subset).not.toContain(features[7]);
|
expect(subset).not.to.contain(features[7]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can filter by extent and geometry type using its index', function() {
|
it('can filter by extent and geometry type using its index', function() {
|
||||||
@@ -74,23 +74,23 @@ describe('ol.layer.Vector', function() {
|
|||||||
ol.filter.LogicalOperator.AND);
|
ol.filter.LogicalOperator.AND);
|
||||||
var filter2 = new ol.filter.Logical([extentFilter, geomFilter],
|
var filter2 = new ol.filter.Logical([extentFilter, geomFilter],
|
||||||
ol.filter.LogicalOperator.AND);
|
ol.filter.LogicalOperator.AND);
|
||||||
spyOn(filter1, 'applies');
|
sinon.spy(filter1, 'applies');
|
||||||
spyOn(filter2, 'applies');
|
sinon.spy(filter2, 'applies');
|
||||||
var subset1 = layer.getFeatures(filter1);
|
var subset1 = layer.getFeatures(filter1);
|
||||||
var subset2 = layer.getFeatures(filter2);
|
var subset2 = layer.getFeatures(filter2);
|
||||||
expect(filter1.applies).not.toHaveBeenCalled();
|
expect(filter1.applies.called).to.not.be.ok();
|
||||||
expect(filter2.applies).not.toHaveBeenCalled();
|
expect(filter2.applies.called).to.not.be.ok();
|
||||||
expect(subset1.length).toEqual(0);
|
expect(subset1.length).to.eql(0);
|
||||||
expect(subset2.length).toEqual(0);
|
expect(subset2.length).to.eql(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can handle query using the filter\'s applies function', function() {
|
it('can handle query using the filter\'s applies function', function() {
|
||||||
var filter = new ol.filter.Logical([geomFilter, extentFilter],
|
var filter = new ol.filter.Logical([geomFilter, extentFilter],
|
||||||
ol.filter.LogicalOperator.OR);
|
ol.filter.LogicalOperator.OR);
|
||||||
spyOn(filter, 'applies').andCallThrough();
|
sinon.spy(filter, 'applies');
|
||||||
var subset = layer.getFeatures(filter);
|
var subset = layer.getFeatures(filter);
|
||||||
expect(filter.applies).toHaveBeenCalled();
|
expect(filter.applies.called).to.be.ok();
|
||||||
expect(subset.length).toEqual(8);
|
expect(subset.length).to.eql(8);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -134,11 +134,11 @@ describe('ol.layer.Vector', function() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
||||||
expect(groups.length).toBe(2);
|
expect(groups.length).to.be(2);
|
||||||
expect(groups[0][0].length).toBe(1);
|
expect(groups[0][0].length).to.be(1);
|
||||||
expect(groups[0][1].strokeColor).toBe('#BADA55');
|
expect(groups[0][1].strokeColor).to.be('#BADA55');
|
||||||
expect(groups[1][0].length).toBe(2);
|
expect(groups[1][0].length).to.be(2);
|
||||||
expect(groups[1][1].strokeColor).toBe('#013');
|
expect(groups[1][1].strokeColor).to.be('#013');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('groups equal symbolizers also when defined on features', function() {
|
it('groups equal symbolizers also when defined on features', function() {
|
||||||
@@ -164,9 +164,9 @@ describe('ol.layer.Vector', function() {
|
|||||||
features.push(featureWithSymbolizers, anotherFeatureWithSymbolizers);
|
features.push(featureWithSymbolizers, anotherFeatureWithSymbolizers);
|
||||||
|
|
||||||
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
var groups = layer.groupFeaturesBySymbolizerLiteral(features);
|
||||||
expect(groups.length).toBe(3);
|
expect(groups.length).to.be(3);
|
||||||
expect(groups[2][0].length).toBe(2);
|
expect(groups[2][0].length).to.be(2);
|
||||||
expect(groups[2][1].strokeWidth).toBe(3);
|
expect(groups[2][1].strokeWidth).to.be(3);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ describe('ol.parser.GeoJSON', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var obj = parser.read(str);
|
var obj = parser.read(str);
|
||||||
expect(obj).toBeA(ol.geom.Point);
|
expect(obj).to.be.a(ol.geom.Point);
|
||||||
expect(obj.getCoordinates()).toEqual([10, 20]);
|
expect(obj.getCoordinates()).to.eql([10, 20]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses linestring', function() {
|
it('parses linestring', function() {
|
||||||
@@ -88,8 +88,8 @@ describe('ol.parser.GeoJSON', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var obj = parser.read(str);
|
var obj = parser.read(str);
|
||||||
expect(obj).toBeA(ol.geom.LineString);
|
expect(obj).to.be.a(ol.geom.LineString);
|
||||||
expect(obj.getCoordinates()).toEqual([[10, 20], [30, 40]]);
|
expect(obj.getCoordinates()).to.eql([[10, 20], [30, 40]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses polygon', function() {
|
it('parses polygon', function() {
|
||||||
@@ -102,11 +102,11 @@ describe('ol.parser.GeoJSON', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var obj = parser.read(str);
|
var obj = parser.read(str);
|
||||||
expect(obj).toBeA(ol.geom.Polygon);
|
expect(obj).to.be.a(ol.geom.Polygon);
|
||||||
expect(obj.rings.length).toBe(3);
|
expect(obj.rings.length).to.be(3);
|
||||||
expect(obj.rings[0]).toBeA(ol.geom.LinearRing);
|
expect(obj.rings[0]).to.be.a(ol.geom.LinearRing);
|
||||||
expect(obj.rings[1]).toBeA(ol.geom.LinearRing);
|
expect(obj.rings[1]).to.be.a(ol.geom.LinearRing);
|
||||||
expect(obj.rings[2]).toBeA(ol.geom.LinearRing);
|
expect(obj.rings[2]).to.be.a(ol.geom.LinearRing);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses geometry collection', function() {
|
it('parses geometry collection', function() {
|
||||||
@@ -119,52 +119,53 @@ describe('ol.parser.GeoJSON', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var array = parser.read(str);
|
var array = parser.read(str);
|
||||||
expect(array.length).toBe(2);
|
expect(array.length).to.be(2);
|
||||||
expect(array[0]).toBeA(ol.geom.Point);
|
expect(array[0]).to.be.a(ol.geom.Point);
|
||||||
expect(array[1]).toBeA(ol.geom.LineString);
|
expect(array[1]).to.be.a(ol.geom.LineString);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses feature collection', function() {
|
it('parses feature collection', function() {
|
||||||
var str = JSON.stringify(data),
|
var str = JSON.stringify(data),
|
||||||
array = parser.read(str);
|
array = parser.read(str);
|
||||||
|
|
||||||
expect(array.length).toBe(2);
|
expect(array.length).to.be(2);
|
||||||
|
|
||||||
var first = array[0];
|
var first = array[0];
|
||||||
expect(first).toBeA(ol.Feature);
|
expect(first).to.be.a(ol.Feature);
|
||||||
expect(first.get('LINK_ID')).toBe(573730499);
|
expect(first.get('LINK_ID')).to.be(573730499);
|
||||||
var firstGeom = first.getGeometry();
|
var firstGeom = first.getGeometry();
|
||||||
expect(firstGeom).toBeA(ol.geom.LineString);
|
expect(firstGeom).to.be.a(ol.geom.LineString);
|
||||||
|
|
||||||
var second = array[1];
|
var second = array[1];
|
||||||
expect(second).toBeA(ol.Feature);
|
expect(second).to.be.a(ol.Feature);
|
||||||
expect(second.get('ST_NAME')).toBe('BRUNNSGATAN');
|
expect(second.get('ST_NAME')).to.be('BRUNNSGATAN');
|
||||||
var secondGeom = second.getGeometry();
|
var secondGeom = second.getGeometry();
|
||||||
expect(secondGeom).toBeA(ol.geom.LineString);
|
expect(secondGeom).to.be.a(ol.geom.LineString);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('parses countries.json', function() {
|
it('parses countries.json', function(done) {
|
||||||
afterLoadText('spec/ol/parser/geojson/countries.json', function(text) {
|
afterLoadText('spec/ol/parser/geojson/countries.json', function(text) {
|
||||||
var result = parser.read(text);
|
var result = parser.read(text);
|
||||||
expect(result.length).toBe(179);
|
expect(result.length).to.be(179);
|
||||||
|
|
||||||
var first = result[0];
|
var first = result[0];
|
||||||
expect(first).toBeA(ol.Feature);
|
expect(first).to.be.a(ol.Feature);
|
||||||
expect(first.get('name')).toBe('Afghanistan');
|
expect(first.get('name')).to.be('Afghanistan');
|
||||||
var firstGeom = first.getGeometry();
|
var firstGeom = first.getGeometry();
|
||||||
expect(firstGeom).toBeA(ol.geom.Polygon);
|
expect(firstGeom).to.be.a(ol.geom.Polygon);
|
||||||
expect(firstGeom.getBounds().equals(
|
expect(firstGeom.getBounds().equals(
|
||||||
new ol.Extent(60.52843, 29.318572, 75.158028, 38.486282)))
|
new ol.Extent(60.52843, 29.318572, 75.158028, 38.486282)))
|
||||||
.toBe(true);
|
.to.be(true);
|
||||||
|
|
||||||
var last = result[178];
|
var last = result[178];
|
||||||
expect(last).toBeA(ol.Feature);
|
expect(last).to.be.a(ol.Feature);
|
||||||
expect(last.get('name')).toBe('Zimbabwe');
|
expect(last.get('name')).to.be('Zimbabwe');
|
||||||
var lastGeom = last.getGeometry();
|
var lastGeom = last.getGeometry();
|
||||||
expect(lastGeom).toBeA(ol.geom.Polygon);
|
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||||
expect(lastGeom.getBounds().equals(
|
expect(lastGeom.getBounds().equals(
|
||||||
new ol.Extent(25.264226, -22.271612, 32.849861, -15.507787)))
|
new ol.Extent(25.264226, -22.271612, 32.849861, -15.507787)))
|
||||||
.toBe(true);
|
.to.be(true);
|
||||||
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -188,29 +189,29 @@ describe('ol.parser.GeoJSON', function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var result = parser.readFeaturesFromString(text, {callback: callback});
|
var result = parser.readFeaturesFromString(text, {callback: callback});
|
||||||
expect(result.length).toBe(179);
|
expect(result.length).to.be(179);
|
||||||
|
|
||||||
expect(pointVertices.coordinates.length).toBe(0);
|
expect(pointVertices.coordinates.length).to.be(0);
|
||||||
expect(lineVertices.coordinates.length).toBe(0);
|
expect(lineVertices.coordinates.length).to.be(0);
|
||||||
expect(polygonVertices.coordinates.length).toBe(21344);
|
expect(polygonVertices.coordinates.length).to.be(21344);
|
||||||
|
|
||||||
var first = result[0];
|
var first = result[0];
|
||||||
expect(first).toBeA(ol.Feature);
|
expect(first).to.be.a(ol.Feature);
|
||||||
expect(first.get('name')).toBe('Afghanistan');
|
expect(first.get('name')).to.be('Afghanistan');
|
||||||
var firstGeom = first.getGeometry();
|
var firstGeom = first.getGeometry();
|
||||||
expect(firstGeom).toBeA(ol.geom.Polygon);
|
expect(firstGeom).to.be.a(ol.geom.Polygon);
|
||||||
expect(firstGeom.getBounds().equals(
|
expect(firstGeom.getBounds().equals(
|
||||||
new ol.Extent(60.52843, 29.318572, 75.158028, 38.486282)))
|
new ol.Extent(60.52843, 29.318572, 75.158028, 38.486282)))
|
||||||
.toBe(true);
|
.to.be(true);
|
||||||
|
|
||||||
var last = result[178];
|
var last = result[178];
|
||||||
expect(last).toBeA(ol.Feature);
|
expect(last).to.be.a(ol.Feature);
|
||||||
expect(last.get('name')).toBe('Zimbabwe');
|
expect(last.get('name')).to.be('Zimbabwe');
|
||||||
var lastGeom = last.getGeometry();
|
var lastGeom = last.getGeometry();
|
||||||
expect(lastGeom).toBeA(ol.geom.Polygon);
|
expect(lastGeom).to.be.a(ol.geom.Polygon);
|
||||||
expect(lastGeom.getBounds().equals(
|
expect(lastGeom.getBounds().equals(
|
||||||
new ol.Extent(25.264226, -22.271612, 32.849861, -15.507787)))
|
new ol.Extent(25.264226, -22.271612, 32.849861, -15.507787)))
|
||||||
.toBe(true);
|
.to.be(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,8 +6,8 @@ describe('ol.source.Vector', function() {
|
|||||||
describe('constructor', function() {
|
describe('constructor', function() {
|
||||||
it('creates an instance', function() {
|
it('creates an instance', function() {
|
||||||
var source = new ol.source.Vector({});
|
var source = new ol.source.Vector({});
|
||||||
expect(source).toBeA(ol.source.Vector);
|
expect(source).to.be.a(ol.source.Vector);
|
||||||
expect(source).toBeA(ol.source.Source);
|
expect(source).to.be.a(ol.source.Source);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -15,24 +15,24 @@ describe('ol.structs.RTree', function() {
|
|||||||
it('stores items', function() {
|
it('stores items', function() {
|
||||||
expect(goog.object.getCount(rTree.find(new ol.Rectangle(
|
expect(goog.object.getCount(rTree.find(new ol.Rectangle(
|
||||||
Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY,
|
Number.NEGATIVE_INFINITY, Number.NEGATIVE_INFINITY,
|
||||||
Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)))).toBe(6);
|
Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY)))).to.be(6);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('filters by rectangle', function() {
|
it('filters by rectangle', function() {
|
||||||
var result;
|
var result;
|
||||||
result = goog.object.getValues(rTree.find(new ol.Rectangle(2, 2, 3, 3)));
|
result = goog.object.getValues(rTree.find(new ol.Rectangle(2, 2, 3, 3)));
|
||||||
expect(result).toContain(2);
|
expect(result).to.contain(2);
|
||||||
expect(result).toContain(3);
|
expect(result).to.contain(3);
|
||||||
expect(result.length).toBe(2);
|
expect(result.length).to.be(2);
|
||||||
result = goog.object.getValues(
|
result = goog.object.getValues(
|
||||||
rTree.find(new ol.Rectangle(-1, -1, 2, 2)));
|
rTree.find(new ol.Rectangle(-1, -1, 2, 2)));
|
||||||
expect(result).toContain(1);
|
expect(result).to.contain(1);
|
||||||
expect(result).toContain(2);
|
expect(result).to.contain(2);
|
||||||
expect(result).toContain(3);
|
expect(result).to.contain(3);
|
||||||
expect(result).toContain(5);
|
expect(result).to.contain(5);
|
||||||
expect(result.length).toBe(4);
|
expect(result.length).to.be(4);
|
||||||
expect(goog.object.getCount(rTree.find(new ol.Rectangle(5, 5, 6, 6))))
|
expect(goog.object.getCount(rTree.find(new ol.Rectangle(5, 5, 6, 6))))
|
||||||
.toBe(0);
|
.to.be(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can store thosands of items and find fast', function() {
|
it('can store thosands of items and find fast', function() {
|
||||||
@@ -41,17 +41,17 @@ describe('ol.structs.RTree', function() {
|
|||||||
Math.random() * 10, Math.random() * 10), i);
|
Math.random() * 10, Math.random() * 10), i);
|
||||||
}
|
}
|
||||||
expect(goog.object.getCount(
|
expect(goog.object.getCount(
|
||||||
rTree.find(new ol.Rectangle(-10, -10, 10, 10)))).toBe(10000);
|
rTree.find(new ol.Rectangle(-10, -10, 10, 10)))).to.be(10000);
|
||||||
var result = rTree.find(new ol.Rectangle(0, 0, 0, 0));
|
var result = rTree.find(new ol.Rectangle(0, 0, 0, 0));
|
||||||
expect(goog.object.getCount(result)).toBe(9995);
|
expect(goog.object.getCount(result)).to.be(9995);
|
||||||
var values = goog.object.getValues(result);
|
var values = goog.object.getValues(result);
|
||||||
expect(values).toContain(1);
|
expect(values).to.contain(1);
|
||||||
expect(values).not.toContain(2);
|
expect(values).not.to.contain(2);
|
||||||
expect(values).not.toContain(3);
|
expect(values).not.to.contain(3);
|
||||||
expect(values).not.toContain(4);
|
expect(values).not.to.contain(4);
|
||||||
expect(values).not.toContain(5);
|
expect(values).not.to.contain(5);
|
||||||
expect(values).not.toContain(6);
|
expect(values).not.to.contain(6);
|
||||||
expect(values).toContain(7);
|
expect(values).to.contain(7);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ describe('ol.style.LineLiteral', function() {
|
|||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
expect(literal.equals(equalLiteral)).toBe(true);
|
expect(literal.equals(equalLiteral)).to.be(true);
|
||||||
expect(literal.equals(differentLiteral)).toBe(false);
|
expect(literal.equals(differentLiteral)).to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -37,7 +37,7 @@ describe('ol.style.Line', function() {
|
|||||||
strokeColor: '#BADA55',
|
strokeColor: '#BADA55',
|
||||||
strokeWidth: 3
|
strokeWidth: 3
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Line);
|
expect(symbolizer).to.be.a(ol.style.Line);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts expressions', function() {
|
it('accepts expressions', function() {
|
||||||
@@ -45,7 +45,7 @@ describe('ol.style.Line', function() {
|
|||||||
opacity: new ol.Expression('value / 100'),
|
opacity: new ol.Expression('value / 100'),
|
||||||
strokeWidth: ol.Expression('widthAttr')
|
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);
|
var literal = symbolizer.createLiteral(feature);
|
||||||
expect(literal).toBeA(ol.style.LineLiteral);
|
expect(literal).to.be.a(ol.style.LineLiteral);
|
||||||
expect(literal.opacity).toBe(42 / 100);
|
expect(literal.opacity).to.be(42 / 100);
|
||||||
expect(literal.strokeWidth).toBe(1.5);
|
expect(literal.strokeWidth).to.be(1.5);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ describe('ol.style.PolygonLiteral', function() {
|
|||||||
strokeWidth: 3,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
expect(literal.equals(equalLiteral)).toBe(true);
|
expect(literal.equals(equalLiteral)).to.be(true);
|
||||||
expect(literal.equals(differentLiteral)).toBe(false);
|
expect(literal.equals(differentLiteral)).to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -40,7 +40,7 @@ describe('ol.style.Polygon', function() {
|
|||||||
fillColor: '#BADA55',
|
fillColor: '#BADA55',
|
||||||
strokeWidth: 3
|
strokeWidth: 3
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Polygon);
|
expect(symbolizer).to.be.a(ol.style.Polygon);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts expressions', function() {
|
it('accepts expressions', function() {
|
||||||
@@ -48,7 +48,7 @@ describe('ol.style.Polygon', function() {
|
|||||||
opacity: new ol.Expression('value / 100'),
|
opacity: new ol.Expression('value / 100'),
|
||||||
fillColor: new ol.Expression('fillAttr')
|
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);
|
var literal = symbolizer.createLiteral(feature);
|
||||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||||
expect(literal.opacity).toBe(42 / 100);
|
expect(literal.opacity).to.be(42 / 100);
|
||||||
expect(literal.fillColor).toBe('#ff0000');
|
expect(literal.fillColor).to.be('#ff0000');
|
||||||
expect(literal.strokeColor).toBeUndefined();
|
expect(literal.strokeColor).to.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies default strokeWidth if only strokeColor is given', function() {
|
it('applies default strokeWidth if only strokeColor is given', function() {
|
||||||
@@ -79,10 +79,10 @@ describe('ol.style.Polygon', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var literal = symbolizer.createLiteral();
|
var literal = symbolizer.createLiteral();
|
||||||
expect(literal).toBeA(ol.style.PolygonLiteral);
|
expect(literal).to.be.a(ol.style.PolygonLiteral);
|
||||||
expect(literal.strokeColor).toBe('#ff0000');
|
expect(literal.strokeColor).to.be('#ff0000');
|
||||||
expect(literal.strokeWidth).toBe(1.5);
|
expect(literal.strokeWidth).to.be(1.5);
|
||||||
expect(literal.fillColor).toBeUndefined();
|
expect(literal.fillColor).to.be(undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,21 +8,21 @@ describe('ol.style.Rule', function() {
|
|||||||
|
|
||||||
it('returns true for a rule without filter', function() {
|
it('returns true for a rule without filter', function() {
|
||||||
rule = new ol.style.Rule({});
|
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() {
|
it('returns false when the rule does not apply', function() {
|
||||||
rule = new ol.style.Rule({
|
rule = new ol.style.Rule({
|
||||||
filter: new ol.filter.Filter(function() { return false; })
|
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() {
|
it('returns true when the rule applies', function() {
|
||||||
rule = new ol.style.Rule({
|
rule = new ol.style.Rule({
|
||||||
filter: new ol.filter.Filter(function() { return true; })
|
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,
|
strokeWidth: 3,
|
||||||
opacity: 1
|
opacity: 1
|
||||||
});
|
});
|
||||||
expect(literal.equals(equalLiteral)).toBe(true);
|
expect(literal.equals(equalLiteral)).to.be(true);
|
||||||
expect(literal.equals(differentLiteral)).toBe(false);
|
expect(literal.equals(differentLiteral)).to.be(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -46,7 +46,7 @@ describe('ol.style.Shape', function() {
|
|||||||
size: 4,
|
size: 4,
|
||||||
fillColor: '#BADA55'
|
fillColor: '#BADA55'
|
||||||
});
|
});
|
||||||
expect(symbolizer).toBeA(ol.style.Shape);
|
expect(symbolizer).to.be.a(ol.style.Shape);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('accepts expressions', function() {
|
it('accepts expressions', function() {
|
||||||
@@ -54,7 +54,7 @@ describe('ol.style.Shape', function() {
|
|||||||
size: new ol.Expression('sizeAttr'),
|
size: new ol.Expression('sizeAttr'),
|
||||||
strokeColor: new ol.Expression('color')
|
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);
|
var literal = symbolizer.createLiteral(feature);
|
||||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||||
expect(literal.size).toBe(42);
|
expect(literal.size).to.be(42);
|
||||||
expect(literal.opacity).toBe(0.4);
|
expect(literal.opacity).to.be(0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can be called without a feature', function() {
|
it('can be called without a feature', function() {
|
||||||
@@ -89,12 +89,12 @@ describe('ol.style.Shape', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var literal = symbolizer.createLiteral();
|
var literal = symbolizer.createLiteral();
|
||||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||||
expect(literal.size).toBe(10);
|
expect(literal.size).to.be(10);
|
||||||
expect(literal.opacity).toBe(1);
|
expect(literal.opacity).to.be(1);
|
||||||
expect(literal.fillColor).toBe('#BADA55');
|
expect(literal.fillColor).to.be('#BADA55');
|
||||||
expect(literal.strokeColor).toBe('#013');
|
expect(literal.strokeColor).to.be('#013');
|
||||||
expect(literal.strokeWidth).toBe(2);
|
expect(literal.strokeWidth).to.be(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('applies default type if none provided', function() {
|
it('applies default type if none provided', function() {
|
||||||
@@ -110,9 +110,9 @@ describe('ol.style.Shape', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
var literal = symbolizer.createLiteral(feature);
|
var literal = symbolizer.createLiteral(feature);
|
||||||
expect(literal).toBeA(ol.style.ShapeLiteral);
|
expect(literal).to.be.a(ol.style.ShapeLiteral);
|
||||||
expect(literal.size).toBe(42);
|
expect(literal.size).to.be(42);
|
||||||
expect(literal.opacity).toBe(0.4);
|
expect(literal.opacity).to.be(0.4);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -23,10 +23,10 @@ describe('ol.style.Style', function() {
|
|||||||
});
|
});
|
||||||
var feature = new ol.Feature();
|
var feature = new ol.Feature();
|
||||||
feature.set('foo', 'bar');
|
feature.set('foo', 'bar');
|
||||||
expect(style.apply(feature).length).toBe(1);
|
expect(style.apply(feature).length).to.be(1);
|
||||||
expect(style.apply(feature)[0].fillColor).toBe('#BADA55');
|
expect(style.apply(feature)[0].fillColor).to.be('#BADA55');
|
||||||
feature.set('foo', 'baz');
|
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();
|
var feature = new ol.Feature();
|
||||||
|
|
||||||
it('returns an empty array for features without geometry', function() {
|
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() {
|
it('returns an array with the Shape default for points', function() {
|
||||||
feature.setGeometry(new ol.geom.Point([0, 0]));
|
feature.setGeometry(new ol.geom.Point([0, 0]));
|
||||||
var symbolizers = ol.style.Style.applyDefaultStyle(feature);
|
var symbolizers = ol.style.Style.applyDefaultStyle(feature);
|
||||||
expect(symbolizers.length).toBe(1);
|
expect(symbolizers.length).to.be(1);
|
||||||
expect(symbolizers[0]).toBeA(ol.style.ShapeLiteral);
|
expect(symbolizers[0]).to.be.a(ol.style.ShapeLiteral);
|
||||||
expect(symbolizers[0].equals(ol.style.ShapeDefaults)).toBe(true);
|
expect(symbolizers[0].equals(ol.style.ShapeDefaults)).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns an array with the Line default for lines', function() {
|
it('returns an array with the Line default for lines', function() {
|
||||||
feature.setGeometry(new ol.geom.LineString([[0, 0], [1, 1]]));
|
feature.setGeometry(new ol.geom.LineString([[0, 0], [1, 1]]));
|
||||||
expect(ol.style.Style.applyDefaultStyle(feature)[0]
|
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() {
|
it('returns an array with the Polygon default for polygons', function() {
|
||||||
feature.setGeometry(new ol.geom.Polygon([[[0, 0], [1, 1], [0, 0]]]));
|
feature.setGeometry(new ol.geom.Polygon([[[0, 0], [1, 1], [0, 0]]]));
|
||||||
expect(ol.style.Style.applyDefaultStyle(feature)[0]
|
expect(ol.style.Style.applyDefaultStyle(feature)[0]
|
||||||
.equals(ol.style.PolygonDefaults)).toBe(true);
|
.equals(ol.style.PolygonDefaults)).to.be(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -22,3 +22,69 @@ function waitsFor(condition, message, timeout, callback) {
|
|||||||
expect.Assertion.prototype.roughlyEqual = function(other, tol) {
|
expect.Assertion.prototype.roughlyEqual = function(other, tol) {
|
||||||
return Math.abs(this.actual - other) <= tol;
|
return Math.abs(this.actual - other) <= tol;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// helper functions for async testing
|
||||||
|
(function(global) {
|
||||||
|
|
||||||
|
function afterLoad(type, path, next) {
|
||||||
|
var done, error, data;
|
||||||
|
|
||||||
|
goog.net.XhrIo.send(path, function(event) {
|
||||||
|
var xhr = event.target;
|
||||||
|
if (xhr.isSuccess()) {
|
||||||
|
if (type === 'xml') {
|
||||||
|
data = xhr.getResponseXml();
|
||||||
|
} else if (type === 'json') {
|
||||||
|
data = xhr.getResponseJson();
|
||||||
|
} else {
|
||||||
|
data = xhr.getResponseText();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
error = new Error(path + ' loading failed: ' + xhr.getStatus());
|
||||||
|
}
|
||||||
|
done = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
waitsFor(function() {
|
||||||
|
return done;
|
||||||
|
}, 'XHR timeout', 1000, function() {
|
||||||
|
if (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
next(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} path Relative path to file (e.g. 'spec/ol/foo.json').
|
||||||
|
* @param {function(Object)} next Function to call with response object on
|
||||||
|
* success. On failure, an error is thrown with the reason.
|
||||||
|
*/
|
||||||
|
global.afterLoadJson = function(path, next) {
|
||||||
|
afterLoad('json', path, next);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} path Relative path to file (e.g. 'spec/ol/foo.txt').
|
||||||
|
* @param {function(string)} next Function to call with response text on
|
||||||
|
* success. On failure, an error is thrown with the reason.
|
||||||
|
*/
|
||||||
|
global.afterLoadText = function(path, next) {
|
||||||
|
afterLoad('text', path, next);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} path Relative path to file (e.g. 'spec/ol/foo.xml').
|
||||||
|
* @param {function(Document)} next Function to call with response xml on
|
||||||
|
* success. On failure, an error is thrown with the reason.
|
||||||
|
*/
|
||||||
|
global.afterLoadXml = function(path, next) {
|
||||||
|
afterLoad('xml', path, next);
|
||||||
|
};
|
||||||
|
|
||||||
|
})(this);
|
||||||
|
|||||||
Reference in New Issue
Block a user