mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
More action specs; fix ReverseWay
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
iD.actions.ReverseWay = function(wayId) {
|
||||
return function(graph) {
|
||||
var way = graph.entity(wayId),
|
||||
nodes = way.nodes.slice();
|
||||
nodes = way.nodes.slice().reverse();
|
||||
return graph.replace(way.update({nodes: nodes}), 'changed way direction');
|
||||
};
|
||||
};
|
||||
|
||||
@@ -83,10 +83,18 @@
|
||||
</script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="spec/actions/add_node.js"></script>
|
||||
<script src="spec/actions/add_way.js"></script>
|
||||
<script src="spec/actions/add_way_node.js"></script>
|
||||
<script src="spec/actions/change_entity_tags.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
<script src="spec/actions/move.js"></script>
|
||||
<script src="spec/actions/noop.js"></script>
|
||||
<script src="spec/actions/remove_way_node.js"></script>
|
||||
<script src="spec/actions/remove_relation_member.js"></script>
|
||||
<script src="spec/actions/reverse_way.js"></script>
|
||||
|
||||
<script src="spec/format/geojson.js"></script>
|
||||
<script src="spec/format/xml.js"></script>
|
||||
<script src="spec/graph/graph.js"></script>
|
||||
|
||||
@@ -25,10 +25,18 @@
|
||||
</script>
|
||||
|
||||
<!-- include spec files here... -->
|
||||
<script src="spec/actions/add_node.js"></script>
|
||||
<script src="spec/actions/add_way.js"></script>
|
||||
<script src="spec/actions/add_way_node.js"></script>
|
||||
<script src="spec/actions/change_entity_tags.js"></script>
|
||||
<script src="spec/actions/delete_node.js"></script>
|
||||
<script src="spec/actions/delete_way.js"></script>
|
||||
<script src="spec/actions/move.js"></script>
|
||||
<script src="spec/actions/noop.js"></script>
|
||||
<script src="spec/actions/remove_way_node.js"></script>
|
||||
<script src="spec/actions/remove_relation_member.js"></script>
|
||||
<script src="spec/actions/reverse_way.js"></script>
|
||||
|
||||
<script src="spec/format/geojson.js"></script>
|
||||
<script src="spec/format/xml.js"></script>
|
||||
<script src="spec/graph/graph.js"></script>
|
||||
|
||||
7
test/spec/actions/add_node.js
Normal file
7
test/spec/actions/add_node.js
Normal file
@@ -0,0 +1,7 @@
|
||||
describe("iD.actions.AddNode", function () {
|
||||
it("adds a node to the graph", function () {
|
||||
var node = iD.Node(),
|
||||
graph = iD.actions.AddNode(node)(iD.Graph());
|
||||
expect(graph.entity(node.id)).to.equal(node);
|
||||
});
|
||||
});
|
||||
7
test/spec/actions/add_way.js
Normal file
7
test/spec/actions/add_way.js
Normal file
@@ -0,0 +1,7 @@
|
||||
describe("iD.actions.AddWay", function () {
|
||||
it("adds a way to the graph", function () {
|
||||
var way = iD.Way(),
|
||||
graph = iD.actions.AddWay(way)(iD.Graph());
|
||||
expect(graph.entity(way.id)).to.equal(way);
|
||||
});
|
||||
});
|
||||
8
test/spec/actions/change_entity_tags.js
Normal file
8
test/spec/actions/change_entity_tags.js
Normal file
@@ -0,0 +1,8 @@
|
||||
describe("iD.actions.ChangeEntityTags", function () {
|
||||
it("changes an entity's tags", function () {
|
||||
var entity = iD.Entity(),
|
||||
tags = {foo: 'bar'},
|
||||
graph = iD.actions.ChangeEntityTags(entity.id, tags)(iD.Graph([entity]));
|
||||
expect(graph.entity(entity.id).tags).to.eql(tags);
|
||||
});
|
||||
});
|
||||
8
test/spec/actions/move.js
Normal file
8
test/spec/actions/move.js
Normal file
@@ -0,0 +1,8 @@
|
||||
describe("iD.actions.Move", function () {
|
||||
it("changes an entity's location", function () {
|
||||
var entity = iD.Entity(),
|
||||
loc = [2, 3],
|
||||
graph = iD.actions.Move(entity.id, loc)(iD.Graph([entity]));
|
||||
expect(graph.entity(entity.id).loc).to.eql(loc);
|
||||
});
|
||||
});
|
||||
7
test/spec/actions/noop.js
Normal file
7
test/spec/actions/noop.js
Normal file
@@ -0,0 +1,7 @@
|
||||
describe("iD.actions.Noop", function () {
|
||||
it("does nothing", function () {
|
||||
var graph = iD.Graph(),
|
||||
action = iD.actions.Noop(graph);
|
||||
expect(action(graph)).to.equal(graph);
|
||||
});
|
||||
});
|
||||
8
test/spec/actions/remove_relation_member.js
Normal file
8
test/spec/actions/remove_relation_member.js
Normal file
@@ -0,0 +1,8 @@
|
||||
describe("iD.actions.RemoveRelationMember", function () {
|
||||
it("removes a member from a relation", function () {
|
||||
var node = iD.Node(),
|
||||
relation = iD.Way({members: [node.id]}),
|
||||
graph = iD.actions.RemoveRelationMember(relation.id, node.id)(iD.Graph([node, relation]));
|
||||
expect(graph.entity(relation.id).members).to.eql([]);
|
||||
});
|
||||
});
|
||||
9
test/spec/actions/reverse_way.js
Normal file
9
test/spec/actions/reverse_way.js
Normal file
@@ -0,0 +1,9 @@
|
||||
describe("iD.actions.ReverseWay", function () {
|
||||
it("reverses the order of nodes in the way", function () {
|
||||
var node1 = iD.Node(),
|
||||
node2 = iD.Node(),
|
||||
way = iD.Way({nodes: [node1.id, node2.id]}),
|
||||
graph = iD.actions.ReverseWay(way.id)(iD.Graph([node1, node2, way]));
|
||||
expect(graph.entity(way.id).nodes).to.eql([node2.id, node1.id]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user