diff --git a/test/spec/geo/extent.js b/test/spec/geo/extent.js index b58dbefec..ce8627624 100644 --- a/test/spec/geo/extent.js +++ b/test/spec/geo/extent.js @@ -1,52 +1,52 @@ -describe("iD.geo.Extent", function () { - describe("constructor", function () { - it("defaults to infinitely empty extent", function () { +describe('iD.geo.Extent', function () { + describe('constructor', function () { + it('defaults to infinitely empty extent', function () { expect(iD.geo.Extent().equals([[Infinity, Infinity], [-Infinity, -Infinity]])).to.be.ok; }); - it("constructs via a point", function () { + it('constructs via a point', function () { var p = [0, 0]; expect(iD.geo.Extent(p).equals([p, p])).to.be.ok; }); - it("constructs via two points", function () { + it('constructs via two points', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent(min, max).equals([min, max])).to.be.ok; }); - it("constructs via an extent", function () { + it('constructs via an extent', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent([min, max]).equals([min, max])).to.be.ok; }); - it("constructs via an iD.geo.Extent", function () { + it('constructs via an iD.geo.Extent', function () { var min = [0, 0], max = [5, 10], extent = iD.geo.Extent(min, max); expect(iD.geo.Extent(extent).equals(extent)).to.be.ok; }); - it("has length 2", function () { + it('has length 2', function () { expect(iD.geo.Extent().length).to.equal(2); }); - it("has min element", function () { + it('has min element', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent(min, max)[0]).to.equal(min); }); - it("has max element", function () { + it('has max element', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent(min, max)[1]).to.equal(max); }); }); - describe("#equals", function () { - it("tests extent equality", function () { + describe('#equals', function () { + it('tests extent equality', function () { var e1 = iD.geo.Extent([0, 0], [10, 10]), e2 = iD.geo.Extent([0, 0], [10, 10]), e3 = iD.geo.Extent([0, 0], [12, 12]); @@ -55,63 +55,63 @@ describe("iD.geo.Extent", function () { }); }); - describe("#center", function () { - it("returns the center point", function () { + describe('#center', function () { + it('returns the center point', function () { expect(iD.geo.Extent([0, 0], [5, 10]).center()).to.eql([2.5, 5]); }); }); - describe("#rectangle", function () { - it("returns the extent as a rectangle", function () { + describe('#rectangle', function () { + it('returns the extent as a rectangle', function () { expect(iD.geo.Extent([0, 0], [5, 10]).rectangle()).to.eql([0, 0, 5, 10]); }); }); - describe("#polygon", function () { - it("returns the extent as a polygon", function () { + describe('#polygon', function () { + it('returns the extent as a polygon', function () { expect(iD.geo.Extent([0, 0], [5, 10]).polygon()) .to.eql([[0, 0], [0, 10], [5, 10], [5, 0], [0, 0]]); }); }); - describe("#area", function () { - it("returns the area", function () { + describe('#area', function () { + it('returns the area', function () { expect(iD.geo.Extent([0, 0], [5, 10]).area()).to.eql(50); }); }); - describe("#padByMeters", function () { - it("does not change centerpoint of an extent", function () { + describe('#padByMeters', function () { + it('does not change centerpoint of an extent', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent(min, max).padByMeters(100).center()).to.eql([2.5, 5]); }); - it("does not affect the extent with a pad of zero", function () { + it('does not affect the extent with a pad of zero', function () { var min = [0, 0], max = [5, 10]; expect(iD.geo.Extent(min, max).padByMeters(0)[0]).to.eql([0, 0]); }); }); - describe("#extend", function () { - it("does not modify self", function () { + describe('#extend', function () { + it('does not modify self', function () { var extent = iD.geo.Extent([0, 0], [0, 0]); extent.extend([1, 1]); expect(extent.equals([[0, 0], [0, 0]])).to.be.ok; }); - it("returns the minimal extent containing self and the given point", function () { + it('returns the minimal extent containing self and the given point', function () { expect(iD.geo.Extent().extend([0, 0]).equals([[0, 0], [0, 0]])).to.be.ok; expect(iD.geo.Extent([0, 0], [0, 0]).extend([5, 10]).equals([[0, 0], [5, 10]])).to.be.ok; }); - it("returns the minimal extent containing self and the given extent", function () { + it('returns the minimal extent containing self and the given extent', function () { expect(iD.geo.Extent().extend([[0, 0], [5, 10]]).equals([[0, 0], [5, 10]])).to.be.ok; expect(iD.geo.Extent([0, 0], [0, 0]).extend([[4, -1], [5, 10]]).equals([[0, -1], [5, 10]])).to.be.ok; }); }); - describe("#_extend", function () { - it("extends self to the minimal extent containing self and the given extent", function () { + describe('#_extend', function () { + it('extends self to the minimal extent containing self and the given extent', function () { var e = iD.geo.Extent(); e._extend([[0, 0], [5, 10]]); expect(e.equals([[0, 0], [5, 10]])).to.be.ok; @@ -123,99 +123,99 @@ describe("iD.geo.Extent", function () { }); describe('#contains', function () { - it("returns true for a point inside self", function () { + it('returns true for a point inside self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([2, 2])).to.be.true; }); - it("returns true for a point on the boundary of self", function () { + it('returns true for a point on the boundary of self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([0, 0])).to.be.true; }); - it("returns false for a point outside self", function () { + it('returns false for a point outside self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([6, 6])).to.be.false; }); - it("returns true for an extent contained by self", function () { + it('returns true for an extent contained by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([[1, 1], [2, 2]])).to.be.true; expect(iD.geo.Extent([1, 1], [2, 2]).contains([[0, 0], [5, 5]])).to.be.false; }); - it("returns false for an extent partially contained by self", function () { + it('returns false for an extent partially contained by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([[1, 1], [6, 6]])).to.be.false; expect(iD.geo.Extent([1, 1], [6, 6]).contains([[0, 0], [5, 5]])).to.be.false; }); - it("returns false for an extent not intersected by self", function () { + it('returns false for an extent not intersected by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).contains([[6, 6], [7, 7]])).to.be.false; expect(iD.geo.Extent([[6, 6], [7, 7]]).contains([[0, 0], [5, 5]])).to.be.false; }); }); describe('#intersects', function () { - it("returns true for a point inside self", function () { + it('returns true for a point inside self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([2, 2])).to.be.true; }); - it("returns true for a point on the boundary of self", function () { + it('returns true for a point on the boundary of self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([0, 0])).to.be.true; }); - it("returns false for a point outside self", function () { + it('returns false for a point outside self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([6, 6])).to.be.false; }); - it("returns true for an extent contained by self", function () { + it('returns true for an extent contained by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[1, 1], [2, 2]])).to.be.true; expect(iD.geo.Extent([1, 1], [2, 2]).intersects([[0, 0], [5, 5]])).to.be.true; }); - it("returns true for an extent partially contained by self", function () { + it('returns true for an extent partially contained by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[1, 1], [6, 6]])).to.be.true; expect(iD.geo.Extent([1, 1], [6, 6]).intersects([[0, 0], [5, 5]])).to.be.true; }); - it("returns false for an extent not intersected by self", function () { + it('returns false for an extent not intersected by self', function () { expect(iD.geo.Extent([0, 0], [5, 5]).intersects([[6, 6], [7, 7]])).to.be.false; expect(iD.geo.Extent([[6, 6], [7, 7]]).intersects([[0, 0], [5, 5]])).to.be.false; }); }); - describe("#intersection", function () { - it("returns an empty extent if self does not intersect with other", function () { + describe('#intersection', function () { + it('returns an empty extent if self does not intersect with other', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([6, 6], [7, 7]); expect(a.intersection(b)).to.eql(iD.geo.Extent()); }); - it("returns the intersection of self with other (1)", function () { + it('returns the intersection of self with other (1)', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([3, 4], [7, 7]); expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 4], [5, 5])); expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 4], [5, 5])); }); - it("returns the intersection of self with other (2)", function () { + it('returns the intersection of self with other (2)', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([3, -4], [7, 2]); expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 0], [5, 2])); expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 0], [5, 2])); }); - it("returns the intersection of self with other (3)", function () { + it('returns the intersection of self with other (3)', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([3, 3], [4, 7]); expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 3], [4, 5])); expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 3], [4, 5])); }); - it("returns the intersection of self with other (4)", function () { + it('returns the intersection of self with other (4)', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([3, -2], [4, 2]); expect(a.intersection(b)).to.eql(iD.geo.Extent([3, 0], [4, 2])); expect(b.intersection(a)).to.eql(iD.geo.Extent([3, 0], [4, 2])); }); - it("returns the intersection of self with other (5)", function () { + it('returns the intersection of self with other (5)', function () { var a = iD.geo.Extent([0, 0], [5, 5]), b = iD.geo.Extent([1, 1], [2, 2]); expect(a.intersection(b)).to.eql(iD.geo.Extent([1, 1], [2, 2])); @@ -223,22 +223,22 @@ describe("iD.geo.Extent", function () { }); }); - describe("#percentContainedIn", function () { - it("returns a 0 if self does not intersect other", function () { + describe('#percentContainedIn', function () { + it('returns a 0 if self does not intersect other', function () { var a = iD.geo.Extent([0, 0], [1, 1]), b = iD.geo.Extent([0, 3], [4, 1]); expect(a.percentContainedIn(b)).to.eql(0); expect(b.percentContainedIn(a)).to.eql(0); }); - it("returns the percent contained of self with other (1)", function () { + it('returns the percent contained of self with other (1)', function () { var a = iD.geo.Extent([0, 0], [2, 1]), b = iD.geo.Extent([1, 0], [3, 1]); expect(a.percentContainedIn(b)).to.eql(0.5); expect(b.percentContainedIn(a)).to.eql(0.5); }); - it("returns the percent contained of self with other (2)", function () { + it('returns the percent contained of self with other (2)', function () { var a = iD.geo.Extent([0, 0], [4, 1]), b = iD.geo.Extent([3, 0], [4, 2]); expect(a.percentContainedIn(b)).to.eql(0.25); diff --git a/test/spec/geo/intersection.js b/test/spec/geo/intersection.js index 88e7b9e53..e1d4253fa 100644 --- a/test/spec/geo/intersection.js +++ b/test/spec/geo/intersection.js @@ -1,4 +1,4 @@ -describe("iD.geo.Intersection", function() { +describe('iD.geo.Intersection', function() { describe('highways', function() { it('excludes non-highways', function() { var graph = iD.Graph([ @@ -11,7 +11,7 @@ describe("iD.geo.Intersection", function() { expect(iD.geo.Intersection(graph, '*').ways).to.eql([]); }); - it("excludes degenerate highways", function() { + it('excludes degenerate highways', function() { var graph = iD.Graph([ iD.Node({id: 'u'}), iD.Node({id: '*'}), @@ -21,7 +21,7 @@ describe("iD.geo.Intersection", function() { expect(_.map(iD.geo.Intersection(graph, '*').ways, 'id')).to.eql(['=']); }); - it("excludes coincident highways", function() { + it('excludes coincident highways', function() { var graph = iD.Graph([ iD.Node({id: 'u'}), iD.Node({id: '*'}), @@ -64,7 +64,7 @@ describe("iD.geo.Intersection", function() { }); describe('#turns', function() { - it("permits turns onto a way forward", function() { + it('permits turns onto a way forward', function() { // u====*--->w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -83,7 +83,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns onto a way backward", function() { + it('permits turns onto a way backward', function() { // u====*<---w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -102,7 +102,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns from a way that must be split", function() { + it('permits turns from a way that must be split', function() { // w // | // u===* @@ -137,7 +137,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns to a way that must be split", function() { + it('permits turns to a way that must be split', function() { // w // | // u===* @@ -172,7 +172,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns from a oneway forward", function() { + it('permits turns from a oneway forward', function() { // u===>v----w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -190,7 +190,7 @@ describe("iD.geo.Intersection", function() { }]); }); - it("permits turns from a reverse oneway backward", function() { + it('permits turns from a reverse oneway backward', function() { // u<===*----w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -208,7 +208,7 @@ describe("iD.geo.Intersection", function() { }]); }); - it("omits turns from a oneway backward", function() { + it('omits turns from a oneway backward', function() { // u<===*----w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -220,7 +220,7 @@ describe("iD.geo.Intersection", function() { expect(iD.geo.Intersection(graph, '*').turns('u')).to.eql([]); }); - it("omits turns from a reverse oneway forward", function() { + it('omits turns from a reverse oneway forward', function() { // u===>*----w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -232,7 +232,7 @@ describe("iD.geo.Intersection", function() { expect(iD.geo.Intersection(graph, '*').turns('u')).to.eql([]); }); - it("permits turns onto a oneway forward", function() { + it('permits turns onto a oneway forward', function() { // u====*--->w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -251,7 +251,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns onto a reverse oneway backward", function() { + it('permits turns onto a reverse oneway backward', function() { // u====*<---w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -270,7 +270,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("omits turns onto a oneway backward", function() { + it('omits turns onto a oneway backward', function() { // u====*<---w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -282,7 +282,7 @@ describe("iD.geo.Intersection", function() { expect(iD.geo.Intersection(graph, '*').turns('u').length).to.eql(1); }); - it("omits turns onto a reverse oneway forward", function() { + it('omits turns onto a reverse oneway forward', function() { // u====*--->w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -294,7 +294,7 @@ describe("iD.geo.Intersection", function() { expect(iD.geo.Intersection(graph, '*').turns('u').length).to.eql(1); }); - it("includes U-turns", function() { + it('includes U-turns', function() { // u====*--->w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -314,7 +314,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("restricts turns with a restriction relation", function() { + it('restricts turns with a restriction relation', function() { // u====*--->w var graph = iD.Graph([ iD.Node({id: 'u'}), @@ -339,7 +339,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("restricts turns affected by an only_* restriction relation", function() { + it('restricts turns affected by an only_* restriction relation', function() { // u====*~~~~v // | // w @@ -383,7 +383,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns to a circular way", function() { + it('permits turns to a circular way', function() { // // b -- c // | | @@ -419,7 +419,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns from a circular way", function() { + it('permits turns from a circular way', function() { // // b -- c // | | @@ -455,7 +455,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns to a oneway circular way", function() { + it('permits turns to a oneway circular way', function() { // // b -- c // | | @@ -486,7 +486,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns to a reverse oneway circular way", function() { + it('permits turns to a reverse oneway circular way', function() { // // b -- c // | | @@ -517,7 +517,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns from a oneway circular way", function() { + it('permits turns from a oneway circular way', function() { // // b -- c // | | @@ -547,7 +547,7 @@ describe("iD.geo.Intersection", function() { }); }); - it("permits turns from a reverse oneway circular way", function() { + it('permits turns from a reverse oneway circular way', function() { // // b -- c // | | diff --git a/test/spec/geo/multipolygon.js b/test/spec/geo/multipolygon.js index 3bfefdfcd..7f7081be9 100644 --- a/test/spec/geo/multipolygon.js +++ b/test/spec/geo/multipolygon.js @@ -1,5 +1,5 @@ -describe("iD.geo.simpleMultipolygonOuterMember", function() { - it("returns the outer member of a simple multipolygon", function() { +describe('iD.geo.simpleMultipolygonOuterMember', function() { + it('returns the outer member of a simple multipolygon', function() { var inner = iD.Way(), outer = iD.Way(), relation = iD.Relation({tags: {type: 'multipolygon'}, members: [ @@ -12,7 +12,7 @@ describe("iD.geo.simpleMultipolygonOuterMember", function() { expect(iD.geo.simpleMultipolygonOuterMember(outer, graph)).to.equal(outer); }); - it("returns falsy for a complex multipolygon", function() { + it('returns falsy for a complex multipolygon', function() { var inner = iD.Way(), outer1 = iD.Way(), outer2 = iD.Way(), @@ -28,7 +28,7 @@ describe("iD.geo.simpleMultipolygonOuterMember", function() { expect(iD.geo.simpleMultipolygonOuterMember(outer2, graph)).not.to.be.ok; }); - it("handles incomplete relations", function() { + it('handles incomplete relations', function() { var way = iD.Way({id: 'w'}), relation = iD.Relation({id: 'r', tags: {type: 'multipolygon'}, members: [ {id: 'o', role: 'outer'}, @@ -40,8 +40,8 @@ describe("iD.geo.simpleMultipolygonOuterMember", function() { }); }); -describe("iD.geo.joinWays", function() { - it("returns an array of members with nodes properties", function() { +describe('iD.geo.joinWays', function() { + it('returns an array of members with nodes properties', function() { var node = iD.Node({loc: [0, 0]}), way = iD.Way({nodes: [node.id]}), member = {id: way.id, type: 'way'}, @@ -55,7 +55,7 @@ describe("iD.geo.joinWays", function() { expect(result[0][0]).to.equal(member); }); - it("returns the members in the correct order", function() { + it('returns the members in the correct order', function() { // a<===b--->c~~~>d var graph = iD.Graph([ iD.Node({id: 'a', loc: [0, 0]}), @@ -76,7 +76,7 @@ describe("iD.geo.joinWays", function() { expect(_.map(result[0], 'id')).to.eql(['=', '-', '~']); }); - it("reverses member tags of reversed segements", function() { + it('reverses member tags of reversed segements', function() { // a --> b <== c // Expected result: // a --> b --> c @@ -93,14 +93,14 @@ describe("iD.geo.joinWays", function() { expect(result[0][1].tags).to.eql({'oneway': '-1', 'lanes:backward': 2}); }); - it("ignores non-way members", function() { + it('ignores non-way members', function() { var node = iD.Node({loc: [0, 0]}), member = {id: 'n', type: 'node'}, graph = iD.Graph([node]); expect(iD.geo.joinWays([member], graph)).to.eql([]); }); - it("ignores incomplete members", function() { + it('ignores incomplete members', function() { var member = {id: 'w', type: 'way'}, graph = iD.Graph(); expect(iD.geo.joinWays([member], graph)).to.eql([]);