@@ -7,6 +7,7 @@ import {Head} from "../../src/decorator/Head";
7
7
import { Delete } from "../../src/decorator/Delete" ;
8
8
import { Patch } from "../../src/decorator/Patch" ;
9
9
import { Put } from "../../src/decorator/Put" ;
10
+ import { All } from "../../src/decorator/All" ;
10
11
import { ContentType } from "../../src/decorator/ContentType" ;
11
12
import { JsonController } from "../../src/decorator/JsonController" ;
12
13
import { UnauthorizedError } from "../../src/http-error/UnauthorizedError" ;
@@ -52,6 +53,10 @@ describe("controller methods", () => {
52
53
head ( ) {
53
54
return "<html><body>Removing user</body></html>" ;
54
55
}
56
+ @All ( "/users/me" )
57
+ all ( ) {
58
+ return "<html><body>Current user</body></html>" ;
59
+ }
55
60
@Method ( "post" , "/categories" )
56
61
postCategories ( ) {
57
62
return "<html><body>Posting categories</body></html>" ;
@@ -196,6 +201,19 @@ describe("controller methods", () => {
196
201
} ) ;
197
202
} ) ;
198
203
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
+
199
217
describe ( "custom method (post) respond with proper status code, headers and body content" , ( ) => {
200
218
assertRequest ( [ 3001 , 3002 ] , "post" , "categories" , response => {
201
219
expect ( response ) . to . have . status ( 200 ) ;
0 commit comments