mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 18:20:27 +00:00
added test for adjacency
This commit is contained in:
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user