mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
test to show back browsing is broken
after selecting a node
This commit is contained in:
@@ -5,8 +5,17 @@ describe('AppStore', function() {
|
||||
let AppStore;
|
||||
let registeredCallback;
|
||||
|
||||
// fixtures
|
||||
|
||||
const NODE_SET = {n1: {id: 'n1'}, n2: {id: 'n2'}};
|
||||
|
||||
// actions
|
||||
|
||||
const ClickNodeAction = {
|
||||
type: ActionTypes.CLICK_NODE,
|
||||
nodeId: 'n1'
|
||||
};
|
||||
|
||||
const ClickTopologyAction = {
|
||||
type: ActionTypes.CLICK_TOPOLOGY,
|
||||
topologyId: 'topo1'
|
||||
@@ -17,6 +26,21 @@ describe('AppStore', function() {
|
||||
grouping: 'grouped'
|
||||
};
|
||||
|
||||
const HitEscAction = {
|
||||
type: ActionTypes.HIT_ESC_KEY
|
||||
};
|
||||
|
||||
const ReceiveNodesDeltaAction = {
|
||||
type: ActionTypes.RECEIVE_NODES_DELTA,
|
||||
delta: {
|
||||
add: [{
|
||||
id: 'n1'
|
||||
}, {
|
||||
id: 'n2'
|
||||
}]
|
||||
}
|
||||
};
|
||||
|
||||
const ReceiveTopologiesAction = {
|
||||
type: ActionTypes.RECEIVE_TOPOLOGIES,
|
||||
topologies: [{
|
||||
@@ -26,6 +50,11 @@ describe('AppStore', function() {
|
||||
}]
|
||||
};
|
||||
|
||||
const RouteAction = {
|
||||
type: ActionTypes.ROUTE_TOPOLOGY,
|
||||
state: {}
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
AppStore = require('../app-store');
|
||||
registeredCallback = AppStore.registeredCallback;
|
||||
@@ -58,4 +87,42 @@ describe('AppStore', function() {
|
||||
expect(AppStore.getCurrentTopologyUrl()).toBe('/topo1grouped');
|
||||
});
|
||||
|
||||
// browsing
|
||||
|
||||
it('shows nodes that were received', function() {
|
||||
registeredCallback(ReceiveNodesDeltaAction);
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
});
|
||||
|
||||
it('gets selected node after click', function() {
|
||||
registeredCallback(ReceiveNodesDeltaAction);
|
||||
|
||||
registeredCallback(ClickNodeAction);
|
||||
expect(AppStore.getSelectedNodeId()).toBe('n1');
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
|
||||
registeredCallback(HitEscAction)
|
||||
expect(AppStore.getSelectedNodeId()).toBe(null);
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
});
|
||||
|
||||
it('keeps showing nodes on navigating back after node click', function() {
|
||||
registeredCallback(ReceiveNodesDeltaAction);
|
||||
// TODO clear AppStore cache
|
||||
expect(AppStore.getAppState())
|
||||
.toEqual({"topologyId":"topo1","grouping":"grouped","selectedNodeId": null});
|
||||
|
||||
registeredCallback(ClickNodeAction);
|
||||
expect(AppStore.getAppState())
|
||||
.toEqual({"topologyId":"topo1","grouping":"grouped","selectedNodeId": 'n1'});
|
||||
|
||||
// go back in browsing
|
||||
RouteAction.state = {"topologyId":"topo1","grouping":"grouped","selectedNodeId": null};
|
||||
registeredCallback(RouteAction);
|
||||
expect(AppStore.getSelectedNodeId()).toBe(null);
|
||||
expect(AppStore.getNodes()).toEqual(NODE_SET);
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user