import { AuthenticationClient } from "clients/authentication" ; import { Session } from "common" ; import { VerificationCode } from "verification" ; import { mockSession } from "_/mocks/common" ; import { mockVerificationCode } from "_/mocks/verification" ; param promise return function mockAuthenticationClientAuthenticateWithCredentials ( promise ) { return spyOn ( AuthenticationClient . prototype , "authenticateWithCredentials" ) . and . callFake ( promise ) ; } param session return export function mockAuthenticationClientAuthenticateWithCredentialsWithResult ( session = mockSession ( ) ) { return mockAuthenticationClientAuthenticateWithCredentials ( ( ) => Promise . resolve ( session ) ) ; } param err return export function mockAuthenticationClientAuthenticateWithCredentialsWithError ( err = new Error ( "authenticateWithCredentials" ) ) { return mockAuthenticationClientAuthenticateWithCredentials ( ( ) => Promise . reject ( err ) ) ; } param promise return function mockAuthenticationClientAuthenticateWithToken ( promise ) { return spyOn ( AuthenticationClient . prototype , "authenticateWithToken" ) . and . callFake ( promise ) ; } param session return export function mockAuthenticationClientAuthenticateWithTokenWithResult ( session = mockSession ( ) ) { return mockAuthenticationClientAuthenticateWithToken ( ( ) => Promise . resolve ( session ) ) ; } param err return export function mockAuthenticationClientAuthenticateWithTokenWithError ( err = new Error ( "authenticateWithToken" ) ) { return mockAuthenticationClientAuthenticateWithToken ( ( ) => Promise . reject ( err ) ) ; } param promise return function mockAuthenticationClientRegister ( promise ) { return spyOn ( AuthenticationClient . prototype , "register" ) . and . callFake ( promise ) ; } return export function mockAuthenticationClientRegisterWithSuccess ( ) { return mockAuthenticationClientRegister ( ( ) => Promise . resolve ( mockVerificationCode ( ) ) ) ; } param err return export function mockAuthenticationClientRegisterWithError ( err = new Error ( "register" ) ) { return mockAuthenticationClientRegister ( ( ) => Promise . reject ( err ) ) ; } param promise return function mockAuthenticationClientForgotPassword ( promise ) { return spyOn ( AuthenticationClient . prototype , "forgotPassword" ) . and . callFake ( promise ) ; } return export function mockAuthenticationClientForgotPasswordWithSuccess ( ) { return mockAuthenticationClientForgotPassword ( ( ) => Promise . resolve ( mockVerificationCode ( ) ) ) ; } param err return export function mockAuthenticationClientForgotPasswordWithError ( err = new Error ( "forgotPassword" ) ) { return mockAuthenticationClientForgotPassword ( ( ) => Promise . reject ( err ) ) ; }