import tachijs , { controller , httpGet , NextResult } from '../../index' ; import request from 'supertest' ; import { ErrorRequestHandler } from 'express' ; describe ( 'NextResult' , ( ) => { it ( 'uses next' , async ( ) => { @ controller ( '/' ) class HomeController { @ httpGet ( '/' ) index ( ) { return new NextResult ( ) ; } @ httpGet ( '/' ) next ( ) { return 'Hello' ; } } const app = tachijs ( { controllers : [ HomeController ] } ) ; const response = await request ( app ) . get ( '/' ) ; expect ( response ) . toMatchObject ( { status : 200 , text : 'Hello' } ) ; } ) ; it ( 'accepts error' , async ( ) => { @ controller ( '/' ) class HomeController { @ httpGet ( '/' ) index ( ) { return new NextResult ( new Error ( 'Hello' ) ) ; } } const app = tachijs ( { controllers : [ HomeController ] } ) ; const errorHandler = ( error , req , res , next ) => { res . send ( error . message ) ; } ; app . use ( errorHandler ) ; const response = await request ( app ) . get ( '/' ) ; expect ( response ) . toMatchObject ( { status : 200 , text : 'Hello' } ) ; } ) ; } ) ;