Skip to content

Commit

Permalink
Feat: resolved conflict on google auth branch
Browse files Browse the repository at this point in the history
  • Loading branch information
MugemaneBertin2001 committed Apr 26, 2024
2 parents 9a69b47 + b9f51e2 commit 4566a10
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions __test__/home.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ describe("Testing Home route", () => {
const response = await request(app).get("/login");
expect(response.text).toBe("<a href='/api/v1/users/login/google'>click to here to Login</a>")

expect(response.status).toBe(200);
}, 20000);
test("server should return status code of 200 and link to log in with google --> given'/login'", async () => {
const response = await request(app).get("/login");
expect(response.text).toBe("<a href='/api/v1/users/login/google'>click to here to Login</a>")

expect(response.status).toBe(200);
}, 20000);
});
11 changes: 7 additions & 4 deletions __test__/user.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,15 @@ describe("Testing user Routes", () => {
});

test("should return all users in db --> given '/api/v1/users'", async () => {
const spy = jest.spyOn(User, "findAll");
const spy2 = jest.spyOn(userServices, "getAllUsers");
const response = await request(app).get("/api/v1/users");
expect(spy).toHaveBeenCalled();
expect(spy2).toHaveBeenCalled();
expect(response.status).toBe(200);
expect(response.body).toBeDefined();
expect(response.body.users).toBeDefined();
expect(Array.isArray(response.body.users)).toBe(true);
expect(response.body.users.length).toBeGreaterThan(0);
}, 20000);


test("Should return status 401 to indicate Unauthorized user", async () => {
const loggedInUser = {
email: userData.email,
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"build": "tsc",
"migrate": "npx sequelize-cli db:migrate",
"unmigrate": "npx sequelize-cli db:migrate:undo",
"unmigrate": "npx sequelize-cli db:migrate:undo",
"seed": "npx sequelize-cli db:seed:all",
"lint:fix": "npx eslint --fix .",
"test": "cross-env NODE_ENV=test jest --detectOpenHandles --coverage",
Expand Down Expand Up @@ -80,9 +81,7 @@
"dotenv": "^16.4.5",
"email-validator": "^2.0.4",
"express": "^4.19.2",
"husky": "^9.0.11",
"joi": "^17.13.0",
"express-session": "^1.18.0",
"joi": "^17.12.3",
"jsonwebtoken": "^9.0.2",
"lint-staged": "^15.2.2",
"passport": "^0.7.0",
Expand Down
8 changes: 8 additions & 0 deletions src/routes/userRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import {
userLogin,
updatePassword, handleFailure, handleSuccess }
from "../controllers/userControllers";
require("../auth/auth");

import {
emailValidation,
validateSchema,
Expand Down Expand Up @@ -32,6 +34,12 @@ userRoutes.get("/auth/google/callback", userService.callbackFn);
userRoutes.get("/auth/google/success", handleSuccess);
userRoutes.get("/auth/google/failure", handleFailure);

userRoutes.get("/login/google", userService.authenticateUser);
userRoutes.get("/auth/google/callback", userService.callbackFn);
userRoutes.get("/auth/google/success", handleSuccess);
userRoutes.get("/auth/google/failure", handleFailure);




export default userRoutes;

0 comments on commit 4566a10

Please sign in to comment.