Skip to content

Commit

Permalink
fix(merge): resolve merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickocoffeyo committed Jun 6, 2018
2 parents 0e347c0 + 632360f commit 1f17876
Show file tree
Hide file tree
Showing 11 changed files with 102 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/actions/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function* userLogIn({ username, password }) {
*/
export function* userLogOut() {
yield put({
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
});
}

Expand All @@ -57,7 +57,7 @@ export function* userLogOut() {
*/
export function* userSetRole(role) {
yield put({
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role
}
Expand Down
4 changes: 2 additions & 2 deletions src/actions/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('actions->user', () => {
testSaga(userLogOut)
.next()
.put({
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
})
.next()
.isDone();
Expand All @@ -69,7 +69,7 @@ describe('actions->user', () => {
testSaga(userSetRole, USER_ROLE_EDITOR)
.next()
.put({
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role: USER_ROLE_EDITOR
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/App/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import React, { Fragment } from 'react';
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
import { CssBaseline } from '@material-ui/core';

import { Home, Login, Dashboard, ExperienceCreate } from '../../pages';
import { Home, Login, Logout, Dashboard, ExperienceCreate } from '../../pages';
import { PrivateRoute, PublicRoute } from '../../hoc';

const App = () => (
Expand All @@ -22,6 +22,7 @@ const App = () => (
redirectTo="/dashboard"
component={Login}
/>
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
<PrivateRoute
exact
path="/dashboard"
Expand Down
15 changes: 15 additions & 0 deletions src/pages/Logout/Logout.container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @file Logout.container.js
* Exports a redux-connected Logout component.
*/

import { connect } from 'react-redux';
import Logout from './Logout';

const mapDispatchToProps = dispatch => ({
dispatch
});

const mapState = ({ user }) => ({ user });

export default connect(mapState, mapDispatchToProps)(Logout);
31 changes: 31 additions & 0 deletions src/pages/Logout/Logout.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @file Logout.js
* Exports a React component that handles requests to /logout.
*/

import { Component } from 'react';
import PropTypes from 'prop-types';

import { USER_LOG_OUT } from '../../constants';

class Logout extends Component {
static propTypes = {
dispatch: PropTypes.func.isRequired
};

/**
* {@inheritdoc}
*/
componentWillMount() {
this.props.dispatch({ type: USER_LOG_OUT });
}

/**
* {@inheritdoc}
*/
render() {
return null;
}
}

export default Logout;
37 changes: 37 additions & 0 deletions src/pages/Logout/Logout.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file Logout.test.js
* Contains tests for Logout.js.
*/

import React from 'react';
import renderer from 'react-test-renderer';
import configureStore from 'redux-mock-store';
import { Provider } from 'react-redux';
import { MemoryRouter as Router } from 'react-router-dom';

import Logout from './Logout.container';

describe('<Logout />', () => {
it('Matches its snapshot', () => {
const store = configureStore()({
user: {
uid: '1',
authentication: {
accessToken: 'test',
csrfToken: 'test'
}
}
});
expect(
renderer
.create(
<Provider store={store}>
<Router>
<Logout />
</Router>
</Provider>
)
.toJSON()
).toMatchSnapshot();
});
});
3 changes: 3 additions & 0 deletions src/pages/Logout/__snapshots__/Logout.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Logout /> Matches its snapshot 1`] = `null`;
3 changes: 2 additions & 1 deletion src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import Home from './Home/Home';
import Login from './Login/Login';
import Logout from './Logout/Logout.container';
import Dashboard from './Dashboard/Dashboard.container';
import ExperienceCreate from './ExperienceCreate/ExperienceCreate';

export { Home, Login, Dashboard, ExperienceCreate };
export { Home, Login, Logout, Dashboard, ExperienceCreate };
4 changes: 2 additions & 2 deletions src/reducers/__snapshots__/user.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Object {
}
`;

exports[`reducers->user Should handle USER_LOG_OUT 1`] = `
exports[`reducers->user Should handle USER_LOG_OUT_SUCCESS 1`] = `
Object {
"authentication": Object {
"accessToken": null,
Expand All @@ -68,7 +68,7 @@ Object {
}
`;

exports[`reducers->user Should handle USER_SET_ROLE 1`] = `
exports[`reducers->user Should handle USER_SET_ROLE_SUCCESS 1`] = `
Object {
"authentication": Object {
"accessToken": null,
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export default function user(state = defaultState, action) {
/**
* Reducer that handles user logout actions.
*/
case USER_LOG_OUT: {
case `${USER_LOG_OUT}_SUCCESS`: {
return defaultState;
}

/**
* Reducer that handles setting a user's role.
*/
case USER_SET_ROLE: {
case `${USER_SET_ROLE}_SUCCESS`: {
const { role } = action.payload;
return { ...state, authentication: { ...state.authentication, role } };
}
Expand Down
8 changes: 4 additions & 4 deletions src/reducers/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,18 @@ describe('reducers->user', () => {
).toMatchSnapshot();
});

it(`Should handle ${USER_LOG_OUT}`, () => {
it(`Should handle ${USER_LOG_OUT}_SUCCESS`, () => {
expect(
reducer(undefined, {
type: USER_LOG_OUT
type: `${USER_LOG_OUT}_SUCCESS`
})
).toMatchSnapshot();
});

it(`Should handle ${USER_SET_ROLE}`, () => {
it(`Should handle ${USER_SET_ROLE}_SUCCESS`, () => {
expect(
reducer(undefined, {
type: USER_SET_ROLE,
type: `${USER_SET_ROLE}_SUCCESS`,
payload: {
role: USER_ROLE_EDITOR
}
Expand Down

0 comments on commit 1f17876

Please sign in to comment.