Default relation members to empty array

This commit is contained in:
John Firebaugh
2012-12-05 14:45:41 -05:00
parent 4e87ecbe5f
commit fa1b536ce7
2 changed files with 11 additions and 3 deletions
+3 -3
View File
@@ -30,11 +30,11 @@ iD.Entity.prototype = {
};
iD.Node = function(attrs) {
return iD.Entity({tags: {}}, attrs || {}, {type: 'node'});
return iD.Entity(attrs || {}, {type: 'node'});
};
iD.Way = function(attrs) {
return iD.Entity({tags: {}, nodes: []}, attrs || {}, {type: 'way'});
return iD.Entity({nodes: []}, attrs || {}, {type: 'way'});
};
iD.Way.isOneWay = function(d) {
@@ -50,5 +50,5 @@ iD.Way.isArea = function(d) {
};
iD.Relation = function(attrs) {
return iD.Entity({tags: {}}, attrs || {}, {type: 'relation'});
return iD.Entity({members: []}, attrs || {}, {type: 'relation'});
};
+8
View File
@@ -131,6 +131,14 @@ describe('Relation', function () {
expect(iD.Relation({id: 'r1234'}).modified()).not.to.be.ok;
});
it("defaults members to an empty array", function () {
expect(iD.Relation().members).to.eql([]);
});
it("sets members as specified", function () {
expect(iD.Relation({members: ["n-1"]}).members).to.eql(["n-1"]);
});
it("defaults tags to an empty object", function () {
expect(iD.Relation().tags).to.eql({});
});