From fa1b536ce7163509f4d3c6d3e7e7fe20f2378613 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Wed, 5 Dec 2012 14:45:41 -0500 Subject: [PATCH] Default relation members to empty array --- js/id/graph/entity.js | 6 +++--- test/spec/graph/entity.js | 8 ++++++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/id/graph/entity.js b/js/id/graph/entity.js index 47487cc91..85d061406 100644 --- a/js/id/graph/entity.js +++ b/js/id/graph/entity.js @@ -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'}); }; diff --git a/test/spec/graph/entity.js b/test/spec/graph/entity.js index baa15cc4f..e28c782ef 100644 --- a/test/spec/graph/entity.js +++ b/test/spec/graph/entity.js @@ -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({}); });