import { testHelper , admin , user } from './test.helper' ; const http = testHelper . http ; const httpAdmin = http . as ( admin ) ; const httpUser = http . as ( user ) ; const { expect } = testHelper ; describe ( 'Test Helper' , ( ) => { describe ( 'Sample Router' , ( ) => { it ( 'should return 200 on GET' , async ( ) => { const response = await http . get ( '/sample-router' ) ; expect ( response . status ) . to . be . equal ( 200 ) ; } ) ; it ( 'should return 200 on GET with queries' , async ( ) => { const query = { name : 'sergio' } ; const response = await http . get ( '/sample-router' , { query } ) ; expect ( response . status ) . to . be . equal ( 200 ) ; expect ( response . body ) . to . have . property ( 'query' ) . to . have . property ( 'name' ) . equal ( 'sergio' ) ; } ) ; it ( 'should return 200 on POST' , async ( ) => { const body = { message : 'anything' } ; const response = await http . post ( '/sample-router' , body ) ; expect ( response . status ) . to . be . equal ( 200 ) ; expect ( response . body ) . to . have . property ( 'body' ) . to . have . property ( 'message' ) . equal ( 'anything' ) ; } ) ; it ( 'should return 200 on PUT' , async ( ) => { const body = { message : 'anything' } ; const response = await http . put ( '/sample-router' , body ) ; expect ( response . status ) . to . be . equal ( 200 ) ; expect ( response . body ) . to . have . property ( 'body' ) . to . have . property ( 'message' ) . equal ( 'anything' ) ; } ) ; it ( 'should return 200 on DELETE' , async ( ) => { const response = await http . delete ( '/sample-router' ) ; expect ( response . status ) . to . be . equal ( 200 ) ; } ) ; } ) ; describe ( 'Decorator' , ( ) => { it ( 'should perform user authenticated requests' , async ( ) => { let response = await httpUser . get ( '/sample-router' ) ; expect ( response . status ) . to . be . equal ( 200 ) ; expect ( response . body ) . to . have . property ( 'headers' ) . to . have . property ( 'authorization' ) . equal ( 'Bearer user-123456' ) ; response = await httpAdmin . get ( '/sample-router' ) ; expect ( response . status ) . to . be . equal ( 200 ) ; expect ( response . body ) . to . have . property ( 'headers' ) . to . have . property ( 'authorization' ) . equal ( 'Bearer admin-123456' ) ; } ) ; } ) ; } ) ;