Skip to content

Commit d7f2f0b

Browse files
Updated the tests and added some extra coverage
1 parent 0c71119 commit d7f2f0b

File tree

8 files changed

+64
-35
lines changed

8 files changed

+64
-35
lines changed

src/layout/__snapshots__/layout.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ exports[`Layout renders correctly 1`] = `
132132
}
133133
}
134134
inverseZoom={false}
135-
maxNumberPointsPerLink={Infinity}
135+
maxNumberPointsPerLink={0}
136136
smartRouting={false}
137137
/>
138138
`;

src/layout/block/__snapshots__/blockWidget.component.test.js.snap

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,21 @@ exports[`BlockWidget block renders correctly 1`] = `
148148
<div
149149
className="BlockWidget-iconContents-7"
150150
>
151-
<span
152-
dangerouslySetInnerHTML={
153-
Object {
154-
"__html": "<svg height=\\"100\\" width=\\"100\\"><circle cx=\\"50\\" cy=\\"50\\" r=\\"40\\" stroke=\\"black\\" stroke-width=\\"3\\" fill=\\"red\\" /></svg>",
155-
}
156-
}
157-
/>
151+
<svg
152+
height="100"
153+
key="0"
154+
width="100"
155+
>
156+
<circle
157+
cx="50"
158+
cy="50"
159+
fill="red"
160+
key="0"
161+
r="40"
162+
stroke="black"
163+
strokeWidth="3"
164+
/>
165+
</svg>
158166
</div>
159167
<div
160168
className="BlockWidget-outputPortsContainer-5"

src/malcolm/malcolmSocketHandler.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,14 +138,6 @@ describe('malcolm socket handler', () => {
138138
configureMalcolmSocketHandlers(socketContainer, store);
139139
});
140140

141-
it('calls connect on reconnecting socket at configure', () => {
142-
configureMalcolmSocketHandlers(reconnectingSocketContainer, store);
143-
jest.runTimersToTime(100);
144-
expect(
145-
reconnectingSocketContainer.socket.mockConnect.mock.calls.length
146-
).toEqual(1);
147-
});
148-
149141
it('sets flag and flushes on open', () => {
150142
socketContainer.queue.push('flushed test');
151143
socketContainer.socket.onopen();

src/navbar/navcontrol.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,12 @@ describe('NavControl', () => {
4848

4949
expect(navigateFunction.mock.calls.length).toEqual(1);
5050
});
51+
52+
it('handles the nav drop down being clicked', () => {
53+
const wrapper = mount(<NavControl nav={nav} navigateToChild={() => {}} />);
54+
55+
wrapper.find('IconButton').simulate('click');
56+
57+
expect(wrapper.state.anchorEl).toEqual('werwer');
58+
});
5159
});

src/viewState/viewState.actions.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { push } from 'react-router-redux';
33
export const openParentPanelType = 'OPEN_PARENT_PANEL';
44
export const openChildPanelType = 'OPEN_CHILD_PANEL';
55
export const updateVersionNumerType = 'UPDATE_VERSION';
6-
export const siteLoadingType = 'SITE_LOADING';
76

87
export const openParentPanel = open => ({
98
type: openParentPanelType,
@@ -36,16 +35,8 @@ export const updateVersionNumber = version => ({
3635
},
3736
});
3837

39-
export const siteLoading = loading => ({
40-
type: siteLoadingType,
41-
payload: {
42-
siteLoading: loading,
43-
},
44-
});
45-
4638
export default {
4739
openParentPanel,
4840
closeChildPanel,
4941
updateChildPanel,
50-
siteLoading,
5142
};

src/viewState/viewState.actions.test.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import { openParentPanel, closeChildPanel } from './viewState.actions';
1+
import {
2+
openParentPanel,
3+
closeChildPanel,
4+
updateVersionNumber,
5+
updateChildPanel,
6+
} from './viewState.actions';
27

38
it('openParentPanel signals the open state of the parent panel', () => {
49
const action = openParentPanel(true);
@@ -13,3 +18,24 @@ it('closeChildPanel updates the route to remove the child', () => {
1318
expect(action.type).toEqual('@@router/CALL_HISTORY_METHOD');
1419
expect(action.payload.args[0]).toEqual('/gui/PANDA/layout');
1520
});
21+
22+
it('updateVersionNumber signals the version number', () => {
23+
const action = updateVersionNumber('1.2.3');
24+
25+
expect(action.type).toEqual('UPDATE_VERSION');
26+
expect(action.payload.version).toEqual('1.2.3');
27+
});
28+
29+
it('updateChildPanel adds to the end of the route if it ends in layout', () => {
30+
const action = updateChildPanel('/gui/PANDA/layout', 'PANDA:SEQ1');
31+
32+
expect(action.type).toEqual('@@router/CALL_HISTORY_METHOD');
33+
expect(action.payload.args[0]).toEqual('/gui/PANDA/layout/PANDA:SEQ1');
34+
});
35+
36+
it('updateChildPanel replaces the end of the route if it does not end in layout', () => {
37+
const action = updateChildPanel('/gui/PANDA/layout/TTLIN1', 'PANDA:SEQ1');
38+
39+
expect(action.type).toEqual('@@router/CALL_HISTORY_METHOD');
40+
expect(action.payload.args[0]).toEqual('/gui/PANDA/layout/PANDA:SEQ1');
41+
});

src/viewState/viewState.reducer.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import {
22
openParentPanelType,
33
updateVersionNumerType,
4-
siteLoadingType,
54
} from './viewState.actions';
65

76
const initialViewState = {
87
openParentPanel: true,
98
openChildPanel: true,
10-
siteLoading: true,
119
};
1210

1311
const viewStateReducer = (state = initialViewState, action) => {
@@ -21,12 +19,6 @@ const viewStateReducer = (state = initialViewState, action) => {
2119
}
2220
return state;
2321

24-
case siteLoadingType:
25-
return {
26-
...state,
27-
siteLoading: action.payload.siteLoading,
28-
};
29-
3022
default:
3123
return state;
3224
}

src/viewState/viewState.reducer.test.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import ViewStateReducer from './viewState.reducer';
2-
import { openParentPanel } from './viewState.actions';
2+
import { openParentPanel, updateVersionNumber } from './viewState.actions';
33

44
describe('view state reducer', () => {
55
let state = {};
@@ -11,9 +11,21 @@ describe('view state reducer', () => {
1111
};
1212
});
1313

14+
it('returns state if not a recognised type', () => {
15+
const newState = ViewStateReducer(state, { type: 'TEST' });
16+
expect(newState).toBe(state);
17+
});
18+
1419
it('openParentPanelType messages update the parent panel state', () => {
1520
const newState = ViewStateReducer(state, openParentPanel(false));
1621
expect(newState.openParentPanel).toEqual(false);
1722
expect(newState.openChildPanel).toEqual(true);
1823
});
24+
25+
it('updateVersionNumerType messages updates the document title', () => {
26+
const newState = ViewStateReducer(state, updateVersionNumber('1.2.3'));
27+
28+
expect(newState).toBe(state);
29+
expect(document.title).toEqual('MalcolmJS 1.2.3');
30+
});
1931
});

0 commit comments

Comments
 (0)