Files
iD/test/spec/actions/delete_way.js
John Firebaugh 9743ee282b More mode and action overhaul
Pass entities to actions via id; this allows safe composition
of actions that modify the same entity.

Fix remaining ghost node cases (#213).

Create more logical undo states when drawing.
2012-12-06 18:39:51 -05:00

50 lines
2.0 KiB
JavaScript

describe("iD.actions.DeleteWay", function () {
it("removes the way from the graph", function () {
var way = iD.Way(),
action = iD.actions.DeleteWay(way.id),
graph = action(iD.Graph([way]));
expect(graph.entity(way.id)).to.be.undefined;
});
it("removes a way from parent relations", function () {
var way = iD.Way(),
relation = iD.Relation({members: [way.id]}),
action = iD.actions.DeleteWay(way.id),
graph = action(iD.Graph([way, relation]));
expect(graph.entity(relation.id).members).not.to.contain(way.id);
});
it("deletes member nodes not referenced by another parent", function () {
var node = iD.Node(),
way = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way.id),
graph = action(iD.Graph([node, way]));
expect(graph.entity(node.id)).to.be.undefined;
});
it("does not delete member nodes referenced by another parent", function () {
var node = iD.Node(),
way1 = iD.Way({nodes: [node.id]}),
way2 = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way1.id),
graph = action(iD.Graph([node, way1, way2]));
expect(graph.entity(node.id)).not.to.be.undefined;
});
it("does not delete member nodes with interesting tags", function () {
var node = iD.Node({tags: {highway: 'traffic_signals'}}),
way = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way.id),
graph = action(iD.Graph([node, way]));
expect(graph.entity(node.id)).not.to.be.undefined;
});
it("registers member nodes with interesting tags as POIs", function () {
var node = iD.Node({tags: {highway: 'traffic_signals'}}),
way = iD.Way({nodes: [node.id]}),
action = iD.actions.DeleteWay(way.id),
graph = action(iD.Graph([node, way]));
expect(graph.entity(node.id)._poi).to.be.ok;
});
});