From 545789efcc64daeaa83b2ca0821dcde74e092e50 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Thu, 17 Jan 2013 10:51:51 -0800 Subject: [PATCH] More area tests --- js/id/svg/areas.js | 2 +- test/spec/svg/areas.js | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/js/id/svg/areas.js b/js/id/svg/areas.js index 3862aca0c..e77fe8a4d 100644 --- a/js/id/svg/areas.js +++ b/js/id/svg/areas.js @@ -41,7 +41,7 @@ iD.svg.Areas = function(projection) { var lineString = iD.svg.LineString(projection); function drawPaths(group, areas, filter, classes) { - var paths = group.selectAll('path') + var paths = group.selectAll('path.area') .filter(filter) .data(areas, iD.Entity.key); diff --git a/test/spec/svg/areas.js b/test/spec/svg/areas.js index d978e81c6..112e25d03 100644 --- a/test/spec/svg/areas.js +++ b/test/spec/svg/areas.js @@ -8,6 +8,16 @@ describe("iD.svg.Areas", function () { .call(iD.svg.Surface()); }); + it("adds way and area classes", function () { + var area = iD.Way({tags: {area: 'yes'}}), + graph = iD.Graph([area]); + + surface.call(iD.svg.Areas(projection), graph, [area], filter); + + expect(surface.select('path')).to.be.classed('way'); + expect(surface.select('path')).to.be.classed('area'); + }); + it("adds tag classes", function () { var area = iD.Way({tags: {area: 'yes', building: 'yes'}}), graph = iD.Graph([area]); @@ -17,4 +27,17 @@ describe("iD.svg.Areas", function () { expect(surface.select('.area')).to.be.classed('tag-building'); expect(surface.select('.area')).to.be.classed('tag-building-yes'); }); + + it("preserves non-area paths", function () { + var area = iD.Way({tags: {area: 'yes'}}), + graph = iD.Graph([area]); + + surface.select('.layer-fill') + .append('path') + .attr('class', 'other'); + + surface.call(iD.svg.Areas(projection), graph, [area], filter); + + expect(surface.selectAll('.other')[0].length).to.equal(1); + }); });