mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-21 22:36:39 +00:00
fix JS error on missing edge target
* replace mergeDeep with merge on node updates to set adjacency to updated value * added json-loader to make json import of websocket frames easier * console message for this was `Cannot read property 'id' of undefined`
This commit is contained in:
@@ -11,7 +11,7 @@ describe('AppStore', function() {
|
||||
n1: {
|
||||
id: 'n1',
|
||||
rank: undefined,
|
||||
adjacency: undefined,
|
||||
adjacency: ['n1', 'n2'],
|
||||
pseudo: undefined,
|
||||
label_major: undefined,
|
||||
label_minor: undefined
|
||||
@@ -64,13 +64,25 @@ describe('AppStore', function() {
|
||||
type: ActionTypes.RECEIVE_NODES_DELTA,
|
||||
delta: {
|
||||
add: [{
|
||||
id: 'n1'
|
||||
id: 'n1',
|
||||
adjacency: ['n1', 'n2']
|
||||
}, {
|
||||
id: 'n2'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
const ReceiveNodesDeltaUpdateAction = {
|
||||
type: ActionTypes.RECEIVE_NODES_DELTA,
|
||||
delta: {
|
||||
update: [{
|
||||
id: 'n1',
|
||||
adjacency: ['n1']
|
||||
}],
|
||||
remove: ['n2']
|
||||
}
|
||||
};
|
||||
|
||||
const ReceiveTopologiesAction = {
|
||||
type: ActionTypes.RECEIVE_TOPOLOGIES,
|
||||
topologies: [{
|
||||
@@ -121,6 +133,15 @@ describe('AppStore', function() {
|
||||
expect(AppStore.getCurrentTopologyUrl()).toBe('/topo1-grouped');
|
||||
});
|
||||
|
||||
// nodes delta
|
||||
|
||||
it('replaces adjacency on update', function() {
|
||||
registeredCallback(ReceiveNodesDeltaAction);
|
||||
expect(AppStore.getNodes().toJS().n1.adjacency).toEqual(['n1', 'n2']);
|
||||
registeredCallback(ReceiveNodesDeltaUpdateAction);
|
||||
expect(AppStore.getNodes().toJS().n1.adjacency).toEqual(['n1']);
|
||||
});
|
||||
|
||||
// browsing
|
||||
|
||||
it('shows nodes that were received', function() {
|
||||
|
||||
@@ -247,7 +247,7 @@ AppStore.registeredCallback = function(payload) {
|
||||
|
||||
// update existing nodes
|
||||
_.each(payload.delta.update, function(node) {
|
||||
nodes = nodes.set(node.id, nodes.get(node.id).mergeDeep(makeNode(node)));
|
||||
nodes = nodes.set(node.id, nodes.get(node.id).merge(makeNode(node)));
|
||||
});
|
||||
|
||||
// add new nodes
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"file-loader": "^0.8.4",
|
||||
"istanbul-instrumenter-loader": "^0.1.3",
|
||||
"jasmine-core": "^2.3.4",
|
||||
"json-loader": "^0.5.2",
|
||||
"karma": "^0.13.3",
|
||||
"karma-cli": "0.0.4",
|
||||
"karma-coverage": "^0.4.2",
|
||||
|
||||
@@ -48,6 +48,10 @@ module.exports = {
|
||||
}
|
||||
],
|
||||
loaders: [
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
},
|
||||
{
|
||||
test: /\.less$/,
|
||||
loader: 'style-loader!css-loader!postcss-loader!less-loader'
|
||||
|
||||
Reference in New Issue
Block a user