-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add remainder auth tests #2233
Add remainder auth tests #2233
Conversation
@horvathmarton do you need to rebase? Looks like this still shows changes from the previous PR |
70d2a34
to
e130d21
Compare
@imolorhe true, rebase is done. |
@@ -0,0 +1,9 @@ | |||
import { Request, Response } from 'express'; | |||
|
|||
export function mockRequest(props?: object): Request { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function mockRequest(props?: object): Request { | |
export function mockRequest(props?: Partial<Request>): Request { |
the props should be valid fields in request right? Same treatment for response below.
it(`should return true if the password matches the provided hash`, async () => { | ||
// GIVEN | ||
jest | ||
.spyOn(bcrypt, 'compare') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of mocking bcrypt, let's generate a valid hash and hardcode it in the test. You can create a map of password-to-hash that you can use in the tests, if you need multiple.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes!
Fixes
#1717
Checks
yarn test-build
Changes proposed in this pull request:
Added unit tests for all public methods of:
Add dynamic mocks for Express request and response.
Add custom matches for user controller responses.