mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Update relation tests
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
iD.actions.RemoveRelationMember = function(relationId, memberId) {
|
||||
return function(graph) {
|
||||
var relation = graph.entity(relationId),
|
||||
members = _.without(relation.members, memberId);
|
||||
members = _.reject(relation.members, function(r) {
|
||||
return r.id === memberId;
|
||||
});
|
||||
return graph.replace(relation.update({members: members}));
|
||||
};
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ describe("iD.actions.DeleteNode", function () {
|
||||
|
||||
it("removes the node from parent relations", function () {
|
||||
var node = iD.Node(),
|
||||
relation = iD.Relation({members: [node.id]}),
|
||||
relation = iD.Relation({members: [{ id: node.id }]}),
|
||||
action = iD.actions.DeleteNode(node.id),
|
||||
graph = action(iD.Graph([node, relation]));
|
||||
expect(graph.entity(relation.id).members).not.to.contain(node.id);
|
||||
|
||||
@@ -8,10 +8,10 @@ describe("iD.actions.DeleteWay", function () {
|
||||
|
||||
it("removes a way from parent relations", function () {
|
||||
var way = iD.Way(),
|
||||
relation = iD.Relation({members: [way.id]}),
|
||||
relation = iD.Relation({members: [{ id: 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);
|
||||
expect(_.pluck(graph.entity(relation.id).members, 'id')).not.to.contain(way.id);
|
||||
});
|
||||
|
||||
it("deletes member nodes not referenced by another parent", function () {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe("iD.actions.RemoveRelationMember", function () {
|
||||
it("removes a member from a relation", function () {
|
||||
var node = iD.Node(),
|
||||
relation = iD.Way({members: [node.id]}),
|
||||
relation = iD.Way({members: [{ id: node.id }]}),
|
||||
graph = iD.actions.RemoveRelationMember(relation.id, node.id)(iD.Graph([node, relation]));
|
||||
expect(graph.entity(relation.id).members).to.eql([]);
|
||||
});
|
||||
|
||||
@@ -77,7 +77,7 @@ describe('iD.Graph', function() {
|
||||
describe("#parentRelations", function() {
|
||||
it("returns an array of relations that contain the given entity id", function () {
|
||||
var node = iD.Node({id: "n1"}),
|
||||
relation = iD.Relation({id: "r1", members: ["n1"]}),
|
||||
relation = iD.Relation({id: "r1", members: [{ id: "n1", role: 'from' }]}),
|
||||
graph = iD.Graph({n1: node, r1: relation});
|
||||
expect(graph.parentRelations("n1")).to.eql([relation]);
|
||||
expect(graph.parentRelations("n2")).to.eql([]);
|
||||
|
||||
Reference in New Issue
Block a user