import { Back , Controller , Post , Route , Request , Response , RequestBody , ResponseBody } from "../index" ; const request = require ( "supertest" ) ; const assert = require ( "assert" ) ; import "mocha" ; import bodyParser = require ( "body-parser" ) ; describe ( "@RequestBody" , ( ) => { class Product { constructor ( private id , private label , private price ) { } ; } it ( "shoul the product" , done => { Back . reset ( ) ; @ Controller @ Route ( "/product" ) class ProductController { constructor ( ) { } @ Post ( "/" ) @ ResponseBody addProduct ( req , res , @ RequestBody product ) { assert . deepEqual ( { id : 1 , label : "Bimo" , price : 45 } , product ) ; return "done" ; } } let app = Back . express ( ) ; app . use ( bodyParser . json ( ) ) ; app . use ( bodyParser . urlencoded ( { extended : false } ) ) ; Back . prepare ( app ) ; request ( app ) . post ( "/product/" ) . send ( { id : 1 , label : "Bimo" , price : 45 } ) . expect ( JSON . stringify ( "done" ) , done ) ; } ) ; } ) ;