From 8463bb228d9eb8200ff8634e6ce16b4a89c32693 Mon Sep 17 00:00:00 2001 From: Janith Lahiru Kariyawasam <88109775+janithlahirukariyawasam@users.noreply.github.com> Date: Tue, 16 Jan 2024 22:41:36 +0530 Subject: [PATCH] Update auth.service.test.ts --- src/services/auth.service.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/services/auth.service.test.ts b/src/services/auth.service.test.ts index fecffeeb..2eb8e88d 100644 --- a/src/services/auth.service.test.ts +++ b/src/services/auth.service.test.ts @@ -2,9 +2,12 @@ import { registerUser, loginUser } from './auth.service' import { dataSource } from '../configs/dbConfig' jest.mock('bcrypt', () => ({ - hash: jest.fn((password) => Promise.resolve(`hashed_${password}`)), - compare: jest.fn((password, hashedPassword) => - Promise.resolve(password === hashedPassword) + hash: jest.fn( + async (password) => await Promise.resolve(`hashed_${password}`) + ), + compare: jest.fn( + async (password, hashedPassword) => + await Promise.resolve(password === hashedPassword) ) })) @@ -23,7 +26,7 @@ describe('registerUser', () => { const mockProfileRepository = { findOne: jest.fn().mockResolvedValue(null), create: jest.fn((data) => data), - save: jest.fn((profile) => Promise.resolve(profile)) + save: jest.fn(async (profile) => await Promise.resolve(profile)) } ;(dataSource.getRepository as jest.Mock).mockReturnValueOnce(