Skip to content

Commit

Permalink
ref: return 422 for WaitForOtpError
Browse files Browse the repository at this point in the history
  • Loading branch information
mantariksh committed Mar 30, 2021
1 parent b5b52e3 commit 9036277
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ describe('Verification controller', () => {
expect(mockRes.json).toHaveBeenCalledWith({ message: expect.any(String) })
})

it('should return 400 when OTP waiting time has not elapsed', async () => {
it('should return 422 when OTP waiting time has not elapsed', async () => {
MockVerificationFactory.sendNewOtp
.mockReset()
.mockReturnValueOnce(errAsync(new WaitForOtpError()))
Expand All @@ -451,7 +451,9 @@ describe('Verification controller', () => {
hashedOtp: MOCK_HASHED_OTP,
recipient: MOCK_ANSWER,
})
expect(mockRes.status).toHaveBeenCalledWith(StatusCodes.BAD_REQUEST)
expect(mockRes.status).toHaveBeenCalledWith(
StatusCodes.UNPROCESSABLE_ENTITY,
)
expect(mockRes.json).toHaveBeenCalledWith({ message: expect.any(String) })
})

Expand Down
2 changes: 1 addition & 1 deletion src/app/modules/verification/verification.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const mapRouteError: MapRouteError = (
case WaitForOtpError:
return {
errorMessage: `You must wait for ${WAIT_FOR_OTP_SECONDS} seconds between each OTP request.`,
statusCode: StatusCodes.BAD_REQUEST,
statusCode: StatusCodes.UNPROCESSABLE_ENTITY,
}
case InvalidNumberError:
return {
Expand Down

0 comments on commit 9036277

Please sign in to comment.