From 1f6be2d2ba342d2f813a08a4a7e39728ba1ff9f2 Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 26 Oct 2012 13:25:36 -0700 Subject: [PATCH] Fix Entity#parentWays/Relations --- js/iD/Entity.js | 4 ++-- test/spec/Entity.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/js/iD/Entity.js b/js/iD/Entity.js index e6275a1e8..ab42a921a 100755 --- a/js/iD/Entity.js +++ b/js/iD/Entity.js @@ -37,10 +37,10 @@ iD.Entity = function () { }); }; entity.parentWays = function () { - return entity._parentObjectsOfClass('way'); + return _parentObjectsOfClass('way'); }; entity.parentRelations = function () { - return entity._parentObjectsOfClass('relation'); + return _parentObjectsOfClass('relation'); }; function _parentObjectsOfClass(_class) { return _.filter(entity.parentObjects(), function (p) { diff --git a/test/spec/Entity.js b/test/spec/Entity.js index 503b79d9c..34a052767 100644 --- a/test/spec/Entity.js +++ b/test/spec/Entity.js @@ -8,4 +8,20 @@ describe('Entity', function () { it('has no entity type', function () { expect(entity.entityType).toEqual(''); }); + + describe('#parentWays', function () { + it('returns an array of parents with entityType way', function () { + entity.addParent({_id: 1, entityType: 'way'}); + entity.addParent({_id: 2, entityType: 'node'}); + expect(entity.parentWays()).toEqual([{_id: 1, entityType: 'way'}]); + }); + }); + + describe('#parentRelations', function () { + it('returns an array of parents with entityType relation', function () { + entity.addParent({_id: 1, entityType: 'way'}); + entity.addParent({_id: 2, entityType: 'relation'}); + expect(entity.parentRelations()).toEqual([{_id: 2, entityType: 'relation'}]); + }); + }) });