diff --git a/__test__/cart.test.ts b/__test__/cart.test.ts index 418f085..e5b12f7 100644 --- a/__test__/cart.test.ts +++ b/__test__/cart.test.ts @@ -8,6 +8,8 @@ import User from "../src/sequelize/models/users"; import bcrypt from "bcrypt"; import { Role } from "../src/sequelize/models/roles"; import { dummy } from "./prod"; +import * as userServices from "../src/services/user.service" +import { number } from "joi"; const queryInterface = sequelize.getQueryInterface(); @@ -86,7 +88,8 @@ describe("testing cart", () => { // console.log("response 3--->", res3); sellerToken = res3.body.token; - sellerId = res3.body.userInfo?.id; + const seller = await userServices.getUserByEmail("seller123@example.com"); + const sellerId = seller?.id; await request(app) .patch(`/api/v1/users/${sellerId}/role`) diff --git a/__test__/payment.test.ts b/__test__/payment.test.ts index 4dc8e40..0070c7e 100644 --- a/__test__/payment.test.ts +++ b/__test__/payment.test.ts @@ -8,11 +8,12 @@ import User from "../src/sequelize/models/users"; import bcrypt from "bcryptjs"; import { Role } from "../src/sequelize/models/roles"; import { dummy } from "./prod"; +import * as userServive from "../src/services/user.service" let buyerToken: any; let adminToken: any; let sellerToken: any; -let sellerId: number; + describe("test stripe api payment", () => { beforeAll(async () => { @@ -79,8 +80,11 @@ describe("test stripe api payment", () => { email: "seller123@example.com", password: "password", }); + + const seller = await userServive.getUserByEmail("seller123@example.com"); sellerToken = sellerResponse.body.token; - sellerId = sellerResponse.body.userInfo?.id; + + let sellerId = seller?.id; await request(app) .patch(`/api/v1/users/${sellerId}/role`) diff --git a/__test__/product.test.ts b/__test__/product.test.ts index 569a478..5b95c9e 100644 --- a/__test__/product.test.ts +++ b/__test__/product.test.ts @@ -15,6 +15,7 @@ import { placeOrder } from "../src/services/payment.service"; import Cart from "../src/sequelize/models/Cart"; import CartItem from "../src/sequelize/models/CartItem"; import OrderItem from "../src/sequelize/models/orderItems"; +import * as userService from "../src/services/user.service" const userData: any = { name: "yvanna", @@ -137,7 +138,9 @@ describe("Testing product Routes", () => { }); expect(logDummySeller.status).toBe(200); token = logDummySeller.body.token; - const dummySellerId = logDummySeller.body.userInfo.id; + + const seller = await userService.getUserByEmail(dummySeller.email) + const dummySellerId = seller?.id; const response = await request(app) .patch(`/api/v1/users/${dummySellerId}/role`) diff --git a/__test__/user.test.ts b/__test__/user.test.ts index 9939a2e..08f7bdd 100644 --- a/__test__/user.test.ts +++ b/__test__/user.test.ts @@ -219,7 +219,8 @@ describe("Testing user Routes", () => { password: dummySeller.password, }); expect(logDummySeller.status).toBe(200); - const dummySellerId = logDummySeller.body.userInfo.id; + const seller = await userServices.getUserByEmail(dummySeller.email); + const dummySellerId = seller?.id; const response = await request(app) .patch(`/api/v1/users/${dummySellerId}/role`) diff --git a/src/controllers/userControllers.ts b/src/controllers/userControllers.ts index 4947f6a..d81cb4d 100644 --- a/src/controllers/userControllers.ts +++ b/src/controllers/userControllers.ts @@ -84,7 +84,6 @@ export const userLogin = async (req: Request, res: Response) => { return res.status(200).json({ status: 200, message: "Logged in", - userInfo: userInfo, token: accessToken }); }