import 'reflect-metadata' ; import { ScanNotificationErrorCodes , ScanRunErrorCodes } from 'service-library' ; import { ScanErrorConverter } from './scan-error-converter' ; describe ( ScanErrorConverter , ( ) => { let testSubject ; beforeEach ( ( ) => { testSubject = new ScanErrorConverter ( ) ; } ) ; describe ( 'getScanRunErrorCode' , ( ) => { it ( 'should return internal error for null or undefined' , ( ) => { let errorCode = testSubject . getScanRunErrorCode ( null ) ; expect ( errorCode ) . toEqual ( ScanRunErrorCodes . internalError ) ; errorCode = testSubject . getScanRunErrorCode ( undefined ) ; expect ( errorCode ) . toEqual ( ScanRunErrorCodes . internalError ) ; } ) ; it ( 'should resolve scanError to scanErrorCode' , ( ) => { const errorCode = testSubject . getScanRunErrorCode ( { errorType : 'InvalidContentType' , message : 'some message' , } ) ; expect ( errorCode ) . toEqual ( ScanRunErrorCodes . invalidContentType ) ; } ) ; } ) ; describe ( 'getScanNotificationErrorCode' , ( ) => { it ( 'should return internal error for string input' , ( ) => { const errorCode = testSubject . getScanNotificationErrorCode ( 'hello' ) ; expect ( errorCode ) . toEqual ( ScanNotificationErrorCodes . InternalError ) ; } ) ; it ( 'should resolve scanError to scanErrorCode' , ( ) => { const errorCode = testSubject . getScanNotificationErrorCode ( { errorType : 'InternalError' , message : 'some message' , } ) ; expect ( errorCode ) . toEqual ( ScanNotificationErrorCodes . InternalError ) ; } ) ; } ) ; } ) ;