From 95a14ea722be42361c93bb0502e299e34f48acc1 Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 21 Nov 2019 12:54:59 -0500 Subject: [PATCH] Add unit test for single-member multipolygon collapse behavior exception for conflicting tags in actionJoin (re: f7d8c51bd3b61b2964422973acf9c077f4d7164a) --- test/spec/actions/join.js | 55 ++++++++++++++++++++++++++++++++++----- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/test/spec/actions/join.js b/test/spec/actions/join.js index 15b66de63..4225fb085 100644 --- a/test/spec/actions/join.js +++ b/test/spec/actions/join.js @@ -562,21 +562,64 @@ describe('iD.actionJoin', function () { iD.osmNode({id: 'd', loc: [2,0]}), iD.osmWay({id: '-', nodes: ['a', 'b', 'c', 'd']}), iD.osmWay({id: '=', nodes: ['d', 'a']}), - iD.osmRelation({id: 'm', tags: { - type: 'multipolygon', - building: 'yes' - }, members: [ + iD.osmRelation({id: 'm', members: [ {id: '-', role: 'outer', type: 'way'}, {id: '=', role: 'outer', type: 'way'} - ]}) + ], tags: { + type: 'multipolygon', + man_made: 'pier' + }}) ]); graph = iD.actionJoin(['-', '='])(graph); expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c', 'd', 'a']); - expect(graph.entity('-').tags.building).to.eql('yes'); + expect(graph.entity('-').tags).to.eql({ man_made: 'pier', area: 'yes' }); expect(graph.hasEntity('=')).to.be.undefined; expect(graph.hasEntity('m')).to.be.undefined; }); + it('does not collapse resultant single-member multipolygon into basic area when tags conflict', function () { + // Situation: + // b --> c + // |#####| + // |# m #| + // |#####| + // a <== d + // + // Expected result: + // a --> b + // |#####| + // |# m #| + // |#####| + // d <-- c + var graph = iD.coreGraph([ + iD.osmNode({id: 'a', loc: [0,0]}), + iD.osmNode({id: 'b', loc: [0,2]}), + iD.osmNode({id: 'c', loc: [2,2]}), + iD.osmNode({id: 'd', loc: [2,0]}), + iD.osmWay({id: '-', nodes: ['a', 'b', 'c', 'd'], tags: { surface: 'paved' }}), + iD.osmWay({id: '=', nodes: ['d', 'a']}), + iD.osmRelation({id: 'm', members: [ + {id: '-', role: 'outer', type: 'way'}, + {id: '=', role: 'outer', type: 'way'} + ], tags: { + type: 'multipolygon', + man_made: 'pier', + surface: 'wood' + }}) + ]); + + graph = iD.actionJoin(['-', '='])(graph); + + expect(graph.entity('-').nodes).to.eql(['a', 'b', 'c', 'd', 'a']); + expect(graph.entity('-').tags).to.eql({ surface: 'paved' }); + expect(graph.hasEntity('=')).to.be.undefined; + expect(graph.hasEntity('m').tags).to.eql({ + type: 'multipolygon', + man_made: 'pier', + surface: 'wood' + }); + }); + });