From 4297b0d95b61116dee5f1f7ef00f58ce5daf768b Mon Sep 17 00:00:00 2001 From: Quincy Morgan Date: Thu, 21 Nov 2019 11:20:56 -0500 Subject: [PATCH] Add unit test for single-member multipolygon collapse behavior in actionJoin (re: f7d8c51bd3b61b2964422973acf9c077f4d7164a) --- test/spec/actions/join.js | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/test/spec/actions/join.js b/test/spec/actions/join.js index 9f789e455..15b66de63 100644 --- a/test/spec/actions/join.js +++ b/test/spec/actions/join.js @@ -541,4 +541,42 @@ describe('iD.actionJoin', function () { ]); }); + it('collapses resultant single-member multipolygon into basic area', function () { + // Situation: + // b --> c + // |#####| + // |# m #| + // |#####| + // a <== d + // + // Expected result: + // a --> b + // |#####| + // |#####| + // |#####| + // 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']}), + iD.osmWay({id: '=', nodes: ['d', 'a']}), + iD.osmRelation({id: 'm', tags: { + type: 'multipolygon', + building: 'yes' + }, members: [ + {id: '-', role: 'outer', type: 'way'}, + {id: '=', role: 'outer', type: 'way'} + ]}) + ]); + + 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.hasEntity('=')).to.be.undefined; + expect(graph.hasEntity('m')).to.be.undefined; + }); + });