Skip to content

Commit

Permalink
Merge pull request #302 from Bit-Nation/feature/refactor-reducers-act…
Browse files Browse the repository at this point in the history
…ions

Feature/refactor reducers actions
  • Loading branch information
florianlenz committed Mar 17, 2018
2 parents c235966 + 28c497f commit df9ad02
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 23 deletions.
2 changes: 1 addition & 1 deletion __tests__/src/actions/modifyNation.js
Expand Up @@ -44,7 +44,7 @@ describe('modify nation action creators', () => {
});
});

test('startNationEditing', () => {
test('resetNationCreation', () => {
expect(resetNationCreation()).toEqual({
type: RESET_NATION_CREATION,
});
Expand Down
18 changes: 16 additions & 2 deletions __tests__/src/actions/profile.js
@@ -1,6 +1,20 @@
import {
startUserCreating, startUserEditing, changeEditingUser, setUserProfile, cancelUserEditing, doneUserEditing, requestProfileUpdate, getUserProfile,
START_USER_CREATING, START_USER_EDITING, CHANGE_EDITING_USER, SET_USER_PROFILE, CANCEL_USER_EDITING, DONE_USER_EDITING, REQUEST_PROFILE_UPDATE, REQUEST_GET_PROFILE,
startUserCreating,
startUserEditing,
changeEditingUser,
setUserProfile,
cancelUserEditing,
doneUserEditing,
requestProfileUpdate,
getUserProfile,
START_USER_CREATING,
START_USER_EDITING,
CHANGE_EDITING_USER,
SET_USER_PROFILE,
CANCEL_USER_EDITING,
DONE_USER_EDITING,
REQUEST_PROFILE_UPDATE,
REQUEST_GET_PROFILE,
} from '../../../src/actions/profile';

test('actions - startUserCreating', (done) => {
Expand Down
2 changes: 0 additions & 2 deletions __tests__/src/actions/testingMode.js
Expand Up @@ -8,7 +8,6 @@ import {
} from '../../../src/actions/testingMode';

describe('testing mode action creators', () => {

test('makeStep', () => {
expect(makeStep()).toEqual({
type: MAKE_STEP,
Expand All @@ -26,5 +25,4 @@ describe('testing mode action creators', () => {
type: EMPTY_WALLET,
});
});

});
9 changes: 7 additions & 2 deletions __tests__/src/reducers/modifyNation.js
@@ -1,7 +1,12 @@
import reducer, { emptyNation, initialState } from '../../../src/reducers/modifyNation';
import {
cancelNationCreation, deleteNationDraft,
editingNationFieldChange, nationDraftDeleteResult, nationDraftSaveResult, nationSubmitResult, resetNationCreation,
cancelNationCreation,
deleteNationDraft,
editingNationFieldChange,
nationDraftDeleteResult,
nationDraftSaveResult,
nationSubmitResult,
resetNationCreation,
saveNationDraft,
startNationCreation,
startNationEditing, submitNation,
Expand Down
9 changes: 8 additions & 1 deletion __tests__/src/reducers/profile.js
@@ -1,4 +1,11 @@
import { startUserCreating, startUserEditing, changeEditingUser, setUserProfile, cancelUserEditing, doneUserEditing, requestProfileUpdate, getUserProfile } from '../../../src/actions/profile';
import {
startUserCreating,
startUserEditing,
changeEditingUser,
setUserProfile,
cancelUserEditing,
doneUserEditing,
} from '../../../src/actions/profile';
import reducer, { emptyProfile, initialState } from '../../../src/reducers/profile';

test('reducer - user profile creation', (done) => {
Expand Down
6 changes: 0 additions & 6 deletions __tests__/src/reducers/testingMode.js
Expand Up @@ -10,7 +10,6 @@ test('testing mode initial state has isActive set to false', () => {
});

describe('testing mode reducer action handling', () => {

test('resetSteps', () => {
const stateBefore = { initialState, stepsLeftToToggle: stepsCountToToggle - 1 };
const stateAfter = reducer(stateBefore, resetSteps());
Expand All @@ -21,7 +20,6 @@ describe('testing mode reducer action handling', () => {
});

describe('emptyWallet', () => {

const testChangeWalletEmptyTo = (value) => {
const stateBefore = { ...initialState, walletEmpty: !value };
const stateAfter = reducer(stateBefore, emptyWallet());
Expand All @@ -38,11 +36,9 @@ describe('testing mode reducer action handling', () => {
test('walletEmpty changed to true', () => {
testChangeWalletEmptyTo(true);
});

});

describe('makeStep', () => {

const testChangeIsActiveTo = (value) => {
const stateBefore = { ...initialState, isActive: !value };
let stateAfter = stateBefore;
Expand Down Expand Up @@ -74,7 +70,5 @@ describe('testing mode reducer action handling', () => {
stepsLeftToToggle: initialValue - 1,
});
});

});

});
6 changes: 3 additions & 3 deletions src/actions/chat.js
Expand Up @@ -5,8 +5,8 @@ type ShowSpinnerAction = { +type: 'SHOW_CHAT_SPINNER' };
type HideSpinnerAction = { +type: 'HIDE_CHAT_SPINNER' };

export type Action =
| ShowSpinnerAction
| HideSpinnerAction;
| ShowSpinnerAction
| HideSpinnerAction;

/**
* @desc Action for an action that shows spinner while processing in background
Expand All @@ -26,4 +26,4 @@ export function hideSpinner(): HideSpinnerAction {
return {
type: HIDE_CHAT_SPINNER,
};
}
}
8 changes: 3 additions & 5 deletions src/reducers/chat.js
@@ -1,11 +1,9 @@
// @flow

import _ from 'lodash';

import {
type Action,
SHOW_CHAT_SPINNER,
HIDE_CHAT_SPINNER
HIDE_CHAT_SPINNER,
} from '../actions/chat';

type State = {
Expand All @@ -27,12 +25,12 @@ export default (state: State = initialState, action: Action): State => {
case SHOW_CHAT_SPINNER:
return {
...state,
isFetching: true
isFetching: true,
};
case HIDE_CHAT_SPINNER:
return {
...state,
isFetching: false
isFetching: false,
};
default:
return state;
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/index.js
Expand Up @@ -18,7 +18,7 @@ const rootReducer = {
key,
activity,
testingMode,
chat
chat,
};

export default combineReducers(rootReducer);

0 comments on commit df9ad02

Please sign in to comment.