Skip to content

Commit f22b112

Browse files
committed
comment out SHOW_WARNING and HIDE_WARNING actions throughout the app as it was obsolete; Write uiReducer tests; new script to distinguish between mocha and jest
1 parent e2b25f6 commit f22b112

File tree

5 files changed

+86
-82
lines changed

5 files changed

+86
-82
lines changed

__tests__/uiReducer.js

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,51 @@
1-
import reducer from "../src/client/reducers/ui";
1+
import uiReducer from "../src/client/reducers/ui";
2+
import { SET_COMPOSER_DISPLAY } from "../src/client/actions/actionTypes";
23

34
describe("UI Reducer", () => {
45
let state;
56

67
beforeEach(() => {
78
state = {
8-
warningIsDisplayed: null,
99
composerDisplay: "Request",
1010
};
1111
});
1212

13-
describe("SHOW_WARNING", () => {
14-
const action = { type: "SHOW_WARNING" };
15-
16-
it("should set warningIsDisplayed to true", () => {
17-
const { warningIsDisplayed } = reducer(state, action);
18-
expect(warningIsDisplayed).toBe(true);
13+
describe("default state", () => {
14+
it("should return a default state when given an undefined input", () => {
15+
expect(uiReducer(undefined, { type: undefined })).toEqual(state);
1916
});
20-
});
21-
22-
describe("HIDE_WARNING", () => {
23-
const action = { type: "HIDE_WARNING" };
24-
25-
it("should set warningIsDisplayed to false", () => {
26-
const { warningIsDisplayed } = reducer(state, action);
27-
expect(warningIsDisplayed).toBe(false);
17+
it("should return default state with unrecognized action types", () => {
18+
expect(uiReducer(undefined, { type: "BAD_TYPE" })).toEqual(state);
2819
});
2920
});
3021

31-
describe("SET_COMPOSER_DISPLAY", () => {
32-
const action = { type: "SET_COMPOSER_DISPLAY", payload: "CHANGE" };
33-
22+
describe("should handle SET_COMPOSER_DISPLAY", () => {
3423
it("should update the composerDisplay", () => {
35-
const { composerDisplay } = reducer(state, action);
36-
expect(composerDisplay).toEqual(action.payload);
24+
const action = {
25+
type: SET_COMPOSER_DISPLAY,
26+
payload: "Warning",
27+
};
28+
expect(uiReducer(undefined, action)).toEqual({
29+
composerDisplay: "Warning",
30+
});
3731
});
3832
});
33+
34+
// describe("SHOW_WARNING", () => {
35+
// const action = { type: "SHOW_WARNING" };
36+
37+
// it("should set warningIsDisplayed to true", () => {
38+
// const { warningIsDisplayed } = reducer(state, action);
39+
// expect(warningIsDisplayed).toBe(true);
40+
// });
41+
// });
42+
43+
// describe("HIDE_WARNING", () => {
44+
// const action = { type: "HIDE_WARNING" };
45+
46+
// it("should set warningIsDisplayed to false", () => {
47+
// const { warningIsDisplayed } = reducer(state, action);
48+
// expect(warningIsDisplayed).toBe(false);
49+
// });
50+
// });
3951
});

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "main.js",
66
"repository": "https://github.com/open-source-labs/Swell",
77
"scripts": {
8-
"test": "jest",
8+
"test-jest": "jest",
99
"test-mocha": "mocha",
1010
"prod": "webpack --mode production --config webpack.build.config.js && electron --noDevServer .",
1111
"start": "webpack-dev-server --mode development --hot --host 0.0.0.0 --config=./webpack.dev.config.js ",
@@ -23,8 +23,7 @@
2323
"email": "swell@getswell.io",
2424
"url": "http://www.getswell.io"
2525
},
26-
"contributors": [
27-
{
26+
"contributors": [{
2827
"name": "Kyle Combs",
2928
"email": "combskyle@gmail.com",
3029
"url": "https://github.com/texpatnyc"
@@ -130,8 +129,7 @@
130129
"createDesktopShortcut": "always"
131130
},
132131
"dmg": {
133-
"contents": [
134-
{
132+
"contents": [{
135133
"x": 130,
136134
"y": 220
137135
},

src/client/actions/actionTypes.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
// BUSINESS LOGIC ACTIONS
2-
export const REQRES_CLEAR = 'REQRES_CLEAR';
3-
export const REQRES_ADD = 'REQRES_ADD';
4-
export const REQRES_DELETE = 'REQRES_DELETE';
5-
export const REQRES_UPDATE = 'REQRES_UPDATE';
2+
export const REQRES_CLEAR = "REQRES_CLEAR";
3+
export const REQRES_ADD = "REQRES_ADD";
4+
export const REQRES_DELETE = "REQRES_DELETE";
5+
export const REQRES_UPDATE = "REQRES_UPDATE";
66

7-
export const GET_HISTORY = 'GET_HISTORY';
8-
export const DELETE_HISTORY = 'DELETE_HISTORY';
9-
export const CLEAR_HISTORY = 'CLEAR_HISTORY';
7+
export const GET_HISTORY = "GET_HISTORY";
8+
export const DELETE_HISTORY = "DELETE_HISTORY";
9+
export const CLEAR_HISTORY = "CLEAR_HISTORY";
1010

11-
export const GET_COLLECTIONS = 'GET_COLLECTIONS';
12-
export const DELETE_COLLECTION = 'DELETE_COLLECTION';
13-
export const COLLECTION_TO_REQRES = 'COLLECTION_TO_REQRES';
14-
export const COLLECTION_ADD = 'COLLECTION_ADD';
11+
export const GET_COLLECTIONS = "GET_COLLECTIONS";
12+
export const DELETE_COLLECTION = "DELETE_COLLECTION";
13+
export const COLLECTION_TO_REQRES = "COLLECTION_TO_REQRES";
14+
export const COLLECTION_ADD = "COLLECTION_ADD";
1515

1616
export const SET_COMPOSER_WARNING_MESSAGE = "SET_COMPOSER_WARNING_MESSAGE";
1717

@@ -26,10 +26,7 @@ export const SET_CURRENT_TAB = "SET_CURRENT_TAB";
2626

2727
export const SET_CHECKS_AND_MINIS = "SET_CHECKS_AND_MINIS";
2828

29-
30-
31-
3229
//UI ACTIONS
33-
export const SHOW_WARNING = "SHOW_WARNING";
34-
export const HIDE_WARNING = "HIDE_WARNING";
30+
// export const SHOW_WARNING = "SHOW_WARNING";
31+
// export const HIDE_WARNING = "HIDE_WARNING";
3532
export const SET_COMPOSER_DISPLAY = "SET_COMPOSER_DISPLAY";

src/client/actions/actions.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as types from './actionTypes';
1+
import * as types from "./actionTypes";
22

33
// BUSINESS LOGIC ACTIONS
4-
export const getHistory = history => ({
4+
export const getHistory = (history) => ({
55
type: types.GET_HISTORY,
66
payload: history,
77
});
88

9-
export const deleteFromHistory = reqRes => ({
9+
export const deleteFromHistory = (reqRes) => ({
1010
type: types.DELETE_HISTORY,
1111
payload: reqRes,
1212
});
@@ -15,22 +15,22 @@ export const clearHistory = () => ({
1515
type: types.CLEAR_HISTORY,
1616
});
1717

18-
export const getCollections = collections => ({
18+
export const getCollections = (collections) => ({
1919
type: types.GET_COLLECTIONS,
2020
payload: collections,
2121
});
2222

23-
export const deleteFromCollection = collection => ({
23+
export const deleteFromCollection = (collection) => ({
2424
type: types.DELETE_COLLECTION,
2525
payload: collection,
2626
});
2727

28-
export const collectionToReqRes = reqResArray => ({
28+
export const collectionToReqRes = (reqResArray) => ({
2929
type: types.COLLECTION_TO_REQRES,
3030
payload: reqResArray,
3131
});
3232

33-
export const collectionAdd = collection => ({
33+
export const collectionAdd = (collection) => ({
3434
type: types.COLLECTION_ADD,
3535
payload: collection,
3636
});
@@ -39,55 +39,54 @@ export const reqResClear = () => ({
3939
type: types.REQRES_CLEAR,
4040
});
4141

42-
export const reqResAdd = reqRes => ({
42+
export const reqResAdd = (reqRes) => ({
4343
type: types.REQRES_ADD,
4444
payload: reqRes,
4545
});
4646

47-
export const reqResDelete = reqRes => ({
47+
export const reqResDelete = (reqRes) => ({
4848
type: types.REQRES_DELETE,
4949
payload: reqRes,
5050
});
5151

52-
export const reqResUpdate = reqRes => ({
52+
export const reqResUpdate = (reqRes) => ({
5353
type: types.REQRES_UPDATE,
5454
payload: reqRes,
5555
});
5656

57-
export const setComposerWarningMessage = message => ({
57+
export const setComposerWarningMessage = (message) => ({
5858
type: types.SET_COMPOSER_WARNING_MESSAGE,
5959
payload: message,
6060
});
6161

62-
6362
export const setNewRequestFields = (requestObj) => ({
6463
type: types.SET_NEW_REQUEST_FIELDS,
65-
payload : requestObj
64+
payload: requestObj,
6665
});
6766

6867
export const setNewRequestHeaders = (headers) => ({
6968
type: types.SET_NEW_REQUEST_HEADERS,
70-
payload : headers
69+
payload: headers,
7170
});
7271

7372
export const setNewRequestStreams = (streams) => ({
7473
type: types.SET_NEW_REQUEST_STREAMS,
75-
payload : streams
74+
payload: streams,
7675
});
7776

7877
export const setNewRequestBody = (body) => ({
7978
type: types.SET_NEW_REQUEST_BODY,
80-
payload : body
79+
payload: body,
8180
});
8281

8382
export const setNewRequestCookies = (cookies) => ({
8483
type: types.SET_NEW_REQUEST_COOKIES,
85-
payload : cookies
84+
payload: cookies,
8685
});
8786

8887
export const setNewRequestSSE = (SSEBool) => ({
8988
type: types.SET_NEW_REQUEST_SSE,
90-
payload : SSEBool
89+
payload: SSEBool,
9190
});
9291

9392
export const setCurrentTab = (tab) => ({
@@ -100,17 +99,16 @@ export const setChecksAndMinis = (reqResArray) => ({
10099
payload: reqResArray,
101100
});
102101

103-
104102
// UI ACTIONS
105-
export const showWarning = () => ({
106-
type: types.SHOW_WARNING,
107-
});
103+
// export const showWarning = () => ({
104+
// type: types.SHOW_WARNING,
105+
// });
108106

109-
export const hideWarning = () => ({
110-
type: types.HIDE_WARNING,
111-
});
107+
// export const hideWarning = () => ({
108+
// type: types.HIDE_WARNING,
109+
// });
112110

113-
export const setComposerDisplay = composerDisplay => ({
111+
export const setComposerDisplay = (composerDisplay) => ({
114112
type: types.SET_COMPOSER_DISPLAY,
115113
payload: composerDisplay,
116114
});

src/client/reducers/ui.js

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
import * as types from "../actions/actionTypes";
22

33
const initialState = {
4-
warningIsDisplayed: true,
4+
// warningIsDisplayed: true,
55
composerDisplay: "Request",
66
};
77

88
const uiReducer = (state = initialState, action) => {
99
switch (action.type) {
10-
case types.SHOW_WARNING: {
11-
return {
12-
...state,
13-
warningIsDisplayed: true,
14-
};
15-
}
10+
// case types.SHOW_WARNING: {
11+
// return {
12+
// ...state,
13+
// warningIsDisplayed: true,
14+
// };
15+
// }
1616

17-
case types.HIDE_WARNING: {
18-
return {
19-
...state,
20-
warningIsDisplayed: false,
21-
};
22-
}
17+
// case types.HIDE_WARNING: {
18+
// return {
19+
// ...state,
20+
// warningIsDisplayed: false,
21+
// };
22+
// }
2323

2424
case types.SET_COMPOSER_DISPLAY: {
2525
return {
26-
...state,
2726
composerDisplay: action.payload,
2827
};
2928
}

0 commit comments

Comments
 (0)