Skip to content

Commit

Permalink
Merge branch 'Elassyo-master' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
jotamorais committed May 29, 2020
2 parents 678cb86 + 7fc4728 commit 9256d08
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/functional/controller-methods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {Head} from "../../src/decorator/Head";
import {Delete} from "../../src/decorator/Delete";
import {Patch} from "../../src/decorator/Patch";
import {Put} from "../../src/decorator/Put";
import {All} from "../../src/decorator/All";
import {ContentType} from "../../src/decorator/ContentType";
import {JsonController} from "../../src/decorator/JsonController";
import {UnauthorizedError} from "../../src/http-error/UnauthorizedError";
Expand Down Expand Up @@ -52,6 +53,10 @@ describe("controller methods", () => {
head() {
return "<html><body>Removing user</body></html>";
}
@All("/users/me")
all() {
return "<html><body>Current user</body></html>";
}
@Method("post", "/categories")
postCategories() {
return "<html><body>Posting categories</body></html>";
Expand Down Expand Up @@ -196,6 +201,19 @@ describe("controller methods", () => {
});
});

describe("all respond with proper status code, headers and body content", () => {
const callback = (response: any) => {
expect(response).to.have.status(200);
expect(response).to.have.header("content-type", "text/html; charset=utf-8");
expect(response.body).to.be.equal("<html><body>Current user</body></html>");
};

assertRequest([3001, 3002], "get", "users/me", callback);
assertRequest([3001, 3002], "put", "users/me", callback);
assertRequest([3001, 3002], "patch", "users/me", callback);
assertRequest([3001, 3002], "delete", "users/me", callback);
});

describe("custom method (post) respond with proper status code, headers and body content", () => {
assertRequest([3001, 3002], "post", "categories", response => {
expect(response).to.have.status(200);
Expand Down

0 comments on commit 9256d08

Please sign in to comment.