mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-26 15:33:50 +00:00
Expand tests
This commit is contained in:
@@ -85,20 +85,46 @@ describe("iD.actions.MergePolygon", function () {
|
||||
expect(find(r, 'w5').role).to.equal('outer');
|
||||
});
|
||||
|
||||
it("moves tags to the relation", function() {
|
||||
it("merges multipolygon tags", function() {
|
||||
var graph = iD.Graph([
|
||||
iD.Relation({id: 'r1', tags: {type: 'multipolygon', a: 'a'}}),
|
||||
iD.Relation({id: 'r2', tags: {type: 'multipolygon', b: 'b'}})
|
||||
]);
|
||||
|
||||
graph = iD.actions.MergePolygon(['r1', 'r2'])(graph);
|
||||
|
||||
expect(graph.entity('r1').tags.a).to.equal('a');
|
||||
expect(graph.entity('r1').tags.b).to.equal('b');
|
||||
});
|
||||
|
||||
it("merges tags from closed outer ways", function() {
|
||||
graph = graph.replace(graph.entity('w0').update({ tags: { 'building': 'yes' }}));
|
||||
// this is a new inner member whose tags should not be moved to the relation
|
||||
graph = graph.replace(graph.entity('w1').update({ tags: { 'natural': 'water' }}));
|
||||
// this is a new outer member whose tags should be moved to the relation
|
||||
graph = graph.replace(graph.entity('w5').update({ tags: { 'amenity': 'school' }}));
|
||||
graph = iD.actions.MergePolygon(['w0', 'w1','w5'], 'r')(graph);
|
||||
var r = graph.entity('r');
|
||||
graph = iD.actions.MergePolygon(['w0', 'w5'], 'r')(graph);
|
||||
expect(graph.entity('w0').tags.building).to.equal(undefined);
|
||||
expect(graph.entity('r').tags.building).to.equal('yes');
|
||||
});
|
||||
|
||||
it("merges no tags from unclosed outer ways", function() {
|
||||
graph = graph.replace(graph.entity('w3').update({ tags: { 'natural': 'water' }}));
|
||||
|
||||
var r1 = iD.Relation({id: 'r1', tags: {type: 'multipolygon'}});
|
||||
var r2 = iD.Relation({id: 'r2', tags: {type: 'multipolygon'},
|
||||
members: [
|
||||
{ type: 'way', role: 'outer', id: 'w3' },
|
||||
{ type: 'way', role: 'outer', id: 'w4' }
|
||||
]});
|
||||
|
||||
graph = graph.replace(r1).replace(r2);
|
||||
graph = iD.actions.MergePolygon(['r1', 'r2'])(graph);
|
||||
expect(graph.entity('w3').tags.natural).to.equal('water');
|
||||
expect(graph.entity('r1').tags.natural).to.equal(undefined);
|
||||
});
|
||||
|
||||
it("merges no tags from inner ways", function() {
|
||||
graph = graph.replace(graph.entity('w1').update({ tags: { 'natural': 'water' }}));
|
||||
graph = iD.actions.MergePolygon(['w0', 'w1'], 'r')(graph);
|
||||
expect(graph.entity('w1').tags.natural).to.equal('water');
|
||||
expect(graph.entity('w5').tags.amenity).to.equal(undefined);
|
||||
expect(r.tags.building).to.equal('yes');
|
||||
expect(r.tags.natural).to.equal(undefined);
|
||||
expect(r.tags.amenity).to.equal('school');
|
||||
expect(graph.entity('r').tags.natural).to.equal(undefined);
|
||||
});
|
||||
|
||||
it("doesn't copy area tags from ways", function() {
|
||||
|
||||
Reference in New Issue
Block a user