generated from graasp/graasp-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add member password routes (#824)
* fix: add member password routes * fix: add tests * fix: update from comments
- Loading branch information
Showing
4 changed files
with
109 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,8 +22,9 @@ import { memberKeys } from '../keys.js'; | |
import { SIGN_OUT_ROUTE } from '../routes.js'; | ||
import { | ||
buildDeleteMemberRoute, | ||
buildPatchMemberPasswordRoute, | ||
buildPatchMemberRoute, | ||
buildUpdateMemberPasswordRoute, | ||
buildPostMemberPasswordRoute, | ||
buildUploadAvatarRoute, | ||
} from './routes.js'; | ||
import { updatePasswordRoutine, uploadAvatarRoutine } from './routines.js'; | ||
|
@@ -346,20 +347,17 @@ describe('Member Mutations', () => { | |
}); | ||
|
||
describe('useUpdatePassword', () => { | ||
const route = `/${buildUpdateMemberPasswordRoute()}`; | ||
const route = `/${buildPatchMemberPasswordRoute()}`; | ||
const mutation = mutations.useUpdatePassword; | ||
const password = 'ASDasd123'; | ||
const currentPassword = 'ASDasd123'; | ||
const name = 'myName'; | ||
const id = 'myId'; | ||
const email = '[email protected]'; | ||
|
||
it(`Update password`, async () => { | ||
const endpoints = [ | ||
{ | ||
route, | ||
response: { email, id, name }, | ||
statusCode: StatusCodes.OK, | ||
response: {}, | ||
statusCode: StatusCodes.NO_CONTENT, | ||
method: HttpMethod.Patch, | ||
}, | ||
]; | ||
|
@@ -409,4 +407,65 @@ describe('Member Mutations', () => { | |
); | ||
}); | ||
}); | ||
|
||
describe('useCreatePassword', () => { | ||
const route = `/${buildPostMemberPasswordRoute()}`; | ||
const mutation = mutations.useCreatePassword; | ||
const password = 'ASDasd123'; | ||
|
||
it(`Update password`, async () => { | ||
const endpoints = [ | ||
{ | ||
route, | ||
response: {}, | ||
statusCode: StatusCodes.NO_CONTENT, | ||
method: HttpMethod.Post, | ||
}, | ||
]; | ||
|
||
const mockedMutation = await mockMutation({ | ||
endpoints, | ||
mutation, | ||
wrapper, | ||
}); | ||
|
||
await act(async () => { | ||
mockedMutation.mutate({ password }); | ||
await waitForMutation(); | ||
}); | ||
|
||
expect(mockedNotifier).toHaveBeenCalledWith({ | ||
type: updatePasswordRoutine.SUCCESS, | ||
payload: { message: SUCCESS_MESSAGES.UPDATE_PASSWORD }, | ||
}); | ||
}); | ||
|
||
it(`Unauthorized`, async () => { | ||
const endpoints = [ | ||
{ | ||
route, | ||
response: UNAUTHORIZED_RESPONSE, | ||
method: HttpMethod.Post, | ||
statusCode: StatusCodes.UNAUTHORIZED, | ||
}, | ||
]; | ||
|
||
const mockedMutation = await mockMutation({ | ||
endpoints, | ||
mutation, | ||
wrapper, | ||
}); | ||
|
||
await act(async () => { | ||
mockedMutation.mutate({ password }); | ||
await waitForMutation(); | ||
}); | ||
|
||
expect(mockedNotifier).toHaveBeenCalledWith( | ||
expect.objectContaining({ | ||
type: updatePasswordRoutine.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 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