diff --git a/spec/EntitySpec.js b/spec/EntitySpec.js index ab14486..16abb4f 100644 --- a/spec/EntitySpec.js +++ b/spec/EntitySpec.js @@ -174,6 +174,28 @@ describe("Entity.hasConnectorAnchor", function() { }); }); +describe("Entity.hasAnyConnectorAnchor", function() { + it("returns true if 1+ anchor is assigned to Entity", function() { + const entity = new Entity( + "obj-123", + 100, + 200, + 10, + 20, + sheet, + window.document.createElement('div'), + [window.document.createElement('div')], + [window.document.createElement('div')] + ); + + const anchorElemA = window.document.createElement('div'); + const anchorElemB = window.document.createElement('div'); + const newAnchorA = entity.addInteractableConnectorAnchor(anchorElemA); + + expect(entity.hasAnyConnectorAnchor([newAnchorA, anchorElemB])).toBe(true); + }); +}); + describe("Entity.translate", function() { it("translates entity", function() { const entityDomElem = window.document.createElement('div'); diff --git a/src/Entity.js b/src/Entity.js index 8a5a387..e84be4f 100644 --- a/src/Entity.js +++ b/src/Entity.js @@ -111,10 +111,21 @@ function Entity(_id, _x, _y, _width, _height, _sheet, _domElement, _translateHan * @returns {Boolean} */ this.hasConnectorAnchor = function(_anchor) { - const anchors = self.getConnectorAnchors(); - for(let i=0; i