-
Notifications
You must be signed in to change notification settings - Fork 9
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
225 additions
and
49 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
File renamed without changes.
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,73 @@ | ||
import expect from 'expect'; | ||
import passwordConfirmReducer from '../src/redux/reducers/passwordConfirmReducer'; | ||
import { PASSWORD_CONFIRM } from '../src/redux/constants'; | ||
|
||
/* | ||
* Defines the password confirm reducer tests: | ||
*/ | ||
|
||
const mockData = { | ||
passwordConfirmData: { | ||
password: '12345678', | ||
}, | ||
response: { | ||
data: { | ||
user: { | ||
message: 'Your account password has been changed successfully.', | ||
}, | ||
}, | ||
status: 200, | ||
}, | ||
error: { | ||
error: 'Password must be alphanumeric with a minimum of 8 characters.', | ||
}, | ||
}; | ||
describe.only('test password confirm reducer', () => { | ||
it('should handle search get request start', () => { | ||
const startAction = { | ||
type: PASSWORD_CONFIRM, | ||
}; | ||
const state = passwordConfirmReducer({}, startAction); | ||
expect(state).toEqual({ | ||
isLoading: true, | ||
}); | ||
}); | ||
|
||
it('should handle password confirm post request success', () => { | ||
const successAction = { | ||
type: `${PASSWORD_CONFIRM}_SUCCESS`, | ||
response: mockData.response.data.user.message, | ||
}; | ||
const state = passwordConfirmReducer({}, successAction); | ||
expect(state).toEqual({ | ||
isLoading: false, | ||
message: mockData.response.data.user.message, | ||
}); | ||
}); | ||
|
||
it('should handle password confirm post request failure', () => { | ||
const state = passwordConfirmReducer( | ||
{}, | ||
{ | ||
type: `${PASSWORD_CONFIRM}_FAILURE`, | ||
error: { | ||
response: { | ||
data: { | ||
message: | ||
'A password should be only Aplhanumeric characters and a minimum of 8 characters', | ||
}, | ||
}, | ||
}, | ||
}, | ||
); | ||
expect(state).toEqual({ | ||
error: { | ||
data: { | ||
message: | ||
'A password should be only Aplhanumeric characters and a minimum of 8 characters', | ||
}, | ||
}, | ||
isLoading: false, | ||
}); | ||
}); | ||
}); |
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,41 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { PasswordConfirmView } from '../src/views/PasswordConfirmView'; | ||
import { PasswordConfirmForm } from '../src/components/auth/PasswordConfirmForm'; | ||
|
||
/* | ||
* Defines the password confirm view tests. | ||
*/ | ||
describe('test renders reset password forms', () => { | ||
const props = { | ||
onSubmit: jest.fn(), | ||
onChange: jest.fn(), | ||
handleSubmit: jest.fn(), | ||
passwordConfirm: jest.fn(), | ||
handleConfirmPassword: jest.fn(), | ||
}; | ||
const wrapper = shallow(<PasswordConfirmView {...props} />); | ||
const input = { target: { name: 'password', value: 'testpassword' } }; | ||
const event = { | ||
preventDefault: jest.fn(), | ||
target: { | ||
name: 'password', | ||
value: '12345678', | ||
}, | ||
}; | ||
|
||
it('should change state value of password', () => { | ||
wrapper.find('PasswordConfirmForm').prop('onChange')(input); | ||
expect(wrapper.state('password')).toBe('testpassword'); | ||
}); | ||
|
||
it('should call onSubmit', () => { | ||
wrapper.instance().onSubmit(event); | ||
expect(props.passwordConfirm).toHaveBeenCalled(); | ||
}); | ||
|
||
it('renders reset password form', () => { | ||
const newWrapper = shallow(<PasswordConfirmForm {...props} />); | ||
expect(newWrapper.exists()).toEqual(true); | ||
}); | ||
}); |
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,66 @@ | ||
import expect from 'expect'; | ||
import resetPasswordReducer from '../src/redux/reducers/resetPasswordReducer'; | ||
import { RESET_PASSWORD } from '../src/redux/constants'; | ||
|
||
/* | ||
* Defines the reset password reducer tests: | ||
* Tests for successful change of state | ||
*/ | ||
|
||
const mockData = { | ||
resetPasswordData: { | ||
email: 'testwere@gmail.com', | ||
}, | ||
response: { | ||
data: { | ||
message: | ||
'Password reset link has been sent to your email, check your email for instructions on how to change password', | ||
uid: 9, | ||
token: '56v-1dfedbe5e7b11ecc2c47', | ||
}, | ||
status: 200, | ||
}, | ||
}; | ||
describe.only('test reset password reducer', () => { | ||
it('should handle search get request start', () => { | ||
const startAction = { | ||
type: RESET_PASSWORD, | ||
}; | ||
const state = resetPasswordReducer({}, startAction); | ||
expect(state).toEqual({ | ||
isLoading: true, | ||
}); | ||
}); | ||
it('should handle reset password post request success', () => { | ||
const successAction = { | ||
type: `${RESET_PASSWORD}_SUCCESS`, | ||
response: mockData.response.data.message, | ||
}; | ||
const state = resetPasswordReducer({}, successAction); | ||
expect(state).toEqual({ | ||
isLoading: false, | ||
message: mockData.response.data.message, | ||
}); | ||
}); | ||
|
||
it('should handle reset password post request failure', () => { | ||
const state = resetPasswordReducer( | ||
{ | ||
reset_password: { | ||
isLoading: true, | ||
message: '', | ||
error: {}, | ||
}, | ||
}, | ||
{ | ||
type: 'RESET_PASSWORD_FAILURE', | ||
error: { response: { data: { message: 'Account with this email not found.' } } }, | ||
}, | ||
); | ||
expect(state).toEqual({ | ||
reset_password: { isLoading: true, message: '', error: {} }, | ||
error: { data: { message: 'Account with this email not found.' } }, | ||
isLoading: false, | ||
}); | ||
}); | ||
}); |
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,35 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { ResetPasswordView } from '../src/views/ResetPasswordView'; | ||
import { ResetPasswordForm } from '../src/components/auth/ResetPasswordForm'; | ||
|
||
/* | ||
* Defines the reset password view tests: | ||
*/ | ||
describe('test renders reset password forms', () => { | ||
const props = { | ||
onSubmit: jest.fn(), | ||
onChange: jest.fn(), | ||
resetPassword: jest.fn(), | ||
}; | ||
const wrapper = shallow(<ResetPasswordView {...props} />); | ||
const input = { target: { name: 'email', value: 'test@gmail.com' } }; | ||
|
||
it('should change state value of email', () => { | ||
wrapper.find('ResetPasswordForm').prop('onChange')(input); | ||
expect(wrapper.state('email')).toBe('test@gmail.com'); | ||
}); | ||
|
||
it('should call onSubmit', () => { | ||
const event = { | ||
preventDefault: jest.fn(), | ||
}; | ||
wrapper.instance().onSubmit(event); | ||
expect(props.resetPassword).toHaveBeenCalled(); | ||
}); | ||
|
||
it('renders reset password form', () => { | ||
const newWrapper = shallow(<ResetPasswordForm {...props} />); | ||
expect(newWrapper.exists()).toEqual(true); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.