import { Context , Logger } from '@azure/functions' ; import { adaptFaasKitHandlerForFunctions } from './adaptors' ; describe ( 'adaptFaasKitHandlerForFunctions' , ( ) => { test ( 'nests functions-provided context' , async ( ) => { const mockEvent = { testKey : 'testValue' } ; const mockPreLogger = ( ... _args ) => { } ; mockPreLogger . warn = ( ... _args ) => { } ; mockPreLogger . error = ( ... _args ) => { } ; mockPreLogger . verbose = ( ... _args ) => { } ; mockPreLogger . info = ( ... _args ) => { } ; const mockLogger = mockPreLogger ; const mockContext = { invocationId : '1' , executionContext : { invocationId : '1' , functionName : 'test' , functionDirectory : '/' , } , bindings : { } , bindingData : { } , bindingDefinitions : [ ] , traceContext : { traceparent : '0' , tracestate : '1' , attributes : { } , } , log : mockLogger , done : ( _err ? , _result ? ) => { } , } ; const mockResult = 'test result' ; const mockHandler = jest . fn ( ) . mockResolvedValue ( mockResult ) ; const mockWrappedHandler = adaptFaasKitHandlerForFunctions ( mockHandler ) ; const result = await mockWrappedHandler ( mockContext , mockEvent ) ; expect ( mockHandler ) . toBeCalledWith ( mockEvent , { AzureFunction : mockContext } ) ; expect ( result ) . toEqual ( mockResult ) ; } ) ; } ) ; describe ( 'adaptLambdaHandlerForFaasKit' , ( ) => { } ) ;