mirror of
https://github.com/FoggedLens/iD.git
synced 2026-06-01 12:41:36 +02:00
3eaf4a46e0
An entity that is a member of a relation will have the classes `member`, `member-role-<member role>`, and `member-type-<relation type>`. The first use of these classes is to avoid filling multipolygon member areas.
56 lines
1.9 KiB
JavaScript
56 lines
1.9 KiB
JavaScript
describe("iD.svg.Areas", function () {
|
|
var surface,
|
|
projection = Object,
|
|
filter = d3.functor(true);
|
|
|
|
beforeEach(function () {
|
|
surface = d3.select(document.createElementNS('http://www.w3.org/2000/svg', 'svg'))
|
|
.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]);
|
|
|
|
surface.call(iD.svg.Areas(projection), graph, [area], filter);
|
|
|
|
expect(surface.select('.area')).to.be.classed('tag-building');
|
|
expect(surface.select('.area')).to.be.classed('tag-building-yes');
|
|
});
|
|
|
|
it("adds member classes", function () {
|
|
var area = iD.Way({tags: {area: 'yes'}}),
|
|
relation = iD.Relation({members: [{id: area.id, role: 'outer'}], tags: {type: 'multipolygon'}}),
|
|
graph = iD.Graph([area, relation]);
|
|
|
|
surface.call(iD.svg.Areas(projection), graph, [area], filter);
|
|
|
|
expect(surface.select('.area')).to.be.classed('member');
|
|
expect(surface.select('.area')).to.be.classed('member-role-outer');
|
|
expect(surface.select('.area')).to.be.classed('member-type-multipolygon');
|
|
});
|
|
|
|
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);
|
|
});
|
|
});
|