diff --git a/client/app/scripts/stores/__tests__/app-store-test.js b/client/app/scripts/stores/__tests__/app-store-test.js index 1fae1e04d..a6011fa5c 100644 --- a/client/app/scripts/stores/__tests__/app-store-test.js +++ b/client/app/scripts/stores/__tests__/app-store-test.js @@ -285,5 +285,19 @@ describe('AppStore', function() { expect(AppStore.getNodes().toJS()).toEqual({}); }); + // adjacency test + + it('returns the correct adjacency set for a node', function() { + registeredCallback(ReceiveNodesDeltaAction); + expect(AppStore.getAdjacentNodes().size).toEqual(0); + + registeredCallback(ClickNodeAction); + expect(AppStore.getAdjacentNodes().size).toEqual(2); + expect(AppStore.getAdjacentNodes().has('n1')).toBeTruthy(); + expect(AppStore.getAdjacentNodes().has('n2')).toBeTruthy(); + + registeredCallback(HitEscAction) + expect(AppStore.getAdjacentNodes().size).toEqual(0); + }); }); \ No newline at end of file diff --git a/client/app/scripts/stores/app-store.js b/client/app/scripts/stores/app-store.js index bc594492d..8745de52a 100644 --- a/client/app/scripts/stores/app-store.js +++ b/client/app/scripts/stores/app-store.js @@ -102,7 +102,7 @@ const AppStore = assign({}, EventEmitter.prototype, { adjacentNodes = makeSet(nodes.get(selectedNodeId).get('adjacency')); // fill up set with reverse edges nodes.forEach(function(node, nodeId) { - if (node.get('adjacency').includes(selectedNodeId)) { + if (node.get('adjacency') && node.get('adjacency').includes(selectedNodeId)) { adjacentNodes = adjacentNodes.add(nodeId); } });