-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CLD-713] Update the Change Password flows to use npm package (#266)
- Loading branch information
1 parent
2cf6070
commit 583971a
Showing
2 changed files
with
42 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,7 @@ import settingsSagas, { | |
developerPasswordChange, | ||
developerPasswordChangeListen, | ||
fetchDeveloperInfo, | ||
updateDeveloperInfo, | ||
callChangePassword | ||
updateDeveloperInfo | ||
} from '../settings' | ||
import { Action } from '@/types/core' | ||
import ActionTypes from '@/constants/action-types' | ||
|
@@ -20,7 +19,7 @@ import { errorThrownServer } from '@/actions/error' | |
import errorMessages from '@/constants/error-messages' | ||
import messages from '@/constants/messages' | ||
import { developerStub } from '../__stubs__/developer' | ||
import { removeSession } from '@reapit/cognito-auth' | ||
import { removeSession, changePassword } from '@reapit/cognito-auth' | ||
import { history } from '../../core/router' | ||
import Routes from '@/constants/routes' | ||
import { authLogoutSuccess } from '@/actions/auth' | ||
|
@@ -112,24 +111,44 @@ describe('settings', () => { | |
}) | ||
expect(gen.next().value).toEqual(put(settingShowLoading(true))) | ||
expect(gen.next().value).toEqual(select(selectDeveloperEmail)) | ||
|
||
it('should call API success', () => { | ||
const clone = gen.clone() | ||
expect(clone.next('[email protected]').value).toEqual( | ||
call(callChangePassword, { values: data, email: '[email protected]' }) | ||
call(changePassword, { password: '123', newPassword: '456', userName: '[email protected]' }) | ||
) | ||
expect(clone.next({ message: 'SUCCESS' }).value).toEqual( | ||
expect(clone.next('SUCCESS').value).toEqual( | ||
put( | ||
showNotificationMessage({ | ||
variant: 'info', | ||
message: messages.CHANGE_SAVE_SUCCESSFULLY | ||
}) | ||
) | ||
) | ||
expect(clone.next({ message: 'SUCCESS' }).value).toEqual(call(removeSession)) | ||
expect(clone.next().value).toEqual(call(removeSession)) | ||
expect(clone.next().value).toEqual(put(authLogoutSuccess())) | ||
expect(clone.next().value).toEqual(history.replace(`${Routes.DEVELOPER_LOGIN}?isChangePasswordSuccess=1`)) | ||
expect(clone.next().value).toEqual(put(settingShowLoading(false))) | ||
expect(clone.next().done).toEqual(true) | ||
}) | ||
|
||
it('should fail if API response !== "SUCCESS" ', () => { | ||
const clone = gen.clone() | ||
expect(clone.next('[email protected]').value).toEqual( | ||
call(changePassword, { password: '123', newPassword: '456', userName: '[email protected]' }) | ||
) | ||
expect(clone.next('FAIL').value).toEqual( | ||
put( | ||
errorThrownServer({ | ||
type: 'SERVER', | ||
message: errorMessages.DEFAULT_SERVER_ERROR | ||
}) | ||
) | ||
) | ||
expect(clone.next().value).toEqual(put(settingShowLoading(false))) | ||
expect(clone.next().done).toEqual(true) | ||
}) | ||
|
||
it('should call API fail', () => { | ||
const clone = gen.clone() | ||
// @ts-ignore | ||
|
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