From 71c0707a904aad21f984f7dc200e8f96c9bf171d Mon Sep 17 00:00:00 2001 From: Harrison Healey Date: Wed, 9 Nov 2016 10:40:20 -0500 Subject: [PATCH] Stopped aliasing action types --- src/actions/channels.js | 10 +++++----- src/actions/device.js | 8 ++++---- src/actions/general.js | 20 ++++++++++---------- src/actions/login.js | 8 ++++---- src/actions/logout.js | 8 ++++---- src/actions/teams.js | 10 +++++----- src/constants/index.js | 14 +++++++------- src/reducers/channels.js | 14 ++++++++------ src/reducers/device.js | 13 +++++++------ src/reducers/general.js | 24 +++++++++++++----------- src/reducers/login.js | 9 ++++----- src/reducers/logout.js | 8 ++++---- src/reducers/posts.js | 9 ++++----- src/reducers/teams.js | 11 +++++------ test/reducers/channels.test.js | 18 +++++++++--------- test/reducers/device.test.js | 14 +++++++------- test/reducers/general.test.js | 26 +++++++++++++------------- test/reducers/login.test.js | 14 +++++++------- test/reducers/logout.test.js | 14 +++++++------- test/reducers/posts.test.js | 14 +++++++------- test/reducers/teams.test.js | 18 +++++++++--------- 21 files changed, 143 insertions(+), 141 deletions(-) diff --git a/src/actions/channels.js b/src/actions/channels.js index 741c7ff8c..fcc5b61ce 100644 --- a/src/actions/channels.js +++ b/src/actions/channels.js @@ -3,11 +3,11 @@ import {bindClientFunc} from './helpers.js'; import Client from 'client/client_instance'; -import {ChannelsTypes as types} from 'constants'; +import {ChannelsTypes} from 'constants'; export function selectChannel(channel) { return { - type: types.SELECT_CHANNEL, + type: ChannelsTypes.SELECT_CHANNEL, channelId: channel.id }; } @@ -15,8 +15,8 @@ export function selectChannel(channel) { export function fetchChannels() { return bindClientFunc( Client.fetchChannels, - types.FETCH_CHANNELS_REQUEST, - types.FETCH_CHANNELS_SUCCESS, - types.FETCH_CHANNELS_FAILURE + ChannelsTypes.FETCH_CHANNELS_REQUEST, + ChannelsTypes.FETCH_CHANNELS_SUCCESS, + ChannelsTypes.FETCH_CHANNELS_FAILURE ); } diff --git a/src/actions/device.js b/src/actions/device.js index bac932cad..a0c70cb05 100644 --- a/src/actions/device.js +++ b/src/actions/device.js @@ -3,16 +3,16 @@ import {requestData, requestSuccess, requestFailure} from './helpers.js'; import {AsyncStorage} from 'react-native'; -import {DeviceTypes as types} from 'constants'; +import {DeviceTypes} from 'constants'; function fetchDevice() { return async (dispatch) => { try { - dispatch(requestData(types.DEVICE_REQUEST)); + dispatch(requestData(DeviceTypes.DEVICE_REQUEST)); const json = await AsyncStorage.getItem('basic_info'); - dispatch(requestSuccess(types.DEVICE_SUCCESS, JSON.parse(json))); + dispatch(requestSuccess(DeviceTypes.DEVICE_SUCCESS, JSON.parse(json))); } catch (err) { - dispatch(requestFailure(types.DEVICE_FAILURE, {msg: 'failed to load local storage'})); + dispatch(requestFailure(DeviceTypes.DEVICE_FAILURE, {msg: 'failed to load local storage'})); } }; } diff --git a/src/actions/general.js b/src/actions/general.js index decda71e2..ce69120d9 100644 --- a/src/actions/general.js +++ b/src/actions/general.js @@ -3,32 +3,32 @@ import Client from 'client/client_instance.js'; import {bindClientFunc} from './helpers.js'; -import {GeneralTypes as types} from 'constants'; +import {GeneralTypes} from 'constants'; export function getPing() { return bindClientFunc( Client.getPing, - types.PING_REQUEST, - types.PING_SUCCESS, - types.PING_FAILURE + GeneralTypes.PING_REQUEST, + GeneralTypes.PING_SUCCESS, + GeneralTypes.PING_FAILURE ); } export function getClientConfig() { return bindClientFunc( Client.getClientConfig, - types.CLIENT_CONFIG_REQUEST, - types.CLIENT_CONFIG_SUCCESS, - types.CLIENT_CONFIG_FAILURE + GeneralTypes.CLIENT_CONFIG_REQUEST, + GeneralTypes.CLIENT_CONFIG_SUCCESS, + GeneralTypes.CLIENT_CONFIG_FAILURE ); } export function logClientError(message, level = 'ERROR') { return bindClientFunc( Client.logClientError, - types.LOG_CLIENT_ERROR_REQUEST, - types.LOG_CLIENT_ERROR_SUCCESS, - types.LOG_CLIENT_ERROR_FAILURE, + GeneralTypes.LOG_CLIENT_ERROR_REQUEST, + GeneralTypes.LOG_CLIENT_ERROR_SUCCESS, + GeneralTypes.LOG_CLIENT_ERROR_FAILURE, message, level ); diff --git a/src/actions/login.js b/src/actions/login.js index 2f74c37bd..cc77081c4 100644 --- a/src/actions/login.js +++ b/src/actions/login.js @@ -1,16 +1,16 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {LoginTypes as types} from 'constants'; +import {LoginTypes} from 'constants'; import Client from 'client/client_instance'; import {bindClientFunc} from 'actions/helpers.js'; export function login(loginId, password, mfaToken = '') { return bindClientFunc( Client.login, - types.LOGIN_REQUEST, - types.LOGIN_SUCCESS, - types.LOGIN_FAILURE, + LoginTypes.LOGIN_REQUEST, + LoginTypes.LOGIN_SUCCESS, + LoginTypes.LOGIN_FAILURE, loginId, password, mfaToken diff --git a/src/actions/logout.js b/src/actions/logout.js index 265d9674a..fce6e4f1d 100644 --- a/src/actions/logout.js +++ b/src/actions/logout.js @@ -1,15 +1,15 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {LogoutTypes as types} from 'constants'; +import {LogoutTypes} from 'constants'; import Client from 'client/client_instance'; import {bindClientFunc} from 'actions/helpers.js'; export function logout() { return bindClientFunc( Client.logout, - types.LOGOUT_REQUEST, - types.LOGOUT_SUCCESS, - types.LOGOUT_FAILURE + LogoutTypes.LOGOUT_REQUEST, + LogoutTypes.LOGOUT_SUCCESS, + LogoutTypes.LOGOUT_FAILURE ); } diff --git a/src/actions/teams.js b/src/actions/teams.js index 649fdaaaa..fe2b08968 100644 --- a/src/actions/teams.js +++ b/src/actions/teams.js @@ -3,12 +3,12 @@ import {bindClientFunc} from './helpers.js'; import Client from 'client/client_instance'; -import {TeamsTypes as types} from 'constants'; +import {TeamsTypes} from 'constants'; export function selectTeam(team) { Client.setTeamId(team.id); return { - type: types.SELECT_TEAM, + type: TeamsTypes.SELECT_TEAM, teamId: team.id }; } @@ -16,8 +16,8 @@ export function selectTeam(team) { export function fetchTeams() { return bindClientFunc( Client.fetchTeams, - types.FETCH_TEAMS_REQUEST, - types.FETCH_TEAMS_SUCCESS, - types.FETCH_TEAMS_FAILURE + TeamsTypes.FETCH_TEAMS_REQUEST, + TeamsTypes.FETCH_TEAMS_SUCCESS, + TeamsTypes.FETCH_TEAMS_FAILURE ); } diff --git a/src/constants/index.js b/src/constants/index.js index 526c1d067..23ad6cc6f 100644 --- a/src/constants/index.js +++ b/src/constants/index.js @@ -10,11 +10,11 @@ import * as TeamsTypes from './teams'; import * as PostsTypes from './posts'; export { - DeviceTypes, - GeneralTypes, - LoginTypes, - LogoutTypes, - TeamsTypes, - ChannelsTypes, - PostsTypes + DeviceTypes, + GeneralTypes, + LoginTypes, + LogoutTypes, + TeamsTypes, + ChannelsTypes, + PostsTypes }; diff --git a/src/reducers/channels.js b/src/reducers/channels.js index 6704231c8..b744c7ee1 100644 --- a/src/reducers/channels.js +++ b/src/reducers/channels.js @@ -1,6 +1,8 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + import _ from 'lodash'; import {ChannelsTypes, LogoutTypes} from 'constants'; -const types = {...ChannelsTypes, ...LogoutTypes}; export const initState = { status: 'not fetched', @@ -17,28 +19,28 @@ function zipById(channels) { export default function reduceChannels(state = initState, action) { switch (action.type) { - case types.SELECT_CHANNEL: + case ChannelsTypes.SELECT_CHANNEL: return {...state, currentChannelId: action.channelId }; - case types.FETCH_CHANNELS_REQUEST: + case ChannelsTypes.FETCH_CHANNELS_REQUEST: return {...state, status: 'fetching', error: null }; - case types.FETCH_CHANNELS_SUCCESS: + case ChannelsTypes.FETCH_CHANNELS_SUCCESS: return {...state, status: 'fetched', data: zipById(action.data.channels) }; - case types.FETCH_CHANNELS_FAILURE: + case ChannelsTypes.FETCH_CHANNELS_FAILURE: return {...state, status: 'failed', error: action.error }; - case types.LOGOUT_SUCCESS: + case LogoutTypes.LOGOUT_SUCCESS: return initState; default: return state; diff --git a/src/reducers/device.js b/src/reducers/device.js index be14f701a..3e58b00e3 100644 --- a/src/reducers/device.js +++ b/src/reducers/device.js @@ -2,14 +2,15 @@ // See License.txt for license information. import {handle, initialState} from './helpers.js'; -import {DeviceTypes as types} from 'constants'; +import {DeviceTypes} from 'constants'; export const initState = initialState(); export default function device(state = initState, action) { return handle( - types.DEVICE_REQUEST, - types.DEVICE_SUCCESS, - types.DEVICE_FAILURE, - state, - action); + DeviceTypes.DEVICE_REQUEST, + DeviceTypes.DEVICE_SUCCESS, + DeviceTypes.DEVICE_FAILURE, + state, + action + ); } diff --git a/src/reducers/general.js b/src/reducers/general.js index 49418436c..2b7bba5b5 100644 --- a/src/reducers/general.js +++ b/src/reducers/general.js @@ -3,7 +3,7 @@ import {combineReducers} from 'redux'; import {initialState, handle} from './helpers.js'; -import {GeneralTypes as types} from 'constants'; +import {GeneralTypes} from 'constants'; export const initState = initialState(); @@ -11,20 +11,22 @@ export const initState = initialState(); // We can't do so until it's extracted into its own store with more reducers export function clientConfig(state = initState, action) { return handle( - types.CLIENT_CONFIG_REQUEST, - types.CLIENT_CONFIG_SUCCESS, - types.CLIENT_CONFIG_FAILURE, - state, - action); + GeneralTypes.CLIENT_CONFIG_REQUEST, + GeneralTypes.CLIENT_CONFIG_SUCCESS, + GeneralTypes.CLIENT_CONFIG_FAILURE, + state, + action + ); } export function ping(state = initialState(), action) { return handle( - types.PING_REQUEST, - types.PING_SUCCESS, - types.PING_FAILURE, - state, - action); + GeneralTypes.PING_REQUEST, + GeneralTypes.PING_SUCCESS, + GeneralTypes.PING_FAILURE, + state, + action + ); } export default combineReducers({ diff --git a/src/reducers/login.js b/src/reducers/login.js index 4b3ed9cf4..81be65b69 100644 --- a/src/reducers/login.js +++ b/src/reducers/login.js @@ -2,7 +2,6 @@ // See License.txt for license information. import {LoginTypes, LogoutTypes} from 'constants'; -const types = {...LoginTypes, ...LogoutTypes}; export const initState = { status: 'not fetched', @@ -12,22 +11,22 @@ export const initState = { export default function reduceLogin(state = initState, action) { switch (action.type) { - case types.LOGIN_REQUEST: + case LoginTypes.LOGIN_REQUEST: return {...state, status: 'fetching', error: null }; - case types.LOGIN_SUCCESS: + case LoginTypes.LOGIN_SUCCESS: return {...state, status: 'fetched' }; - case types.LOGIN_FAILURE: + case LoginTypes.LOGIN_FAILURE: return {...state, status: 'failed', error: action.error }; - case types.LOGOUT_SUCCESS: + case LogoutTypes.LOGOUT_SUCCESS: return initState; default: return state; diff --git a/src/reducers/logout.js b/src/reducers/logout.js index 24070d878..65d8181a8 100644 --- a/src/reducers/logout.js +++ b/src/reducers/logout.js @@ -1,7 +1,7 @@ // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. // See License.txt for license information. -import {LogoutTypes as types} from 'constants'; +import {LogoutTypes} from 'constants'; export const initState = { status: 'not fetched', @@ -10,16 +10,16 @@ export const initState = { export default function reduceLogout(state = initState, action) { switch (action.type) { - case types.LOGOUT_REQUEST: + case LogoutTypes.LOGOUT_REQUEST: return {...state, status: 'fetching', error: null }; - case types.LOGOUT_SUCCESS: + case LogoutTypes.LOGOUT_SUCCESS: return {...state, status: 'fetched' }; - case types.LOGOUT_FAILURE: + case LogoutTypes.LOGOUT_FAILURE: return {...state, status: 'failed', error: action.error diff --git a/src/reducers/posts.js b/src/reducers/posts.js index db66d06eb..815637ce4 100644 --- a/src/reducers/posts.js +++ b/src/reducers/posts.js @@ -2,7 +2,6 @@ // See License.txt for license information. import {PostsTypes, LogoutTypes} from 'constants'; -const types = {...PostsTypes, ...LogoutTypes}; export const initState = { status: 'not fetched', @@ -13,23 +12,23 @@ export const initState = { export default function reducePosts(state = initState, action) { switch (action.type) { - case types.FETCH_POSTS_REQUEST: + case PostsTypes.FETCH_POSTS_REQUEST: return {...state, status: 'fetching', error: null }; - case types.FETCH_POSTS_SUCCESS: + case PostsTypes.FETCH_POSTS_SUCCESS: return {...state, status: 'fetched', data: action.data.posts }; - case types.FETCH_POSTS_FAILURE: + case PostsTypes.FETCH_POSTS_FAILURE: return {...state, status: 'failed', error: action.error }; - case types.LOGOUT_SUCCESS: + case LogoutTypes.LOGOUT_SUCCESS: return initState; default: return state; diff --git a/src/reducers/teams.js b/src/reducers/teams.js index c0cd589cf..bdaff675a 100644 --- a/src/reducers/teams.js +++ b/src/reducers/teams.js @@ -2,7 +2,6 @@ // See License.txt for license information. import {TeamsTypes, LogoutTypes} from 'constants'; -const types = {...TeamsTypes, ...LogoutTypes}; export const initState = { status: 'not fetched', @@ -14,28 +13,28 @@ export const initState = { export default function reduceTeams(state = initState, action) { switch (action.type) { - case types.SELECT_TEAM: + case TeamsTypes.SELECT_TEAM: return {...state, currentTeamId: action.teamId }; - case types.FETCH_TEAMS_REQUEST: + case TeamsTypes.FETCH_TEAMS_REQUEST: return {...state, status: 'fetching', error: null }; - case types.FETCH_TEAMS_SUCCESS: + case TeamsTypes.FETCH_TEAMS_SUCCESS: return {...state, status: 'fetched', data: action.data }; - case types.FETCH_TEAMS_FAILURE: + case TeamsTypes.FETCH_TEAMS_FAILURE: return {...state, status: 'failed', error: action.error }; - case types.LOGOUT_SUCCESS: + case LogoutTypes.LOGOUT_SUCCESS: return initState; default: return state; diff --git a/test/reducers/channels.test.js b/test/reducers/channels.test.js index 85b83b1d6..7292c81fd 100644 --- a/test/reducers/channels.test.js +++ b/test/reducers/channels.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceChannels, {initState} from 'reducers/channels'; -import {ChannelsTypes as types} from 'constants'; +import {ChannelsTypes} from 'constants'; describe('channels reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('channels reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.SELECT_CHANNEL}`, () => { + describe(`when ${ChannelsTypes.SELECT_CHANNEL}`, () => { let store; let expectedStore; before(() => { store = reduceChannels(store, { - type: types.SELECT_CHANNEL, + type: ChannelsTypes.SELECT_CHANNEL, channelId: '1' }); expectedStore = { @@ -37,12 +37,12 @@ describe('channels reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_CHANNELS_REQUEST}`, () => { + describe(`when ${ChannelsTypes.FETCH_CHANNELS_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceChannels(store, { - type: types.FETCH_CHANNELS_REQUEST + type: ChannelsTypes.FETCH_CHANNELS_REQUEST }); expectedStore = { ...initState, @@ -53,12 +53,12 @@ describe('channels reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_CHANNELS_SUCCESS}`, () => { + describe(`when ${ChannelsTypes.FETCH_CHANNELS_SUCCESS}`, () => { let store; let expectedStore; before(() => { store = reduceChannels(store, { - type: types.FETCH_CHANNELS_SUCCESS, + type: ChannelsTypes.FETCH_CHANNELS_SUCCESS, data: {channels: [{id: '1', attr: 'attr'}]} }); expectedStore = { @@ -71,14 +71,14 @@ describe('channels reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_CHANNELS_FAILURE}`, () => { + describe(`when ${ChannelsTypes.FETCH_CHANNELS_FAILURE}`, () => { let store; let expectedStore; let error; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceChannels(store, { - type: types.FETCH_CHANNELS_FAILURE, + type: ChannelsTypes.FETCH_CHANNELS_FAILURE, error }); expectedStore = { diff --git a/test/reducers/device.test.js b/test/reducers/device.test.js index 1281891d4..45b41e594 100644 --- a/test/reducers/device.test.js +++ b/test/reducers/device.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceDevice, {initState} from 'reducers/device'; -import {DeviceTypes as types} from 'constants'; +import {DeviceTypes} from 'constants'; describe('device reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('device reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.DEVICE_REQUEST}`, () => { + describe(`when ${DeviceTypes.DEVICE_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceDevice(store, { - type: types.DEVICE_REQUEST + type: DeviceTypes.DEVICE_REQUEST }); expectedStore = { ...initState, @@ -36,13 +36,13 @@ describe('device reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.DEVICE_SUCCESS}`, () => { + describe(`when ${DeviceTypes.DEVICE_SUCCESS}`, () => { let store; let expectedStore; const data = {some: 'data'}; before(() => { store = reduceDevice(store, { - type: types.DEVICE_SUCCESS, + type: DeviceTypes.DEVICE_SUCCESS, data }); expectedStore = { @@ -55,14 +55,14 @@ describe('device reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.DEVICE_FAILURE}`, () => { + describe(`when ${DeviceTypes.DEVICE_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceDevice(store, { - type: types.DEVICE_FAILURE, + type: DeviceTypes.DEVICE_FAILURE, error }); expectedStore = { diff --git a/test/reducers/general.test.js b/test/reducers/general.test.js index 737de5cec..7b7d15e66 100644 --- a/test/reducers/general.test.js +++ b/test/reducers/general.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceGeneral, {initState} from 'reducers/general'; -import {GeneralTypes as types} from 'constants'; +import {GeneralTypes} from 'constants'; const combinedState = { clientConfig: {...initState}, @@ -26,12 +26,12 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.PING_REQUEST}`, () => { + describe(`when ${GeneralTypes.PING_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceGeneral(store, { - type: types.PING_REQUEST + type: GeneralTypes.PING_REQUEST }); expectedStore = { ...combinedState, @@ -45,13 +45,13 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.PING_SUCCESS}`, () => { + describe(`when ${GeneralTypes.PING_SUCCESS}`, () => { let store; let expectedStore; const data = {some: 'data'}; before(() => { store = reduceGeneral(store, { - type: types.PING_SUCCESS, + type: GeneralTypes.PING_SUCCESS, data }); expectedStore = { @@ -66,14 +66,14 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.PING_FAILURE}`, () => { + describe(`when ${GeneralTypes.PING_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceGeneral(store, { - type: types.PING_FAILURE, + type: GeneralTypes.PING_FAILURE, error }); expectedStore = { @@ -104,12 +104,12 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.CLIENT_CONFIG_REQUEST}`, () => { + describe(`when ${GeneralTypes.CLIENT_CONFIG_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceGeneral(store, { - type: types.CLIENT_CONFIG_REQUEST + type: GeneralTypes.CLIENT_CONFIG_REQUEST }); expectedStore = { ...combinedState, @@ -123,13 +123,13 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.CLIENT_CONFIG_SUCCESS}`, () => { + describe(`when ${GeneralTypes.CLIENT_CONFIG_SUCCESS}`, () => { let store; let expectedStore; const data = {some: 'data'}; before(() => { store = reduceGeneral(store, { - type: types.CLIENT_CONFIG_SUCCESS, + type: GeneralTypes.CLIENT_CONFIG_SUCCESS, data }); expectedStore = { @@ -144,14 +144,14 @@ describe('general reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.CLIENT_CONFIG_FAILURE}`, () => { + describe(`when ${GeneralTypes.CLIENT_CONFIG_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceGeneral(store, { - type: types.CLIENT_CONFIG_FAILURE, + type: GeneralTypes.CLIENT_CONFIG_FAILURE, error }); expectedStore = { diff --git a/test/reducers/login.test.js b/test/reducers/login.test.js index 42284a76c..1094bb443 100644 --- a/test/reducers/login.test.js +++ b/test/reducers/login.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceLogin, {initState} from 'reducers/login'; -import {LoginTypes as types} from 'constants'; +import {LoginTypes} from 'constants'; describe('login reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('login reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGIN_REQUEST}`, () => { + describe(`when ${LoginTypes.LOGIN_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceLogin(store, { - type: types.LOGIN_REQUEST + type: LoginTypes.LOGIN_REQUEST }); expectedStore = { ...initState, @@ -36,12 +36,12 @@ describe('login reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGIN_SUCCESS}`, () => { + describe(`when ${LoginTypes.LOGIN_SUCCESS}`, () => { let store; let expectedStore; before(() => { store = reduceLogin(store, { - type: types.LOGIN_SUCCESS + type: LoginTypes.LOGIN_SUCCESS }); expectedStore = { ...initState, @@ -52,14 +52,14 @@ describe('login reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGIN_FAILURE}`, () => { + describe(`when ${LoginTypes.LOGIN_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceLogin(store, { - type: types.LOGIN_FAILURE, + type: LoginTypes.LOGIN_FAILURE, error }); expectedStore = { diff --git a/test/reducers/logout.test.js b/test/reducers/logout.test.js index 47810b67b..6bedeb180 100644 --- a/test/reducers/logout.test.js +++ b/test/reducers/logout.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceLogout, {initState} from 'reducers/logout'; -import {LogoutTypes as types} from 'constants'; +import {LogoutTypes} from 'constants'; describe('logout reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('logout reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGOUT_REQUEST}`, () => { + describe(`when ${LogoutTypes.LOGOUT_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceLogout(store, { - type: types.LOGOUT_REQUEST + type: LogoutTypes.LOGOUT_REQUEST }); expectedStore = { ...initState, @@ -36,12 +36,12 @@ describe('logout reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGOUT_SUCCESS}`, () => { + describe(`when ${LogoutTypes.LOGOUT_SUCCESS}`, () => { let store; let expectedStore; before(() => { store = reduceLogout(store, { - type: types.LOGOUT_SUCCESS + type: LogoutTypes.LOGOUT_SUCCESS }); expectedStore = { ...initState, @@ -52,14 +52,14 @@ describe('logout reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.LOGOUT_FAILURE}`, () => { + describe(`when ${LogoutTypes.LOGOUT_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceLogout(store, { - type: types.LOGOUT_FAILURE, + type: LogoutTypes.LOGOUT_FAILURE, error }); expectedStore = { diff --git a/test/reducers/posts.test.js b/test/reducers/posts.test.js index c582c83e8..2d8d32e60 100644 --- a/test/reducers/posts.test.js +++ b/test/reducers/posts.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reducePosts, {initState} from 'reducers/posts'; -import {PostsTypes as types} from 'constants'; +import {PostsTypes} from 'constants'; describe('posts reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('posts reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_POSTS_REQUEST}`, () => { + describe(`when ${PostsTypes.FETCH_POSTS_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reducePosts(store, { - type: types.FETCH_POSTS_REQUEST + type: PostsTypes.FETCH_POSTS_REQUEST }); expectedStore = { ...initState, @@ -36,13 +36,13 @@ describe('posts reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_POSTS_SUCCESS}`, () => { + describe(`when ${PostsTypes.FETCH_POSTS_SUCCESS}`, () => { let store; let expectedStore; const data = {id: '1', attrs: 'attrs'}; before(() => { store = reducePosts(store, { - type: types.FETCH_POSTS_SUCCESS, + type: PostsTypes.FETCH_POSTS_SUCCESS, data: { posts: data } @@ -57,14 +57,14 @@ describe('posts reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_POSTS_FAILURE}`, () => { + describe(`when ${PostsTypes.FETCH_POSTS_FAILURE}`, () => { let store; let error; let expectedStore; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reducePosts(store, { - type: types.FETCH_POSTS_FAILURE, + type: PostsTypes.FETCH_POSTS_FAILURE, error }); expectedStore = { diff --git a/test/reducers/teams.test.js b/test/reducers/teams.test.js index f6a93917a..b874deff4 100644 --- a/test/reducers/teams.test.js +++ b/test/reducers/teams.test.js @@ -3,7 +3,7 @@ import assert from 'assert'; import reduceTeams, {initState} from 'reducers/teams'; -import {TeamsTypes as types} from 'constants'; +import {TeamsTypes} from 'constants'; describe('teams reducer', () => { describe('Init', () => { @@ -20,12 +20,12 @@ describe('teams reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.SELECT_TEAM}`, () => { + describe(`when ${TeamsTypes.SELECT_TEAM}`, () => { let store; let expectedStore; before(() => { store = reduceTeams(store, { - type: types.SELECT_TEAM, + type: TeamsTypes.SELECT_TEAM, teamId: '1' }); expectedStore = { @@ -37,12 +37,12 @@ describe('teams reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_TEAMS_REQUEST}`, () => { + describe(`when ${TeamsTypes.FETCH_TEAMS_REQUEST}`, () => { let store; let expectedStore; before(() => { store = reduceTeams(store, { - type: types.FETCH_TEAMS_REQUEST + type: TeamsTypes.FETCH_TEAMS_REQUEST }); expectedStore = { ...initState, @@ -53,13 +53,13 @@ describe('teams reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_TEAMS_SUCCESS}`, () => { + describe(`when ${TeamsTypes.FETCH_TEAMS_SUCCESS}`, () => { let store; const data = {some: 'thing'}; let expectedStore; before(() => { store = reduceTeams(store, { - type: types.FETCH_TEAMS_SUCCESS, + type: TeamsTypes.FETCH_TEAMS_SUCCESS, data }); expectedStore = { @@ -72,14 +72,14 @@ describe('teams reducer', () => { assert.deepEqual(store, expectedStore); }); }); - describe(`when ${types.FETCH_TEAMS_FAILURE}`, () => { + describe(`when ${TeamsTypes.FETCH_TEAMS_FAILURE}`, () => { let store; let expectedStore; let error; before(() => { error = {id: 'the.error.id', message: 'Something went wrong'}; store = reduceTeams(store, { - type: types.FETCH_TEAMS_FAILURE, + type: TeamsTypes.FETCH_TEAMS_FAILURE, error }); expectedStore = {