Lint-free tests

This commit is contained in:
Tim Schaub
2016-01-03 11:38:01 -07:00
parent cca86886f1
commit 4e0cddcb41
4 changed files with 41 additions and 64 deletions
+1 -1
View File
@@ -12,7 +12,7 @@
"install": "node tasks/install.js", "install": "node tasks/install.js",
"postinstall": "closure-util update", "postinstall": "closure-util update",
"start": "node tasks/serve.js", "start": "node tasks/serve.js",
"pretest": "eslint tasks", "pretest": "eslint tasks test",
"test": "node tasks/test.js", "test": "node tasks/test.js",
"debug-server": "node tasks/serve-lib.js" "debug-server": "node tasks/serve-lib.js"
}, },
@@ -19,22 +19,22 @@ describe('ol.geom.flat.interpolate', function() {
}); });
it('returns the expected value when the mid point is an existing ' + it('returns the expected value when the mid point is an existing ' +
'coordinate', 'coordinate',
function() { function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5]; var flatCoordinates = [0, 1, 2, 3, 4, 5];
var point = ol.geom.flat.interpolate.lineString( var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 6, 2, 0.5); flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]); expect(point).to.eql([2, 3]);
}); });
it('returns the expected value when the midpoint falls halfway between ' + it('returns the expected value when the midpoint falls halfway between ' +
'two existing coordinates', 'two existing coordinates',
function() { function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7]; var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
var point = ol.geom.flat.interpolate.lineString( var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 8, 2, 0.5); flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]); expect(point).to.eql([3, 4]);
}); });
it('returns the expected value when the coordinates are not evenly spaced', it('returns the expected value when the coordinates are not evenly spaced',
function() { function() {
+8 -8
View File
@@ -49,14 +49,14 @@ describe('ol.proj', function() {
}); });
it('gives that CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:4326 are ' + it('gives that CRS:84, urn:ogc:def:crs:EPSG:6.6:4326, EPSG:4326 are ' +
'equivalent', 'equivalent',
function() { function() {
_testAllEquivalent([ _testAllEquivalent([
'CRS:84', 'CRS:84',
'urn:ogc:def:crs:EPSG:6.6:4326', 'urn:ogc:def:crs:EPSG:6.6:4326',
'EPSG:4326' 'EPSG:4326'
]); ]);
}); });
it('requires code and units to be equal for projection evquivalence', it('requires code and units to be equal for projection evquivalence',
function() { function() {
+18 -41
View File
@@ -402,60 +402,41 @@ describe('ol.View', function() {
}); });
it('fits correctly to the geometry', function() { it('fits correctly to the geometry', function() {
view.fit( view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100], constrainResolution: false});
padding: [100, 0, 0, 100],
constrainResolution: false
}
);
expect(view.getResolution()).to.be(11); expect(view.getResolution()).to.be(11);
expect(view.getCenter()[0]).to.be(5950); expect(view.getCenter()[0]).to.be(5950);
expect(view.getCenter()[1]).to.be(47100); expect(view.getCenter()[1]).to.be(47100);
view.fit( view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100]});
padding: [100, 0, 0, 100]
}
);
expect(view.getResolution()).to.be(20); expect(view.getResolution()).to.be(20);
expect(view.getCenter()[0]).to.be(5500); expect(view.getCenter()[0]).to.be(5500);
expect(view.getCenter()[1]).to.be(47550); expect(view.getCenter()[1]).to.be(47550);
view.fit( view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100], nearest: true});
padding: [100, 0, 0, 100],
nearest: true
}
);
expect(view.getResolution()).to.be(10); expect(view.getResolution()).to.be(10);
expect(view.getCenter()[0]).to.be(6000); expect(view.getCenter()[0]).to.be(6000);
expect(view.getCenter()[1]).to.be(47050); expect(view.getCenter()[1]).to.be(47050);
view.fit( view.fit(
new ol.geom.Point([6000, 46000]), new ol.geom.Point([6000, 46000]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100], minResolution: 2});
padding: [100, 0, 0, 100],
minResolution: 2
}
);
expect(view.getResolution()).to.be(2); expect(view.getResolution()).to.be(2);
expect(view.getCenter()[0]).to.be(5900); expect(view.getCenter()[0]).to.be(5900);
expect(view.getCenter()[1]).to.be(46100); expect(view.getCenter()[1]).to.be(46100);
view.fit( view.fit(
new ol.geom.Point([6000, 46000]), new ol.geom.Point([6000, 46000]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100], maxZoom: 6});
padding: [100, 0, 0, 100],
maxZoom: 6
}
);
expect(view.getResolution()).to.be(2); expect(view.getResolution()).to.be(2);
expect(view.getZoom()).to.be(6); expect(view.getZoom()).to.be(6);
expect(view.getCenter()[0]).to.be(5900); expect(view.getCenter()[0]).to.be(5900);
@@ -463,13 +444,9 @@ describe('ol.View', function() {
view.setRotation(Math.PI / 4); view.setRotation(Math.PI / 4);
view.fit( view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]), new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200], [200, 200],
{ {padding: [100, 0, 0, 100], constrainResolution: false});
padding: [100, 0, 0, 100],
constrainResolution: false
}
);
expect(view.getResolution()).to.roughlyEqual(14.849242404917458, 1e-9); expect(view.getResolution()).to.roughlyEqual(14.849242404917458, 1e-9);
expect(view.getCenter()[0]).to.roughlyEqual(5200, 1e-9); expect(view.getCenter()[0]).to.roughlyEqual(5200, 1e-9);
expect(view.getCenter()[1]).to.roughlyEqual(46300, 1e-9); expect(view.getCenter()[1]).to.roughlyEqual(46300, 1e-9);