import { expect } from 'chai' ; import { GenericRequestHandlerChain } from '../../../../lib/dispatcher/request/handler/GenericRequestHandlerChain' ; import { GenericRequestMapper } from '../../../../lib/dispatcher/request/mapper/GenericRequestMapper' ; import { MockAlwaysFalseRequestHandler } from '../../../mocks/request/MockAlwaysFalseRequestHandler' ; import { MockAlwaysTrueRequestHandler } from '../../../mocks/request/MockAlwaysTrueRequestHandler' ; describe ( 'GenericRequestMapper' , ( ) => { const mockAlwaysTrueRequestHandlerChain = new GenericRequestHandlerChain < string , string > ( { requestHandler : new MockAlwaysTrueRequestHandler ( ) , } ) ; const mockAlwaysFalseRequestHandlerChain = new GenericRequestHandlerChain < string , string > ( { requestHandler : new MockAlwaysFalseRequestHandler ( ) , } ) ; it ( 'should be able to get the request handler that can handle the input' , async ( ) => { const mapper = new GenericRequestMapper < string , string > ( { requestHandlerChains : [ mockAlwaysFalseRequestHandlerChain , mockAlwaysTrueRequestHandlerChain , ] , } ) ; const handlerChain = await mapper . getRequestHandlerChain ( null ) ; expect ( handlerChain . getRequestHandler ( ) ) . instanceof ( MockAlwaysTrueRequestHandler ) ; } ) ; it ( 'should return null if no request handler can handle the input' , async ( ) => { const mapper = new GenericRequestMapper < string , string > ( { requestHandlerChains : [ mockAlwaysFalseRequestHandlerChain , ] , } ) ; const handlerChain = await mapper . getRequestHandlerChain ( null ) ; expect ( handlerChain ) . equal ( null ) ; } ) ; } ) ;