From a6be3efcb1717bec01f02142156e52a23482368b Mon Sep 17 00:00:00 2001 From: Peco1503 <102172862+Peco1503@users.noreply.github.com> Date: Fri, 14 Jun 2024 23:04:41 -0600 Subject: [PATCH] Added tests --- tests/educationService.test.ts | 23 +++++++++++++++++++++++ tests/profileService.test.ts | 11 +++++++++++ 2 files changed, 34 insertions(+) diff --git a/tests/educationService.test.ts b/tests/educationService.test.ts index ced638a..5aaa4f4 100644 --- a/tests/educationService.test.ts +++ b/tests/educationService.test.ts @@ -131,4 +131,27 @@ describe('Education Services', () => { // Verify the method was called correctly expect(prisma.education.findMany).toHaveBeenCalledWith(); }); + + test('findEducationById should return an education record', async () => { + const mockEducationId = '1'; + const mockEducation = { + education_id: mockEducationId, + school: 'Tec de Monterrey', + education_degree: 'Computer Science', + gpa: 4.0, + start_date: new Date('2024-04-01'), + end_date: new Date('2027-06-01'), + relevant_coursework: 'Sample Coursework' + }; + + // Perform the function call + const education = await educationService.findEducationById(mockEducationId); + + // Check that the returned value matches the expected mock value + expect(education).toEqual(mockEducation); + // Verify the method was called correctly + expect(prisma.education.findUnique).toHaveBeenCalledWith({ + where: { education_id: mockEducationId }, + }); + }); }); diff --git a/tests/profileService.test.ts b/tests/profileService.test.ts index 5aa2733..f82e71c 100644 --- a/tests/profileService.test.ts +++ b/tests/profileService.test.ts @@ -116,4 +116,15 @@ describe('Profile Service Tests', () => { where: { profile_id: profileId }, }); }); + + test('deleteProfile should return null if profile does not exist', async () => { + const profileId = 'profile3'; + + const profile = await deleteProfile(profileId); + + expect(profile).toBeNull(); + expect(prisma.profile.delete).toHaveBeenCalledWith({ + where: { profile_id: profileId }, + }); + }); });