Skip to content

Commit 1f17876

Browse files
fix(merge): resolve merge conflicts
2 parents 0e347c0 + 632360f commit 1f17876

File tree

11 files changed

+102
-14
lines changed

11 files changed

+102
-14
lines changed

src/actions/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function* userLogIn({ username, password }) {
4646
*/
4747
export function* userLogOut() {
4848
yield put({
49-
type: USER_LOG_OUT
49+
type: `${USER_LOG_OUT}_SUCCESS`
5050
});
5151
}
5252

@@ -57,7 +57,7 @@ export function* userLogOut() {
5757
*/
5858
export function* userSetRole(role) {
5959
yield put({
60-
type: USER_SET_ROLE,
60+
type: `${USER_SET_ROLE}_SUCCESS`,
6161
payload: {
6262
role
6363
}

src/actions/user.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ describe('actions->user', () => {
5959
testSaga(userLogOut)
6060
.next()
6161
.put({
62-
type: USER_LOG_OUT
62+
type: `${USER_LOG_OUT}_SUCCESS`
6363
})
6464
.next()
6565
.isDone();
@@ -69,7 +69,7 @@ describe('actions->user', () => {
6969
testSaga(userSetRole, USER_ROLE_EDITOR)
7070
.next()
7171
.put({
72-
type: USER_SET_ROLE,
72+
type: `${USER_SET_ROLE}_SUCCESS`,
7373
payload: {
7474
role: USER_ROLE_EDITOR
7575
}

src/components/App/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import React, { Fragment } from 'react';
77
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
88
import { CssBaseline } from '@material-ui/core';
99

10-
import { Home, Login, Dashboard, ExperienceCreate } from '../../pages';
10+
import { Home, Login, Logout, Dashboard, ExperienceCreate } from '../../pages';
1111
import { PrivateRoute, PublicRoute } from '../../hoc';
1212

1313
const App = () => (
@@ -22,6 +22,7 @@ const App = () => (
2222
redirectTo="/dashboard"
2323
component={Login}
2424
/>
25+
<PrivateRoute exact path="/logout" redirectTo="/" component={Logout} />
2526
<PrivateRoute
2627
exact
2728
path="/dashboard"

src/pages/Logout/Logout.container.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @file Logout.container.js
3+
* Exports a redux-connected Logout component.
4+
*/
5+
6+
import { connect } from 'react-redux';
7+
import Logout from './Logout';
8+
9+
const mapDispatchToProps = dispatch => ({
10+
dispatch
11+
});
12+
13+
const mapState = ({ user }) => ({ user });
14+
15+
export default connect(mapState, mapDispatchToProps)(Logout);

src/pages/Logout/Logout.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* @file Logout.js
3+
* Exports a React component that handles requests to /logout.
4+
*/
5+
6+
import { Component } from 'react';
7+
import PropTypes from 'prop-types';
8+
9+
import { USER_LOG_OUT } from '../../constants';
10+
11+
class Logout extends Component {
12+
static propTypes = {
13+
dispatch: PropTypes.func.isRequired
14+
};
15+
16+
/**
17+
* {@inheritdoc}
18+
*/
19+
componentWillMount() {
20+
this.props.dispatch({ type: USER_LOG_OUT });
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
render() {
27+
return null;
28+
}
29+
}
30+
31+
export default Logout;

src/pages/Logout/Logout.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @file Logout.test.js
3+
* Contains tests for Logout.js.
4+
*/
5+
6+
import React from 'react';
7+
import renderer from 'react-test-renderer';
8+
import configureStore from 'redux-mock-store';
9+
import { Provider } from 'react-redux';
10+
import { MemoryRouter as Router } from 'react-router-dom';
11+
12+
import Logout from './Logout.container';
13+
14+
describe('<Logout />', () => {
15+
it('Matches its snapshot', () => {
16+
const store = configureStore()({
17+
user: {
18+
uid: '1',
19+
authentication: {
20+
accessToken: 'test',
21+
csrfToken: 'test'
22+
}
23+
}
24+
});
25+
expect(
26+
renderer
27+
.create(
28+
<Provider store={store}>
29+
<Router>
30+
<Logout />
31+
</Router>
32+
</Provider>
33+
)
34+
.toJSON()
35+
).toMatchSnapshot();
36+
});
37+
});
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`<Logout /> Matches its snapshot 1`] = `null`;

src/pages/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
import Home from './Home/Home';
77
import Login from './Login/Login';
8+
import Logout from './Logout/Logout.container';
89
import Dashboard from './Dashboard/Dashboard.container';
910
import ExperienceCreate from './ExperienceCreate/ExperienceCreate';
1011

11-
export { Home, Login, Dashboard, ExperienceCreate };
12+
export { Home, Login, Logout, Dashboard, ExperienceCreate };

src/reducers/__snapshots__/user.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Object {
5151
}
5252
`;
5353

54-
exports[`reducers->user Should handle USER_LOG_OUT 1`] = `
54+
exports[`reducers->user Should handle USER_LOG_OUT_SUCCESS 1`] = `
5555
Object {
5656
"authentication": Object {
5757
"accessToken": null,
@@ -68,7 +68,7 @@ Object {
6868
}
6969
`;
7070

71-
exports[`reducers->user Should handle USER_SET_ROLE 1`] = `
71+
exports[`reducers->user Should handle USER_SET_ROLE_SUCCESS 1`] = `
7272
Object {
7373
"authentication": Object {
7474
"accessToken": null,

src/reducers/user.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,14 @@ export default function user(state = defaultState, action) {
9191
/**
9292
* Reducer that handles user logout actions.
9393
*/
94-
case USER_LOG_OUT: {
94+
case `${USER_LOG_OUT}_SUCCESS`: {
9595
return defaultState;
9696
}
9797

9898
/**
9999
* Reducer that handles setting a user's role.
100100
*/
101-
case USER_SET_ROLE: {
101+
case `${USER_SET_ROLE}_SUCCESS`: {
102102
const { role } = action.payload;
103103
return { ...state, authentication: { ...state.authentication, role } };
104104
}

0 commit comments

Comments
 (0)