import tachijs , { controller , httpGet , RedirectResult } from '../../index' ; import request from 'supertest' ; describe ( 'RedirectResult' , ( ) => { it ( 'uses res.redirect' , async ( ) => { @ controller ( '/' ) class HomeController { @ httpGet ( '/' ) index ( ) { return new RedirectResult ( '/test' ) ; } } const app = tachijs ( { controllers : [ HomeController ] } ) ; const response = await request ( app ) . get ( '/' ) ; expect ( response ) . toMatchObject ( { status : 302 , header : { location : '/test' } } ) ; } ) ; it ( 'accepts status' , async ( ) => { @ controller ( '/' ) class HomeController { @ httpGet ( '/' ) index ( ) { return new RedirectResult ( '/test' , 300 ) ; } } const app = tachijs ( { controllers : [ HomeController ] } ) ; const response = await request ( app ) . get ( '/' ) ; expect ( response ) . toMatchObject ( { status : 300 , header : { location : '/test' } } ) ; } ) ; it ( 'accepts headers' , async ( ) => { @ controller ( '/' ) class HomeController { @ httpGet ( '/' ) index ( ) { return new RedirectResult ( '/test' , undefined , { test : 'test' } ) ; } } const app = tachijs ( { controllers : [ HomeController ] } ) ; const response = await request ( app ) . get ( '/' ) ; expect ( response ) . toMatchObject ( { status : 302 , header : { test : 'test' , location : '/test' } } ) ; } ) ; } ) ;