import { buildProcessorFunction } from './build_processor_function' ; describe ( 'buildProcessorFunction(chain, ...args)' , ( ) => { const req = { } ; const panel = { } ; const series = { } ; test ( 'should call each processor' , ( ) => { const first = jest . fn ( ( ) => ( next ) => ( doc ) => next ( doc ) ) ; const second = jest . fn ( ( ) => ( next ) => ( doc ) => next ( doc ) ) ; buildProcessorFunction ( [ first , second ] , { req , panel , series } ) ; expect ( first . mock . calls . length ) . toEqual ( 1 ) ; expect ( second . mock . calls . length ) . toEqual ( 1 ) ; } ) ; test ( 'should chain each processor' , ( ) => { const first = jest . fn ( ( ) => ( next ) => ( doc ) => next ( doc ) ) ; const second = jest . fn ( ( ) => ( next ) => ( doc ) => next ( doc ) ) ; buildProcessorFunction ( [ ( ) => first , ( ) => second ] , { req , panel , series } ) ; expect ( first . mock . calls . length ) . toEqual ( 1 ) ; expect ( second . mock . calls . length ) . toEqual ( 1 ) ; } ) ; test ( 'should next of each processor' , ( ) => { const first = jest . fn ( ) ; const second = jest . fn ( ) ; const fn = buildProcessorFunction ( [ ( ) => ( next ) => ( doc ) => { first ( ) ; next ( doc ) ; } , ( ) => ( next ) => ( doc ) => { second ( ) ; next ( doc ) ; } , ] , { req , panel , series , } ) ; fn ( { } ) ; expect ( first . mock . calls . length ) . toEqual ( 1 ) ; expect ( second . mock . calls . length ) . toEqual ( 1 ) ; } ) ; } ) ;