import { StatusCode } from '.' ; import { ConversationIsUnknownError } from '../conversation/ConversationError' ; import { UserIsUnknownError } from '../user/UserError' ; import { BackendErrorLabel } from './BackendErrorLabel' ; import { BackendErrorMapper } from './BackendErrorMapper' ; describe ( 'BackendErrorMapper' , ( ) => { describe ( '"map"' , ( ) => { it ( 'maps backend error payloads into error objects' , ( ) => { const userIdError = { code : StatusCode . BAD_REQUEST , label : BackendErrorLabel . CLIENT_ERROR , message : "[path] 'usr' invalid: Failed reading: Invalid UUID" , name : '' , } ; const userError = BackendErrorMapper . map ( userIdError ) ; expect ( userError ) . toEqual ( jasmine . any ( UserIsUnknownError ) ) ; const conversationIdError = { code : StatusCode . BAD_REQUEST , label : BackendErrorLabel . CLIENT_ERROR , message : "[path] 'cnv' invalid: Failed reading: Invalid UUID" , name : '' , } ; const conversationError = BackendErrorMapper . map ( conversationIdError ) ; expect ( conversationError ) . toEqual ( jasmine . any ( ConversationIsUnknownError ) ) ; } ) ; } ) ; } ) ;