Skip to content

Commit

Permalink
fix(tests): move password validation to the top
Browse files Browse the repository at this point in the history
this should fix the occasionally failed tests
  • Loading branch information
Veirt committed Nov 22, 2024
1 parent 9ef2720 commit e5ff17d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
32 changes: 16 additions & 16 deletions tests/integration/learner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,22 @@ describe("Update learner password", async () => {
idToken = token;
});

test("should validate password", async () => {
const res = await supertest(app)
.put("/api/v1/learners/password")
.set("Authorization", `Bearer ${idToken}`)
.send({
currentPassword: "1234",
newPassword: "123",
confirmPassword: "123",
})
.expect(400);

expect(res.body.errors[0].message).toEqual(
"Password must be at least 8 characters",
);
});

test("should be able to update learner password", async () => {
const newPassword = faker.internet.password();
await supertest(app)
Expand All @@ -162,20 +178,4 @@ describe("Update learner password", async () => {
})
.expect(401);
});

test("should validate password", async () => {
const res = await supertest(app)
.put("/api/v1/learners/password")
.set("Authorization", `Bearer ${idToken}`)
.send({
currentPassword: "1234",
newPassword: "123",
confirmPassword: "123",
})
.expect(400);

expect(res.body.errors[0].message).toEqual(
"Password must be at least 8 characters",
);
});
});
32 changes: 16 additions & 16 deletions tests/integration/tutor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,22 @@ describe("Update tutor password", async () => {
idToken = token;
});

test("should validate password", async () => {
const res = await supertest(app)
.put("/api/v1/tutors/password")
.set("Authorization", `Bearer ${idToken}`)
.send({
currentPassword: "1234",
newPassword: "123",
confirmPassword: "123",
})
.expect(400);

expect(res.body.errors[0].message).toEqual(
"Password must be at least 8 characters",
);
});

test("should be able to update tutor password", async () => {
const newPassword = faker.internet.password();
await supertest(app)
Expand All @@ -153,20 +169,4 @@ describe("Update tutor password", async () => {
})
.expect(401);
});

test("should validate password", async () => {
const res = await supertest(app)
.put("/api/v1/tutors/password")
.set("Authorization", `Bearer ${idToken}`)
.send({
currentPassword: "1234",
newPassword: "123",
confirmPassword: "123",
})
.expect(400);

expect(res.body.errors[0].message).toEqual(
"Password must be at least 8 characters",
);
});
});

0 comments on commit e5ff17d

Please sign in to comment.