Skip to content

Commit

Permalink
fix(tests): corrected 'toBeArray' and 'toBeObject' to be called as fu…
Browse files Browse the repository at this point in the history
…nctions instead as a property access.
  • Loading branch information
timDeHof committed Dec 18, 2024
1 parent 7a33692 commit 249c8dc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions test/auth.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ describe("AuthController e2e Tests", () => {
},
});

expect(userAfterVerify?.emailVerified).toBe(true);
expect(userAfterVerify?.emailVerified).toBeTrue();
expect(userAfterVerify?.emailVerificationToken).toBe(null);
});

Expand Down Expand Up @@ -309,7 +309,7 @@ describe("AuthController e2e Tests", () => {
},
});

expect(userAfterVerify?.emailVerified).toBe(false);
expect(userAfterVerify?.emailVerified).toBeFalse();
expect(userAfterVerify?.emailVerificationToken).toBeDefined();
});

Expand Down
7 changes: 4 additions & 3 deletions test/teams.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import * as request from "supertest";
import { AppModule } from "@/app.module";
import { PrismaService } from "@/prisma/prisma.service";
import { seed } from "@Prisma/seed/seed";
import { toBeArray } from "jest-extended";
import { loginAndGetTokens } from "./utils";
import * as cookieParser from "cookie-parser";
import { CASLForbiddenExceptionFilter } from "@/exception-filters/casl-forbidden-exception.filter";

//Logged in user is Jessica Williamson for admin routes /teams and /teams/voyages/:voyageid
//Logged in user is Dan ko for team member routes /teams/:teamid and /teams/:teamid/members
//Dan Ko is part of the team with team id 4

expect.extend({ toBeArray });
describe("Teams Controller (e2e)", () => {
let app: INestApplication;
let prisma: PrismaService;
Expand Down Expand Up @@ -49,7 +50,7 @@ describe("Teams Controller (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeArray;
expect(res.body).toBeArray();
});
});
it("should return 401 when user is not logged in", async () => {
Expand Down Expand Up @@ -86,7 +87,7 @@ describe("Teams Controller (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeArray;
expect(res.body).toBeArray();
});
});
it("should return 404 if voyage teams are not found given a voyage id", async () => {
Expand Down
9 changes: 5 additions & 4 deletions test/unverifiedUser.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { seed } from "@Prisma/seed/seed";
import { loginAndGetTokens } from "./utils";
import * as cookieParser from "cookie-parser";
import { CASLForbiddenExceptionFilter } from "@/exception-filters/casl-forbidden-exception.filter";

import { toBeObject } from "jest-extended";
expect.extend({ toBeObject });
//Logged in user is Yoshi Amano
//Tests are for routes that are accessible to unverified users
// - route /auth/resend-email is not tested, since this case is already covered in existing e2e test
Expand Down Expand Up @@ -51,7 +52,7 @@ describe("Unverified user routes (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeObject;
expect(res.body).toBeObject();
});
});
});
Expand All @@ -69,7 +70,7 @@ describe("Unverified user routes (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeObject;
expect(res.body).toBeObject();
});
});
});
Expand All @@ -88,7 +89,7 @@ describe("Unverified user routes (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeObject;
expect(res.body).toBeObject();
});
});
});
Expand Down
6 changes: 4 additions & 2 deletions test/users.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { seed } from "@Prisma/seed/seed";
import { getUseridFromEmail, loginAndGetTokens } from "./utils";
import * as cookieParser from "cookie-parser";
import { CASLForbiddenExceptionFilter } from "@/exception-filters/casl-forbidden-exception.filter";
import { toBeArray, toBeObject } from "jest-extended";

expect.extend({ toBeArray, toBeObject });
//Logged in user is Jessica Williamson for admin routes
//Logged in user is Dan ko for non admin routes

Expand Down Expand Up @@ -50,7 +52,7 @@ describe("Users Controller (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeArray;
expect(res.body).toBeArray();
});
});
it("should return 401 when user is not logged in", async () => {
Expand Down Expand Up @@ -86,7 +88,7 @@ describe("Users Controller (e2e)", () => {
.expect(200)
.expect("Content-Type", /json/)
.expect((res) => {
expect(res.body).toBeObject;
expect(res.body).toBeObject();
});
});
it("should return 401 when user is not logged in", async () => {
Expand Down

0 comments on commit 249c8dc

Please sign in to comment.