Skip to content

Commit

Permalink
chore(commonWrapper): refactor tests to add society
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Maina committed Feb 20, 2019
1 parent 580e12e commit 0c820ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';

import { Authenticate } from '../AuthenticateRoute';
import LoginComponent from '../../../Login/components';

describe('<AuthenticateRoute />', () => {
const setUpWrapper = ({
Expand All @@ -20,9 +21,9 @@ describe('<AuthenticateRoute />', () => {
expect(wrapper.find('Route').exists()).toBe(true);
});

it('renders error message when component is not authenticated', () => {
it('renders Login component when component is not authenticated', () => {
const wrapper = setUpWrapper({ isAuthenticated: false});
wrapper.props().render({ isAuthenticated: false });
expect(wrapper.props().render({ isAuthenticated: false })).toEqual(<div><h1> PLEASE LOGIN. NOT AUTHORIZED </h1></div>);
expect(wrapper.props().render({ isAuthenticated: false })).toEqual(<LoginComponent />);
});
});
4 changes: 3 additions & 1 deletion src/app/Dashboard/operations/dashboard.data.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { get } from '../../utils/api';
export function* fetchUserActivities(action) {
try {
const result = yield call(get, `users/${action.userId}/logged-activities`);
yield put(actions.fetchUserActivitiesSuccess(result.data, result.pointsEarned, result.activitiesLogged, result.society));
yield put(
actions.fetchUserActivitiesSuccess(result.data, result.pointsEarned, result.activitiesLogged, result.society),
);
} catch (error) {
yield put(actions.fetchUserActivitiesError(error));
}
Expand Down
1 change: 1 addition & 0 deletions src/app/Dashboard/operations/tests/fixtures.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const myloggedActivities = {
activitiesLogged: 4,
data: activities,
pointsEarned: 300,
society: 'Phoenix',
}

export default activities;
6 changes: 5 additions & 1 deletion src/app/Dashboard/operations/tests/reducer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('Dashboard reducer', () => {
}),
).toEqual({
error: null,
society: '',
loading: true,
pointsEarned: 0,
userActivities: [],
Expand All @@ -39,6 +40,7 @@ describe('Dashboard reducer', () => {
}),
).toEqual({
error,
society: '',
loading: false,
pointsEarned: 0,
userActivities: [],
Expand All @@ -49,13 +51,15 @@ describe('Dashboard reducer', () => {

describe('handles case FETCH_USER_ACTIVITIES_SUCCESS', () => {
it('returns poinstEarned, activitiesLogged and userActivities', () => {
const { data, pointsEarned, activitiesLogged } = myloggedActivities;
const { data, society, pointsEarned, activitiesLogged } = myloggedActivities;
expect(dashboard(defaultState, {
type: types.FETCH_USER_ACTIVITIES_SUCCESS,
society,
activities: data,
pointsEarned,
activitiesLogged,
})).toEqual({
society,
error: null,
pointsEarned,
loading: false,
Expand Down

0 comments on commit 0c820ab

Please sign in to comment.