import { ResetRequest as Request } from "common" ; import { post } from "handlers/reset" ; import { mockAuthenticationClientForgotPasswordWithError , mockAuthenticationClientForgotPasswordWithSuccess } from "_/mocks/clients" ; import { mockResetRequest } from "_/mocks/common" ; import { mockAPIGatewayProxyEvent } from "_/mocks/vendor/aws-lambda" ; describe ( "handlers/reset" , ( ) => { describe ( "post" , ( ) => { const { username } = mockResetRequest ( ) ; const event = mockAPIGatewayProxyEvent < Request > ( { body : { username } } ) ; it ( "should resolve with empty body" , async ( ) => { const forgotPasswordMock = mockAuthenticationClientForgotPasswordWithSuccess ( ) ; const { statusCode , body } = await post ( event ) ; expect ( statusCode ) . toEqual ( 204 ) ; expect ( body ) . toEqual ( "" ) ; expect ( forgotPasswordMock ) . toHaveBeenCalledWith ( username ) ; } ) ; it ( "should resolve with authentication client error" , async ( ) => { const forgotPasswordMock = mockAuthenticationClientForgotPasswordWithError ( ) ; const { statusCode , body } = await post ( event ) ; expect ( statusCode ) . toEqual ( 400 ) ; expect ( body ) . toEqual ( JSON . stringify ( { type : "Error" , message : "forgotPassword" } ) ) ; expect ( forgotPasswordMock ) . toHaveBeenCalledWith ( username ) ; } ) ; } ) ; } ) ;