-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
102 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters