Skip to content

Commit 7fc4728

Browse files
committed
Merge branch 'master' of https://github.com/Elassyo/routing-controllers into Elassyo-master
2 parents 311f2fb + 694901a commit 7fc4728

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/functional/controller-methods.spec.ts

+18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {Head} from "../../src/decorator/Head";
77
import {Delete} from "../../src/decorator/Delete";
88
import {Patch} from "../../src/decorator/Patch";
99
import {Put} from "../../src/decorator/Put";
10+
import {All} from "../../src/decorator/All";
1011
import {ContentType} from "../../src/decorator/ContentType";
1112
import {JsonController} from "../../src/decorator/JsonController";
1213
import {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

Comments
 (0)