@@ -7,6 +7,7 @@ import {Head} from "../../src/decorator/Head";
77import { Delete } from "../../src/decorator/Delete" ;
88import { Patch } from "../../src/decorator/Patch" ;
99import { Put } from "../../src/decorator/Put" ;
10+ import { All } from "../../src/decorator/All" ;
1011import { ContentType } from "../../src/decorator/ContentType" ;
1112import { JsonController } from "../../src/decorator/JsonController" ;
1213import { UnauthorizedError } from "../../src/http-error/UnauthorizedError" ;
@@ -52,6 +53,10 @@ describe("controller methods", () => {
5253 head ( ) {
5354 return "<html><body>Removing user</body></html>" ;
5455 }
56+ @All ( "/users/me" )
57+ all ( ) {
58+ return "<html><body>Current user</body></html>" ;
59+ }
5560 @Method ( "post" , "/categories" )
5661 postCategories ( ) {
5762 return "<html><body>Posting categories</body></html>" ;
@@ -196,6 +201,19 @@ describe("controller methods", () => {
196201 } ) ;
197202 } ) ;
198203
204+ describe ( "all respond with proper status code, headers and body content" , ( ) => {
205+ const callback = ( response : any ) => {
206+ expect ( response ) . to . have . status ( 200 ) ;
207+ expect ( response ) . to . have . header ( "content-type" , "text/html; charset=utf-8" ) ;
208+ expect ( response . body ) . to . be . equal ( "<html><body>Current user</body></html>" ) ;
209+ } ;
210+
211+ assertRequest ( [ 3001 , 3002 ] , "get" , "users/me" , callback ) ;
212+ assertRequest ( [ 3001 , 3002 ] , "put" , "users/me" , callback ) ;
213+ assertRequest ( [ 3001 , 3002 ] , "patch" , "users/me" , callback ) ;
214+ assertRequest ( [ 3001 , 3002 ] , "delete" , "users/me" , callback ) ;
215+ } ) ;
216+
199217 describe ( "custom method (post) respond with proper status code, headers and body content" , ( ) => {
200218 assertRequest ( [ 3001 , 3002 ] , "post" , "categories" , response => {
201219 expect ( response ) . to . have . status ( 200 ) ;
0 commit comments