Skip to content

Commit 5c4e74a

Browse files
committed
added reducer testing folder
1 parent a8fafb2 commit 5c4e74a

File tree

2 files changed

+67
-2
lines changed

2 files changed

+67
-2
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"electron": "cross-env NODE_ENV=development electron .",
7272
"build": "cross-env NODE_ENV=production webpack --config webpack.config.production.js",
7373
"build-bin": "electron-builder -mwl",
74-
"test": "cross-env NODE_ENV=test jest",
74+
"test": "cross-env NODE_ENV=test jest --verbose",
7575
"test:clear": "cross-env NODE_ENV=test jest --clearCache",
7676
"linter": "eslint src",
7777
"develop": "concurrently \"npm run dev\" \"npm run electron\""
@@ -184,7 +184,7 @@
184184
"extract-text-webpack-plugin": "^4.0.0-beta.0",
185185
"html-webpack-plugin": "^3.1.0",
186186
"identity-obj-proxy": "^3.0.0",
187-
"jest": "^23.6.0",
187+
"jest": "^25.2.6",
188188
"node-sass": "^4.13.1",
189189
"postcss-loader": "^2.1.6",
190190
"redux-mock-store": "^1.5.4",
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import * as reducers from '../leftReducers.ts';
2+
import { initialApplicationState } from '../initialState.ts';
3+
4+
initialApplicationState.describe('Left reducers', () => {
5+
let state;
6+
7+
// redefine the default state before each reducer test
8+
beforeEach(() => {
9+
state = {
10+
editMode: -1,
11+
testing: 'testingReducer',
12+
codeReadOnly: true,
13+
components: [
14+
{
15+
changed: true,
16+
childrenArray: [{}],
17+
classBased: false,
18+
code: '....',
19+
color: '#FF6D00',
20+
focusChild: {},
21+
focusChildId: -1,
22+
id: 1,
23+
nextChildId: 3,
24+
nextPropId: 2,
25+
position: {
26+
height: 850,
27+
width: 500,
28+
x: 70,
29+
y: 100
30+
},
31+
props: [],
32+
stateful: false,
33+
title: 'App'
34+
}
35+
]
36+
};
37+
});
38+
39+
describe('toggleComponentState', () => {
40+
it('inverts the statefulness of component passed in', () => {});
41+
});
42+
43+
// toggleEditMode reducer allows changing of component names in left container
44+
describe('toggleEditMode reducer', () => {
45+
it('should return the same state if id === 1', () => {
46+
const action = {
47+
type: 'EDIT_MODE',
48+
payload: { id: 1 }
49+
};
50+
51+
const newState = reducers.toggleEditMode(state, action.payload);
52+
expect(newState).toStrictEqual(state);
53+
});
54+
55+
it('should return new state with updated editMode', () => {
56+
const action = {
57+
type: 'EDIT_MODE',
58+
payload: { id: 2 }
59+
};
60+
61+
const newState = reducers.toggleEditMode(state, action.payload);
62+
expect(newState.editMode).toEqual(action.payload.id);
63+
});
64+
});
65+
});

0 commit comments

Comments
 (0)