import { APIClient } from '../APIClient' ; import { ClientType } from '../client/ClientType' ; import { StatusCode } from '../http' ; describe ( 'AuthAPI' , ( ) => { const apiClient = new APIClient ( ) ; it ( 'sets the client to permanent' , async ( ) => { const data = { clientType : ClientType . PERMANENT , email : 'email@example.com' , password : 'email@example.com' , } ; spyOn ( apiClient . transport . http , 'sendJSON' ) . and . returnValue ( Promise . resolve ( { config : { } , data : '' , headers : { } , status : StatusCode . OK , statusText : 'OK' , } ) ) ; await apiClient . auth . api . postLogin ( data ) ; expect ( apiClient . transport . http . sendJSON ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { data : { clientType : undefined , email : data . email , password : data . password , } , params : { persist : true , } , } ) ) ; } ) ; it ( 'sets the client to temporary' , async ( ) => { const data = { clientType : ClientType . TEMPORARY , email : 'email@example.com' , password : 'email@example.com' , } ; spyOn ( apiClient . transport . http , 'sendJSON' ) . and . returnValue ( Promise . resolve ( { config : { } , data : '' , headers : { } , status : StatusCode . OK , statusText : 'OK' , } ) ) ; await apiClient . auth . api . postLogin ( data ) ; expect ( apiClient . transport . http . sendJSON ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { data : { clientType : undefined , email : data . email , password : data . password , } , params : { persist : false , } , } ) ) ; } ) ; } ) ;