-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
cc3883c
commit ef0480a
Showing
17 changed files
with
196 additions
and
167 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 was deleted.
Oops, something went wrong.
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,62 +1,76 @@ | ||
import passwordReducer from '../../reducers/user/passwordReducer'; | ||
import initialState from '../../store/initialState'; | ||
import { passwordAction } from '../../actions-types'; | ||
import { | ||
sendEmail, | ||
fakeEmail, | ||
matchedResetPassword, | ||
mismatchedResetPassword | ||
} from '../../__mocks__/user'; | ||
import { userActionsTypes } from '../../actions-types'; | ||
import { matchedResetPassword, mismatchedResetPassword } from '../../__mocks__/user'; | ||
|
||
describe('User reducer', () => { | ||
test('INITIALIZE_EMAIL', () => { | ||
describe('Password reducer', () => { | ||
test('FORGOT_PASSWORD_START', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.FORGOT_PASSWORD_INITIALIZED, | ||
payload: { ...sendEmail } | ||
type: userActionsTypes.FORGOT_PASSWORD_START, | ||
payload: { loading: true } | ||
}); | ||
expect(reducer).toHaveProperty('email'); | ||
expect(reducer.forgotPassword).toHaveProperty('loading'); | ||
expect(reducer.forgotPassword.loading).toBeTruthy(); | ||
}); | ||
|
||
test('EMAIL_SENT_SUCCESSFULLY', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.FORGOT_PASSWORD_SUCCESS, | ||
payload: { ...sendEmail } | ||
type: userActionsTypes.FORGOT_PASSWORD_SUCCESS, | ||
payload: { message: { sendEmail: 'luctunechi45@gmail.com' } } | ||
}); | ||
expect(reducer).toHaveProperty('email'); | ||
expect(reducer.forgotPassword.message).toHaveProperty('sendEmail'); | ||
}); | ||
|
||
test('ERROR', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.FORGOT_PASSWORD_ERROR, | ||
payload: { ...fakeEmail } | ||
type: userActionsTypes.FORGOT_PASSWORD_FAILURE, | ||
payload: { errors: { sendEmail: 'qweqwewqew@gmail' } } | ||
}); | ||
expect(reducer).toHaveProperty('email'); | ||
expect(reducer.forgotPassword.errors).toHaveProperty('sendEmail'); | ||
}); | ||
|
||
test('INITIALIZE_PASSWORD', () => { | ||
test('FORGOT_PASSWORD_END', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.RESET_PASSWORD_INITIALIZED, | ||
payload: { ...matchedResetPassword } | ||
type: userActionsTypes.FORGOT_PASSWORD_END, | ||
payload: { loading: false } | ||
}); | ||
expect(reducer).toHaveProperty('password'); | ||
expect(reducer).toHaveProperty('confirmPassword'); | ||
|
||
expect(reducer.forgotPassword).toHaveProperty('loading'); | ||
expect(reducer.forgotPassword.loading).toBeFalsy(); | ||
}); | ||
|
||
test('UPDATE_PASSWORD_START', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: userActionsTypes.RESET_PASSWORD_START, | ||
payload: { loading: true } | ||
}); | ||
expect(reducer.updatePassword).toHaveProperty('loading'); | ||
expect(reducer.updatePassword.loading).toBeTruthy(); | ||
}); | ||
|
||
test('UPDATE_SUCCESSFULLY_PASSWORD', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.RESET_PASSWORD_SUCCESS, | ||
payload: { ...matchedResetPassword } | ||
type: userActionsTypes.RESET_PASSWORD_SUCCESS, | ||
payload: { message: { matchedResetPassword } } | ||
}); | ||
expect(reducer).toHaveProperty('password'); | ||
expect(reducer).toHaveProperty('confirmPassword'); | ||
expect(reducer.updatePassword).toHaveProperty('message'); | ||
}); | ||
|
||
test('ERROR', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: passwordAction.RESET_PASSWORD_ERROR, | ||
payload: { ...mismatchedResetPassword } | ||
type: userActionsTypes.RESET_PASSWORD_FAILURE, | ||
payload: { errors: { mismatchedResetPassword } } | ||
}); | ||
expect(reducer).toHaveProperty('password'); | ||
expect(reducer).toHaveProperty('confirmPassword'); | ||
expect(reducer.updatePassword).toHaveProperty('errors'); | ||
}); | ||
|
||
test('UPDATE_PASSWORD_END', () => { | ||
const reducer = passwordReducer(initialState, { | ||
type: userActionsTypes.RESET_PASSWORD_END, | ||
payload: { loading: false } | ||
}); | ||
|
||
expect(reducer.updatePassword).toHaveProperty('loading'); | ||
expect(reducer.updatePassword.loading).toBeFalsy(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
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,6 +1,5 @@ | ||
import * as userActionsTypes from './userActionsTypes'; | ||
import * as apiActionsTypes from './apiActionsTypes'; | ||
import * as notificationActionTypes from './notificationActionTypes'; | ||
import * as passwordAction from './PasswordActionsType'; | ||
|
||
export { apiActionsTypes, userActionsTypes, notificationActionTypes, passwordAction }; | ||
export { apiActionsTypes, userActionsTypes, notificationActionTypes }; |
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,12 @@ | ||
import { userActionsTypes } from '../../actions-types'; | ||
import { apiAction } from '../../helpers'; | ||
|
||
export default email => dispatch => dispatch(apiAction({ | ||
method: 'post', | ||
url: '/auth/reset', | ||
data: { email }, | ||
onStart: userActionsTypes.FORGOT_PASSWORD_START, | ||
onEnd: userActionsTypes.FORGOT_PASSWORD_END, | ||
onSuccess: userActionsTypes.FORGOT_PASSWORD_SUCCESS, | ||
onFailure: userActionsTypes.FORGOT_PASSWORD_FAILURE | ||
})); |
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
import { userActionsTypes } from '../../actions-types'; | ||
import { apiAction } from '../../helpers'; | ||
|
||
export default (form, token) => dispatch => dispatch(apiAction({ | ||
method: 'patch', | ||
url: `auth/reset/${token}`, | ||
data: { ...form }, | ||
onStart: userActionsTypes.RESET_PASSWORD_STARTS, | ||
onEnd: userActionsTypes.RESET_PASSWORD_END, | ||
onSuccess: userActionsTypes.RESET_PASSWORD_SUCCESS, | ||
onFailure: userActionsTypes.RESET_PASSWORD_FAILURE | ||
})); |
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
Oops, something went wrong.