More area tests

This commit is contained in:
John Firebaugh
2013-01-17 10:51:51 -08:00
parent 8564279926
commit 545789efcc
2 changed files with 24 additions and 1 deletions

View File

@@ -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);

View File

@@ -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);
});
});