mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Fixed bug in unseen nodes detection
This commit is contained in:
@@ -74,6 +74,31 @@ describe('NodesLayout', () => {
|
||||
};
|
||||
});
|
||||
|
||||
it('detects unseen nodes', () => {
|
||||
const set1 = fromJS({
|
||||
n1: {id: 'n1'}
|
||||
});
|
||||
const set12 = fromJS({
|
||||
n1: {id: 'n1'},
|
||||
n2: {id: 'n2'}
|
||||
});
|
||||
const set13 = fromJS({
|
||||
n1: {id: 'n1'},
|
||||
n3: {id: 'n3'}
|
||||
});
|
||||
let hasUnseen;
|
||||
hasUnseen = NodesLayout.hasUnseenNodes(set12, set1);
|
||||
expect(hasUnseen).toBeTruthy();
|
||||
hasUnseen = NodesLayout.hasUnseenNodes(set13, set1);
|
||||
expect(hasUnseen).toBeTruthy();
|
||||
hasUnseen = NodesLayout.hasUnseenNodes(set1, set12);
|
||||
expect(hasUnseen).toBeFalsy();
|
||||
hasUnseen = NodesLayout.hasUnseenNodes(set1, set13);
|
||||
expect(hasUnseen).toBeFalsy();
|
||||
hasUnseen = NodesLayout.hasUnseenNodes(set12, set13);
|
||||
expect(hasUnseen).toBeTruthy();
|
||||
});
|
||||
|
||||
it('lays out initial nodeset in a rectangle', () => {
|
||||
const result = NodesLayout.doLayout(
|
||||
nodeSets.initial4.nodes,
|
||||
|
||||
@@ -144,9 +144,13 @@ function setSimpleEdgePoints(edge, nodeCache) {
|
||||
* @param {Map} cache old Map of nodes
|
||||
* @return {Boolean} True if nodes had node ids that are not in cache
|
||||
*/
|
||||
function hasUnseenNodes(nodes, cache) {
|
||||
return (nodes.size > cache.size
|
||||
|| !ImmSet.fromKeys(nodes).isSubset(ImmSet.fromKeys(nodes)));
|
||||
export function hasUnseenNodes(nodes, cache) {
|
||||
const hasUnseen = nodes.size > cache.size
|
||||
|| !ImmSet.fromKeys(nodes).isSubset(ImmSet.fromKeys(cache));
|
||||
if (hasUnseen) {
|
||||
debug('unseen nodes:', ...ImmSet.fromKeys(nodes).subtract(ImmSet.fromKeys(cache)).toJS());
|
||||
}
|
||||
return hasUnseen;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user