11import supertest from 'supertest'
22
33import { Sec } from '../src/server'
4- import { IncomingMessage , ServerResponse } from 'http '
4+ import { Context } from './../src/Contracts/HandlerContract '
55
66describe ( '\n Server' , ( ) => {
77 it ( 'should be able to create a Http server using SecJS' , async ( ) => {
@@ -23,15 +23,12 @@ describe('\n Server', () => {
2323 it ( 'should be able to create routes with handlers' , async ( ) => {
2424 const server = new Sec ( )
2525
26- server . get (
27- '/tests' ,
28- ( request : IncomingMessage , response : ServerResponse ) => {
29- response . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
26+ server . get ( '/tests' , ( ctx : Context ) => {
27+ ctx . response . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
3028
31- response . write ( JSON . stringify ( { data : [ { id : 1 , name : 'Test 1' } ] } ) )
32- response . end ( )
33- } ,
34- )
29+ ctx . response . write ( JSON . stringify ( { data : [ { id : 1 , name : 'Test 1' } ] } ) )
30+ ctx . response . end ( )
31+ } )
3532
3633 server . listen ( )
3734
@@ -49,17 +46,14 @@ describe('\n Server', () => {
4946 it ( 'should be able to create routes with params' , async ( ) => {
5047 const server = new Sec ( )
5148
52- server . get (
53- '/tests/:id/unitaries/:unitaries_id' ,
54- ( request : IncomingMessage , response : ServerResponse ) => {
55- response . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
56-
57- response . write (
58- JSON . stringify ( { data : { id : 1 , name : 'Unit Test 1' , testId : 1 } } ) ,
59- )
60- response . end ( )
61- } ,
62- )
49+ server . get ( '/tests/:id/unitaries/:unitaries_id' , ( ctx : Context ) => {
50+ ctx . response . writeHead ( 200 , { 'Content-Type' : 'application/json' } )
51+
52+ ctx . response . write (
53+ JSON . stringify ( { data : { id : 1 , name : 'Unit Test 1' , testId : 1 } } ) ,
54+ )
55+ ctx . response . end ( )
56+ } )
6357
6458 server . listen ( )
6559
0 commit comments