Move node update into addWayNode action

This commit is contained in:
John Firebaugh
2012-12-04 17:53:34 -05:00
parent 82b14df12f
commit f8fde1f10d
7 changed files with 97 additions and 51 deletions
+1
View File
@@ -63,6 +63,7 @@
</script>
<!-- include spec files here... -->
<script src="spec/actions/add_way_node.js"></script>
<script src="spec/format/geojson.js"></script>
<script src="spec/format/xml.js"></script>
<script src="spec/graph/graph.js"></script>
+1
View File
@@ -25,6 +25,7 @@
</script>
<!-- include spec files here... -->
<script src="spec/actions/add_way_node.js"></script>
<script src="spec/format/geojson.js"></script>
<script src="spec/format/xml.js"></script>
<script src="spec/graph/graph.js"></script>
+15
View File
@@ -0,0 +1,15 @@
describe("iD.actions.addWayNode", function () {
it("adds a node to the end of a way", function () {
var way = iD.Way(),
node = iD.Node({id: "n1"}),
graph = iD.actions.addWayNode(way, node)(iD.Graph());
expect(graph.entity(way.id).nodes).to.eql(["n1"]);
});
it("adds a node to a way at the specified index", function () {
var way = iD.Way({nodes: ["n1", "n3"]}),
node = iD.Node({id: "n2"}),
graph = iD.actions.addWayNode(way, node, 1)(iD.Graph());
expect(graph.entity(way.id).nodes).to.eql(["n1", "n2", "n3"]);
});
});