From 95e667d6b7731007d861627b735ebd2a1505d900 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Mon, 28 Oct 2013 15:33:44 -0700 Subject: [PATCH] More tests --- test/spec/core/tree.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/spec/core/tree.js b/test/spec/core/tree.js index 4200a099e..532c9afd7 100644 --- a/test/spec/core/tree.js +++ b/test/spec/core/tree.js @@ -70,6 +70,35 @@ describe("iD.Tree", function() { expect(tree.intersects(extent, graph)).to.eql([node, way]); }); + it("adjusts parent ways when a member node is moved", function() { + var graph = iD.Graph(), + tree = iD.Tree(graph), + node = iD.Node({id: 'n', loc: [1, 1]}), + way = iD.Way({nodes: ['n']}), + extent = iD.geo.Extent([0, 0], [2, 2]); + + graph = graph.replace(node).replace(way); + expect(tree.intersects(extent, graph)).to.eql([node, way]); + + graph = graph.replace(node.move([3, 3])); + expect(tree.intersects(extent, graph)).to.eql([]); + }); + + it("adjusts parent ways when a member node is removed", function() { + var graph = iD.Graph(), + tree = iD.Tree(graph), + n1 = iD.Node({id: 'n1', loc: [1, 1]}), + n2 = iD.Node({id: 'n2', loc: [3, 3]}), + way = iD.Way({nodes: ['n1', 'n2']}), + extent = iD.geo.Extent([0, 0], [2, 2]); + + graph = graph.replace(n1).replace(n2).replace(way); + expect(tree.intersects(extent, graph)).to.eql([n1, way]); + + graph = graph.replace(way.removeNode('n1')); + expect(tree.intersects(extent, graph)).to.eql([n1]); + }); + it("doesn't include removed entities", function() { var graph = iD.Graph(), tree = iD.Tree(graph),