Skip to content

Commit f3f3300

Browse files
committed
feat: implement callbacks tests
1 parent 10c6244 commit f3f3300

4 files changed

Lines changed: 36 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import app from "../../..";
22
import request from "supertest";
33
import { testFlags } from "../../../middleware/__test__/testSettings";
44

5+
// Authentication URL.
6+
let testCallbackUrl =
7+
"/social/authCallback?success=true&id=375612282&isVerified=false&firstname=Allistair&lastname=Vilakazi&username=375612282&email=&photo=http%3A%2F%2Fpbs.twimg.com%2Fprofile_images%2F378800000629602434%2Fc6e96888c20267d9eb13846b3f23d70d_normal.jpeg";
8+
59
describe("Facebook authentication", () => {
610
beforeEach(() => {
711
testFlags.disableFacebook = false;
@@ -18,6 +22,11 @@ describe("Facebook authentication", () => {
1822
);
1923
});
2024

25+
it("should make a success callback after authentication", async () => {
26+
const res = await request(app).get(testCallbackUrl);
27+
expect(res.status).toBe(200);
28+
});
29+
2130
it("should return a 401 response", async () => {
2231
testFlags.disableFacebook = true;
2332

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import app from "../../..";
22
import request from "supertest";
33
import { testFlags } from "../../../middleware/__test__/testSettings";
44

5+
// Authentication URL.
6+
let testCallbackUrl =
7+
"/social/authCallback?success=true&id=45206423&isVerified=false&firstname=Allistair&lastname=Vilakazi&username=simply-alliv&email=&photo=https%3A%2F%2Favatars3.githubusercontent.com%2Fu%2F45206423%3Fv%3D4";
8+
59
describe("GitHub authentication", () => {
610
beforeEach(() => {
711
testFlags.disableFacebook = false;
@@ -18,6 +22,11 @@ describe("GitHub authentication", () => {
1822
);
1923
});
2024

25+
it("should make a success callback after authentication", async () => {
26+
const res = await request(app).get(testCallbackUrl);
27+
expect(res.status).toBe(200);
28+
});
29+
2130
it("should return a 401 response", async () => {
2231
testFlags.disableGithub = true;
2332

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import app from "../../..";
22
import request from "supertest";
33
import { testFlags } from "../../../middleware/__test__/testSettings";
44

5+
// Authentication URL.
6+
let testCallbackUrl =
7+
"/social/authCallback?success=true&id=106257712146027420454&isVerified=true&firstname=Allistair&lastname=Vilakazi&username=allistair.vilakazi%40gmail.com&email=allistair.vilakazi%40gmail.com&photo=https%3A%2F%2Flh3.googleusercontent.com%2Fa-%2FAOh14GiygoCTW6KQa09vGR7zofMtGEE6YB9_ALO1EMxNMA#";
8+
59
describe("Google authentication", () => {
610
beforeEach(() => {
711
testFlags.disableFacebook = false;
@@ -18,6 +22,11 @@ describe("Google authentication", () => {
1822
);
1923
});
2024

25+
it("should make a success callback after authentication", async () => {
26+
const res = await request(app).get(testCallbackUrl);
27+
expect(res.status).toBe(200);
28+
});
29+
2130
it("should return a 401 response", async () => {
2231
testFlags.disableGoogle = true;
2332

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ import app from "../../..";
22
import request from "supertest";
33
import { testFlags } from "../../../middleware/__test__/testSettings";
44

5+
// Authentication URL.
6+
let testCallbackUrl =
7+
"/social/authCallback?success=true&id=4281211625282819&isVerified=false&firstname=Allistair&lastname=Vilakazi&username=allistair.vilakazi%40gmail.com&email=allistair.vilakazi%40gmail.com&photo=https%3A%2F%2Fplatform-lookaside.fbsbx.com%2Fplatform%2Fprofilepic%2F%3Fasid%3D4281211625282819%26height%3D200%26width%3D200%26ext%3D1599383493%26hash%3DAeRhrrwBsdhpY-gO#_=_";
8+
59
describe("Twitter authentication", () => {
610
beforeEach(() => {
711
testFlags.disableFacebook = false;
@@ -18,6 +22,11 @@ describe("Twitter authentication", () => {
1822
);
1923
});
2024

25+
it("should make a success callback after authentication", async () => {
26+
const res = await request(app).get(testCallbackUrl);
27+
expect(res.status).toBe(200);
28+
});
29+
2130
it("should return a 401 response", async () => {
2231
testFlags.disableTwitter = true;
2332

0 commit comments

Comments
 (0)