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

View File

@@ -12,7 +12,7 @@
"install": "node tasks/install.js",
"postinstall": "closure-util update",
"start": "node tasks/serve.js",
"pretest": "eslint tasks",
"pretest": "eslint tasks test",
"test": "node tasks/test.js",
"debug-server": "node tasks/serve-lib.js"
},

View File

@@ -19,22 +19,22 @@ describe('ol.geom.flat.interpolate', function() {
});
it('returns the expected value when the mid point is an existing ' +
'coordinate',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5];
var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]);
});
'coordinate',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5];
var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 6, 2, 0.5);
expect(point).to.eql([2, 3]);
});
it('returns the expected value when the midpoint falls halfway between ' +
'two existing coordinates',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]);
});
'two existing coordinates',
function() {
var flatCoordinates = [0, 1, 2, 3, 4, 5, 6, 7];
var point = ol.geom.flat.interpolate.lineString(
flatCoordinates, 0, 8, 2, 0.5);
expect(point).to.eql([3, 4]);
});
it('returns the expected value when the coordinates are not evenly spaced',
function() {

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 ' +
'equivalent',
function() {
_testAllEquivalent([
'CRS:84',
'urn:ogc:def:crs:EPSG:6.6:4326',
'EPSG:4326'
]);
});
'equivalent',
function() {
_testAllEquivalent([
'CRS:84',
'urn:ogc:def:crs:EPSG:6.6:4326',
'EPSG:4326'
]);
});
it('requires code and units to be equal for projection evquivalence',
function() {

View File

@@ -402,60 +402,41 @@ describe('ol.View', function() {
});
it('fits correctly to the geometry', function() {
view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{
padding: [100, 0, 0, 100],
constrainResolution: false
}
);
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{padding: [100, 0, 0, 100], constrainResolution: false});
expect(view.getResolution()).to.be(11);
expect(view.getCenter()[0]).to.be(5950);
expect(view.getCenter()[1]).to.be(47100);
view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{
padding: [100, 0, 0, 100]
}
);
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{padding: [100, 0, 0, 100]});
expect(view.getResolution()).to.be(20);
expect(view.getCenter()[0]).to.be(5500);
expect(view.getCenter()[1]).to.be(47550);
view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{
padding: [100, 0, 0, 100],
nearest: true
}
);
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{padding: [100, 0, 0, 100], nearest: true});
expect(view.getResolution()).to.be(10);
expect(view.getCenter()[0]).to.be(6000);
expect(view.getCenter()[1]).to.be(47050);
view.fit(
new ol.geom.Point([6000, 46000]),
[200, 200],
{
padding: [100, 0, 0, 100],
minResolution: 2
}
);
new ol.geom.Point([6000, 46000]),
[200, 200],
{padding: [100, 0, 0, 100], minResolution: 2});
expect(view.getResolution()).to.be(2);
expect(view.getCenter()[0]).to.be(5900);
expect(view.getCenter()[1]).to.be(46100);
view.fit(
new ol.geom.Point([6000, 46000]),
[200, 200],
{
padding: [100, 0, 0, 100],
maxZoom: 6
}
);
new ol.geom.Point([6000, 46000]),
[200, 200],
{padding: [100, 0, 0, 100], maxZoom: 6});
expect(view.getResolution()).to.be(2);
expect(view.getZoom()).to.be(6);
expect(view.getCenter()[0]).to.be(5900);
@@ -463,13 +444,9 @@ describe('ol.View', function() {
view.setRotation(Math.PI / 4);
view.fit(
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{
padding: [100, 0, 0, 100],
constrainResolution: false
}
);
new ol.geom.LineString([[6000, 46000], [6000, 47100], [7000, 46000]]),
[200, 200],
{padding: [100, 0, 0, 100], constrainResolution: false});
expect(view.getResolution()).to.roughlyEqual(14.849242404917458, 1e-9);
expect(view.getCenter()[0]).to.roughlyEqual(5200, 1e-9);
expect(view.getCenter()[1]).to.roughlyEqual(46300, 1e-9);