Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -12,7 +12,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('construct empty', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString([]);
|
||||
});
|
||||
@@ -48,7 +48,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('construct with 2D coordinates', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString([[1, 2], [3, 4]]);
|
||||
});
|
||||
@@ -109,7 +109,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('construct with 3D coordinates', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString([[1, 2, 3], [4, 5, 6]]);
|
||||
});
|
||||
@@ -154,10 +154,10 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('construct with 3D coordinates and layout XYM', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString(
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
});
|
||||
|
||||
it('has the expected layout', function() {
|
||||
@@ -200,7 +200,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('construct with 4D coordinates', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString([[1, 2, 3, 4], [5, 6, 7, 8]]);
|
||||
});
|
||||
@@ -246,23 +246,23 @@ describe('ol.geom.LineString', function() {
|
||||
describe('#scale()', function() {
|
||||
|
||||
it('scales a linestring', function() {
|
||||
var geom = new LineString([[-10, -20], [10, 20]]);
|
||||
const geom = new LineString([[-10, -20], [10, 20]]);
|
||||
geom.scale(10);
|
||||
var coordinates = geom.getCoordinates();
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-100, -200], [100, 200]]);
|
||||
});
|
||||
|
||||
it('accepts sx and sy', function() {
|
||||
var geom = new LineString([[-10, -20], [10, 20]]);
|
||||
const geom = new LineString([[-10, -20], [10, 20]]);
|
||||
geom.scale(2, 3);
|
||||
var coordinates = geom.getCoordinates();
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-20, -60], [20, 60]]);
|
||||
});
|
||||
|
||||
it('accepts an anchor', function() {
|
||||
var geom = new LineString([[-10, -20], [10, 20]]);
|
||||
const geom = new LineString([[-10, -20], [10, 20]]);
|
||||
geom.scale(3, 2, [10, 20]);
|
||||
var coordinates = geom.getCoordinates();
|
||||
const coordinates = geom.getCoordinates();
|
||||
expect(coordinates).to.eql([[-50, -60], [10, 20]]);
|
||||
});
|
||||
|
||||
@@ -270,10 +270,10 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('with a simple line string', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString(
|
||||
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
|
||||
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
|
||||
});
|
||||
|
||||
describe('#getFirstCoordinate', function() {
|
||||
@@ -287,7 +287,7 @@ describe('ol.geom.LineString', function() {
|
||||
describe('#getFlatMidpoint', function() {
|
||||
|
||||
it('returns the expected result', function() {
|
||||
var midpoint = lineString.getFlatMidpoint();
|
||||
const midpoint = lineString.getFlatMidpoint();
|
||||
expect(midpoint).to.be.an(Array);
|
||||
expect(midpoint).to.have.length(2);
|
||||
expect(midpoint[0]).to.roughlyEqual(4, 1e-1);
|
||||
@@ -307,21 +307,21 @@ describe('ol.geom.LineString', function() {
|
||||
describe('#simplify', function() {
|
||||
|
||||
it('returns a simplified geometry', function() {
|
||||
var simplified = lineString.simplify(1);
|
||||
const simplified = lineString.simplify(1);
|
||||
expect(simplified).to.be.an(LineString);
|
||||
expect(simplified.getCoordinates()).to.eql(
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
});
|
||||
|
||||
it('does not modify the original', function() {
|
||||
lineString.simplify(1);
|
||||
expect(lineString.getCoordinates()).to.eql(
|
||||
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
|
||||
[[0, 0], [1.5, 1], [3, 3], [5, 1], [6, 3.5], [7, 5]]);
|
||||
});
|
||||
|
||||
it('delegates to the internal method', function() {
|
||||
var simplified = lineString.simplify(2);
|
||||
var internal = lineString.getSimplifiedGeometry(4);
|
||||
const simplified = lineString.simplify(2);
|
||||
const internal = lineString.getSimplifiedGeometry(4);
|
||||
expect(simplified.getCoordinates()).to.eql(internal.getCoordinates());
|
||||
});
|
||||
|
||||
@@ -330,31 +330,31 @@ describe('ol.geom.LineString', function() {
|
||||
describe('#getSimplifiedGeometry', function() {
|
||||
|
||||
it('returns the expectedResult', function() {
|
||||
var simplifiedGeometry = lineString.getSimplifiedGeometry(1);
|
||||
const simplifiedGeometry = lineString.getSimplifiedGeometry(1);
|
||||
expect(simplifiedGeometry).to.be.an(LineString);
|
||||
expect(simplifiedGeometry.getCoordinates()).to.eql(
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
[[0, 0], [3, 3], [5, 1], [7, 5]]);
|
||||
});
|
||||
|
||||
it('caches by resolution', function() {
|
||||
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
|
||||
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
|
||||
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
|
||||
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
|
||||
expect(simplifiedGeometry1).to.be(simplifiedGeometry2);
|
||||
});
|
||||
|
||||
it('invalidates the cache when the geometry changes', function() {
|
||||
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
|
||||
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(1);
|
||||
lineString.setCoordinates(lineString.getCoordinates());
|
||||
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
|
||||
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(1);
|
||||
expect(simplifiedGeometry1).not.to.be(simplifiedGeometry2);
|
||||
});
|
||||
|
||||
it('remembers the minimum squared tolerance', function() {
|
||||
sinon.spy(lineString, 'getSimplifiedGeometryInternal');
|
||||
var simplifiedGeometry1 = lineString.getSimplifiedGeometry(0.05);
|
||||
const simplifiedGeometry1 = lineString.getSimplifiedGeometry(0.05);
|
||||
expect(lineString.getSimplifiedGeometryInternal.callCount).to.be(1);
|
||||
expect(simplifiedGeometry1).to.be(lineString);
|
||||
var simplifiedGeometry2 = lineString.getSimplifiedGeometry(0.01);
|
||||
const simplifiedGeometry2 = lineString.getSimplifiedGeometry(0.01);
|
||||
expect(lineString.getSimplifiedGeometryInternal.callCount).to.be(1);
|
||||
expect(simplifiedGeometry2).to.be(lineString);
|
||||
});
|
||||
@@ -372,7 +372,7 @@ describe('ol.geom.LineString', function() {
|
||||
});
|
||||
|
||||
it('return the mid point when fraction is 0.5', function() {
|
||||
var midpoint = lineString.getFlatMidpoint();
|
||||
const midpoint = lineString.getFlatMidpoint();
|
||||
expect(lineString.getCoordinateAt(0.5)).to.eql(midpoint);
|
||||
});
|
||||
|
||||
@@ -382,10 +382,10 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('with a simple XYM coordinates', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString(
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
[[1, 2, 3], [4, 5, 6]], 'XYM');
|
||||
});
|
||||
|
||||
describe('#getCoordinateAtM', function() {
|
||||
@@ -411,7 +411,7 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
describe('with several XYZM coordinates', function() {
|
||||
|
||||
var lineString;
|
||||
let lineString;
|
||||
beforeEach(function() {
|
||||
lineString = new LineString([
|
||||
[0, 0, 0, 0],
|
||||
@@ -432,10 +432,10 @@ describe('ol.geom.LineString', function() {
|
||||
|
||||
it('returns the expected value', function() {
|
||||
expect(lineString.getLayout()).to.be('XYZM');
|
||||
var m;
|
||||
let m;
|
||||
for (m = 0; m <= 22; m += 0.5) {
|
||||
expect(lineString.getCoordinateAtM(m, true)).to.eql(
|
||||
[m, -m, 2 * m, m]);
|
||||
[m, -m, 2 * m, m]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user