Skip to content

Commit be554a9

Browse files
committed
feat: improve test coverage
1 parent cf66c09 commit be554a9

6 files changed

Lines changed: 39 additions & 2 deletions

File tree

src/routes/__test__/social/facebook.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ describe("Facebook authentication", () => {
3333
const res = await request(app).get("/social/facebook");
3434
expect(res.status).toBe(401);
3535
});
36+
37+
it("should return a 500 error", async () => {
38+
const res = await request(app).get(
39+
"/social/facebook/callback?state=justastring&code=justanotherstring"
40+
);
41+
expect(res.status).toBe(500);
42+
});
3643
});

src/routes/__test__/social/github.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ describe("GitHub authentication", () => {
3333
const res = await request(app).get("/social/github");
3434
expect(res.status).toBe(401);
3535
});
36+
37+
it("should return a 500 error", async () => {
38+
const res = await request(app).get(
39+
"/social/github/callback?state=justastring&code=justanotherstring"
40+
);
41+
expect(res.status).toBe(500);
42+
});
3643
});

src/routes/__test__/social/google.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ describe("Google authentication", () => {
3333
const res = await request(app).get("/social/google");
3434
expect(res.status).toBe(401);
3535
});
36+
37+
it("should return a 500 error", async () => {
38+
const res = await request(app).get(
39+
"/social/google/callback?state=justastring&code=justanotherstring"
40+
);
41+
expect(res.status).toBe(500);
42+
});
3643
});

src/routes/__test__/social/twitter.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,11 @@ describe("Twitter authentication", () => {
3333
const res = await request(app).get("/social/twitter");
3434
expect(res.status).toBe(401);
3535
});
36+
37+
it("should return a 500 error", async () => {
38+
const res = await request(app).get(
39+
"/social/twitter/callback?oauth_token=justastring&oauth_verifier=justanotherstring"
40+
);
41+
expect(res.status).toBe(500);
42+
});
3643
});

src/services/facebookService.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export default class FacebookService {
7070
},
7171
});
7272

73-
console.log(userResponse.data);
74-
7573
return {
7674
profile: {
7775
facebookId: userResponse.data.id,
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { InternalServerError } from "../customError";
2+
3+
describe("customError", () => {
4+
it("should return a formatted 500 error", () => {
5+
const error = new InternalServerError();
6+
expect(error.message).toEqual(
7+
"Something went wrong, please try again later."
8+
);
9+
expect(error.statusCode).toEqual(500);
10+
});
11+
});

0 commit comments

Comments
 (0)