Skip to content

Commit

Permalink
fix(graphReducer,rhsmActions): clean up unused actions
Browse files Browse the repository at this point in the history
* graphReducer, remove unused action types
* rhsmActions, remove unused actions
  • Loading branch information
cdcabrera committed Mar 5, 2020
1 parent 6935cc9 commit d068e3d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 205 deletions.
23 changes: 0 additions & 23 deletions src/redux/actions/__tests__/rhsmActions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,4 @@ describe('RhsmActions', () => {
done();
});
});

it('Should return response content for getGraphReports method', done => {
const store = generateStore();
const dispatcher = rhsmActions.getGraphReports();

dispatcher(store.dispatch).then(() => {
const response = store.getState().graph;
expect(response.report.fulfilled).toBe(true);
done();
});
});

it('Should return response content for getGraphCapacity method', done => {
const store = generateStore();
const dispatcher = rhsmActions.getGraphCapacity();

dispatcher(store.dispatch).then(() => {
const response = store.getState().graph;

expect(response.capacity.fulfilled).toBe(true);
done();
});
});
});
26 changes: 2 additions & 24 deletions src/redux/actions/rhsmActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,6 @@ const getGraphReportsCapacity = (id = null, query = {}) => dispatch =>
}
});

const getGraphReports = (id = null, query = {}) => dispatch =>
dispatch({
type: rhsmTypes.GET_GRAPH_REPORT_RHSM,
payload: rhsmServices.getGraphReports(id, query),
meta: {
id,
query,
notifications: {}
}
});

const getGraphCapacity = (id = null, query = {}) => dispatch =>
dispatch({
type: rhsmTypes.GET_GRAPH_CAPACITY_RHSM,
payload: rhsmServices.getGraphCapacity(id, query),
meta: {
id,
query,
notifications: {}
}
});

const rhsmActions = { getGraphReportsCapacity, getGraphCapacity, getGraphReports };
const rhsmActions = { getGraphReportsCapacity };

export { rhsmActions as default, rhsmActions, getGraphReportsCapacity, getGraphCapacity, getGraphReports };
export { rhsmActions as default, rhsmActions, getGraphReportsCapacity };
136 changes: 0 additions & 136 deletions src/redux/reducers/__tests__/__snapshots__/graphReducer.test.js.snap
Original file line number Diff line number Diff line change
@@ -1,31 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`GraphReducer should handle all defined error types: rejected types GET_GRAPH_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {
"error": true,
"errorMessage": "MESSAGE",
"errorStatus": 0,
"fulfilled": false,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": false,
},
"report": Object {},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_CAPACITY_RHSM_REJECTED",
}
`;

exports[`GraphReducer should handle all defined error types: rejected types GET_GRAPH_REPORT_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {},
"reportCapacity": Object {
"error": true,
"errorMessage": "MESSAGE",
Expand All @@ -42,56 +19,9 @@ Object {
}
`;

exports[`GraphReducer should handle all defined error types: rejected types GET_GRAPH_REPORT_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {
"error": true,
"errorMessage": "MESSAGE",
"errorStatus": 0,
"fulfilled": false,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": false,
},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_REPORT_RHSM_REJECTED",
}
`;

exports[`GraphReducer should handle all defined fulfilled types: fulfilled types GET_GRAPH_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {
"data": Object {
"test": "success",
},
"date": null,
"error": false,
"errorMessage": "",
"fulfilled": true,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": false,
},
"report": Object {},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_CAPACITY_RHSM_FULFILLED",
}
`;

exports[`GraphReducer should handle all defined fulfilled types: fulfilled types GET_GRAPH_REPORT_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {},
"reportCapacity": Object {
"data": Object {
"test": "success",
Expand All @@ -111,55 +41,9 @@ Object {
}
`;

exports[`GraphReducer should handle all defined fulfilled types: fulfilled types GET_GRAPH_REPORT_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {
"data": Object {
"test": "success",
},
"date": null,
"error": false,
"errorMessage": "",
"fulfilled": true,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": false,
},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_REPORT_RHSM_FULFILLED",
}
`;

exports[`GraphReducer should handle all defined pending types: pending types GET_GRAPH_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {
"error": false,
"errorMessage": "",
"fulfilled": false,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": true,
},
"report": Object {},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_CAPACITY_RHSM_PENDING",
}
`;

exports[`GraphReducer should handle all defined pending types: pending types GET_GRAPH_REPORT_CAPACITY_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {},
"reportCapacity": Object {
"error": false,
"errorMessage": "",
Expand All @@ -174,23 +58,3 @@ Object {
"type": "GET_GRAPH_REPORT_CAPACITY_RHSM_PENDING",
}
`;

exports[`GraphReducer should handle all defined pending types: pending types GET_GRAPH_REPORT_RHSM 1`] = `
Object {
"result": Object {
"capacity": Object {},
"report": Object {
"error": false,
"errorMessage": "",
"fulfilled": false,
"meta": Object {},
"metaData": undefined,
"metaId": undefined,
"metaQuery": undefined,
"pending": true,
},
"reportCapacity": Object {},
},
"type": "GET_GRAPH_REPORT_RHSM_PENDING",
}
`;
18 changes: 3 additions & 15 deletions src/redux/reducers/__tests__/graphReducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ describe('GraphReducer', () => {
});

it('should handle all defined error types', () => {
const specificTypes = [
types.GET_GRAPH_REPORT_CAPACITY_RHSM,
types.GET_GRAPH_CAPACITY_RHSM,
types.GET_GRAPH_REPORT_RHSM
];
const specificTypes = [types.GET_GRAPH_REPORT_CAPACITY_RHSM];

specificTypes.forEach(value => {
const dispatched = {
Expand All @@ -39,11 +35,7 @@ describe('GraphReducer', () => {
});

it('should handle all defined pending types', () => {
const specificTypes = [
types.GET_GRAPH_REPORT_CAPACITY_RHSM,
types.GET_GRAPH_CAPACITY_RHSM,
types.GET_GRAPH_REPORT_RHSM
];
const specificTypes = [types.GET_GRAPH_REPORT_CAPACITY_RHSM];

specificTypes.forEach(value => {
const dispatched = {
Expand All @@ -59,11 +51,7 @@ describe('GraphReducer', () => {
});

it('should handle all defined fulfilled types', () => {
const specificTypes = [
types.GET_GRAPH_REPORT_CAPACITY_RHSM,
types.GET_GRAPH_CAPACITY_RHSM,
types.GET_GRAPH_REPORT_RHSM
];
const specificTypes = [types.GET_GRAPH_REPORT_CAPACITY_RHSM];

specificTypes.forEach(value => {
const dispatched = {
Expand Down
8 changes: 1 addition & 7 deletions src/redux/reducers/graphReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { rhsmTypes } from '../types';
import { reduxHelpers } from '../common/reduxHelpers';

const initialState = {
capacity: {},
report: {},
reportCapacity: {}
};

const graphReducer = (state = initialState, action) =>
reduxHelpers.generatedPromiseActionReducer(
[
{ ref: 'reportCapacity', type: rhsmTypes.GET_GRAPH_REPORT_CAPACITY_RHSM },
{ ref: 'capacity', type: rhsmTypes.GET_GRAPH_CAPACITY_RHSM },
{ ref: 'report', type: rhsmTypes.GET_GRAPH_REPORT_RHSM }
],
[{ ref: 'reportCapacity', type: rhsmTypes.GET_GRAPH_REPORT_CAPACITY_RHSM }],
state,
action
);
Expand Down

0 comments on commit d068e3d

Please sign in to comment.