-
Notifications
You must be signed in to change notification settings - Fork 3
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
8 changed files
with
40 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { Redirect } from 'react-router-dom'; | ||
import store from '../store/store'; | ||
import { PASSWORD_RESET } from '../store/actions/actionTypes'; | ||
import { PASSWORD_RESET, SET_TOKEN } from '../store/actions/actionTypes'; | ||
|
||
export class ConnectedResetPassword extends React.Component { | ||
class ResetPassword extends React.Component { | ||
componentDidMount() { | ||
store.dispatch({ type: PASSWORD_RESET }); | ||
const { match: { params } } = this.props; | ||
const { resetToken } = params; | ||
store.dispatch({ type: SET_TOKEN, payload: { token: resetToken } }); | ||
} | ||
|
||
render() { | ||
const { redirect } = this.props; | ||
return (<>{redirect && <Redirect to="/" />}</>); | ||
return (<Redirect to="/" />); | ||
} | ||
} | ||
|
||
ConnectedResetPassword.propTypes = { | ||
redirect: PropTypes.bool.isRequired, | ||
ResetPassword.propTypes = { | ||
match: PropTypes.shape({}).isRequired, | ||
}; | ||
|
||
export const mapStateToProps = state => state.resetPasswordState; | ||
|
||
const ResetPassword = connect(mapStateToProps)(ConnectedResetPassword); | ||
export default ResetPassword; |
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 |
---|---|---|
@@ -1,26 +1,13 @@ | ||
import { ConnectedResetPassword } from '../../components/ResetPassword'; | ||
import { shallow, mount } from 'enzyme'; | ||
import ResetPassword from '../../components/ResetPassword'; | ||
import { shallow } from 'enzyme'; | ||
import React from 'react'; | ||
import { mapStateToProps } from '../../components/ResetPassword'; | ||
|
||
describe('ResetPassword', () => { | ||
it('renders one Password reset component', () => { | ||
const props = {redirect: true} | ||
const wrapper = shallow(<ConnectedResetPassword {...props}/>); | ||
expect(wrapper).toHaveLength(1); | ||
}); | ||
it('redirects when redirect is true', () => { | ||
const props = {redirect: true} | ||
const wrapper = shallow(<ConnectedResetPassword {...props}/>); | ||
const props = { | ||
match: { params: { resetToken: 'fedageds' } } | ||
} | ||
const wrapper = shallow(<ResetPassword {...props} />); | ||
expect(wrapper).toHaveLength(1); | ||
}); | ||
}) | ||
|
||
describe('MapToProps', () => { | ||
it('should return new state', () => { | ||
const newState = mapStateToProps({ resetPasswordState: { redirect: true } }); | ||
const expected = { redirect: true }; | ||
expect(newState).toEqual(expected) | ||
}) | ||
}); | ||
|
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