From 3e69ef6f9eb87960c6a72bfddcbb1dc35c671476 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Thu, 7 Mar 2013 17:53:36 -0500 Subject: [PATCH] Fix tests and global leak --- Makefile | 1 - js/id/svg.js | 1 + test/index.html | 2 -- test/spec/lib/d3.clip.js | 41 ---------------------------------------- test/spec/svg.js | 20 +++++++++----------- test/spec/svg/lines.js | 2 +- 6 files changed, 11 insertions(+), 56 deletions(-) delete mode 100644 test/spec/lib/d3.clip.js diff --git a/Makefile b/Makefile index f57355762..6d80afca3 100644 --- a/Makefile +++ b/Makefile @@ -41,7 +41,6 @@ data/data.js: \ js/lib/bootstrap-tooltip.js \ js/lib/d3.v3.js \ js/lib/d3.checkselect.js \ - js/lib/d3.clip.js \ js/lib/d3.combobox.js \ js/lib/d3.geo.tile.js \ js/lib/d3.keybinding.js \ diff --git a/js/id/svg.js b/js/id/svg.js index 090c21582..d7da27e58 100644 --- a/js/id/svg.js +++ b/js/id/svg.js @@ -24,6 +24,7 @@ iD.svg = { var segments = [], last, + next, segment = [], started = false, d = ''; diff --git a/test/index.html b/test/index.html index dc71a2bcc..15ce5ab12 100644 --- a/test/index.html +++ b/test/index.html @@ -29,7 +29,6 @@ - @@ -185,7 +184,6 @@ - diff --git a/test/spec/lib/d3.clip.js b/test/spec/lib/d3.clip.js deleted file mode 100644 index 99205da97..000000000 --- a/test/spec/lib/d3.clip.js +++ /dev/null @@ -1,41 +0,0 @@ -describe('d3.clip.cohenSutherland', function() { - var clip; - - beforeEach(function() { - clip = d3.clip.cohenSutherland() - .bounds([0, 0, 10, 10]); - }); - - it('clips an empty array', function() { - expect(clip([])).to.eql([]); - }); - - it('clips a point inside bounds', function() { - expect(clip([[0, 0]])).to.eql([[[0, 0]]]); - }); - - it('clips a point outside bounds', function() { - expect(clip([[-1, -1]])).to.eql([]); - }); - - it('clips a single segment inside bounds', function() { - expect(clip([[0, 0], [10, 10]])).to.eql([[[0, 0], [10, 10]]]); - }); - - it('clips a single segment leaving bounds', function() { - expect(clip([[5, 5], [15, 15]])).to.eql([[[5, 5], [10, 10]]]); - }); - - it('clips a single segment entering bounds', function() { - expect(clip([[15, 15], [5, 5]])).to.eql([[[10, 10], [5, 5]]]); - }); - - it('clips a single segment entering and leaving bounds', function() { - expect(clip([[0, 15], [15, 0]])).to.eql([[[5, 10], [10, 5]]]); - }); - - it('clips multiple segments', function() { - expect(clip([[15, 15], [5, 5], [15, 15], [5, 5]])).to. - eql([[[10, 10], [5, 5], [10, 10]], [[10, 10], [5, 5]]]); - }); -}); diff --git a/test/spec/svg.js b/test/spec/svg.js index 78ad5ac66..cc2b868d9 100644 --- a/test/spec/svg.js +++ b/test/spec/svg.js @@ -1,12 +1,13 @@ describe("iD.svg.LineString", function () { + var projection = d3.geo.mercator(); + it("returns an SVG path description for the entity's nodes", function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [2, 3]}), way = iD.Way({nodes: [a.id, b.id]}), - graph = iD.Graph([a, b, way]), - projection = Object; + graph = iD.Graph([a, b, way]); - expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal("M0,0L2,3"); + expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.equal('M480,250L482,245'); }); describe('resampling', function() { @@ -14,27 +15,24 @@ describe("iD.svg.LineString", function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [10, 0]}), way = iD.Way({nodes: [a.id, b.id]}), - graph = iD.Graph([a, b, way]), - projection = Object; + graph = iD.Graph([a, b, way]); - expect(iD.svg.LineString(projection, graph, [10, 10], 2)(way)).to.equal('M0,0L2,0L4,0L6,0L8,0L10,0'); + expect(iD.svg.LineString(projection, graph, [10, 10], 2)(way)).to.equal('M480,250L482,250L484,250L486,250L488,250L490,250L492,250L493,250'); }); it("does not resmample when no steps are possible", function () { var a = iD.Node({loc: [0, 0]}), b = iD.Node({loc: [10, 0]}), way = iD.Way({nodes: [a.id, b.id]}), - graph = iD.Graph([a, b, way]), - projection = Object; + graph = iD.Graph([a, b, way]); - expect(iD.svg.LineString(projection, graph, [10, 10], 20)(way)).to.equal('M0,0L10,0'); + expect(iD.svg.LineString(projection, graph, [10, 10], 20)(way)).to.equal('M480,250L493,250'); }); }); it("returns null for an entity with no nodes", function () { var way = iD.Way(), - graph = iD.Graph([way]), - projection = Object; + graph = iD.Graph([way]); expect(iD.svg.LineString(projection, graph, [10, 10])(way)).to.be.null; }); diff --git a/test/spec/svg/lines.js b/test/spec/svg/lines.js index d38b6f998..f05dae853 100644 --- a/test/spec/svg/lines.js +++ b/test/spec/svg/lines.js @@ -1,6 +1,6 @@ describe("iD.svg.Lines", function () { var surface, - projection = Object, + projection = d3.geo.mercator(), filter = d3.functor(true), dimensions = [10, 10];