From 1147eb8af12427583443f625f9906f789bb3fb34 Mon Sep 17 00:00:00 2001 From: Frosco03 Date: Fri, 26 Jul 2024 16:02:37 +0800 Subject: [PATCH 1/7] added parameters to userById query --- api_v2/src/graphql/graphql.ts | 2 +- api_v2/src/graphql/schema.gql | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_v2/src/graphql/graphql.ts b/api_v2/src/graphql/graphql.ts index a4fad208..df38ac03 100644 --- a/api_v2/src/graphql/graphql.ts +++ b/api_v2/src/graphql/graphql.ts @@ -802,7 +802,7 @@ export class Project { export abstract class IQuery { abstract getHello(): string | Promise; - abstract userById(): Nullable | Promise>; + abstract userById(id: number): Nullable | Promise>; abstract userByEmail(email: string): Nullable | Promise>; diff --git a/api_v2/src/graphql/schema.gql b/api_v2/src/graphql/schema.gql index c46f2a4f..f086c077 100644 --- a/api_v2/src/graphql/schema.gql +++ b/api_v2/src/graphql/schema.gql @@ -525,7 +525,7 @@ type Project { type Query { getHello: String! - userById: UserDTO + userById(id: Int!): UserDTO userByEmail(email: String!): UserDTO allUsers: [User!]! allESLUsers(exceptUserId: Int): [User!]! From d9125caa2c56a3ef1764f88cfbd50eaeb8e949c4 Mon Sep 17 00:00:00 2001 From: Frosco03 Date: Fri, 26 Jul 2024 16:05:55 +0800 Subject: [PATCH 2/7] Time sheet migration to nestjs --- api_v2/src/app.module.ts | 2 + api_v2/src/time-record/time-record.module.ts | 9 ++ .../time-record/time-record.resolver.spec.ts | 25 ++++ .../src/time-record/time-record.resolver.ts | 33 +++++ .../time-record/time-record.service.spec.ts | 21 +++ api_v2/src/time-record/time-record.service.ts | 125 ++++++++++++++++++ api_v2/src/types/time-record.types.ts | 12 ++ 7 files changed, 227 insertions(+) create mode 100644 api_v2/src/time-record/time-record.module.ts create mode 100644 api_v2/src/time-record/time-record.resolver.spec.ts create mode 100644 api_v2/src/time-record/time-record.resolver.ts create mode 100644 api_v2/src/time-record/time-record.service.spec.ts create mode 100644 api_v2/src/time-record/time-record.service.ts create mode 100644 api_v2/src/types/time-record.types.ts diff --git a/api_v2/src/app.module.ts b/api_v2/src/app.module.ts index 619f5e5b..fdc34e88 100644 --- a/api_v2/src/app.module.ts +++ b/api_v2/src/app.module.ts @@ -24,6 +24,7 @@ import { graphqlUploadExpress } from 'graphql-upload-ts'; import { WorkInterruptionModule } from './work-interruption/work-interruption.module'; import { APP_GUARD } from '@nestjs/core'; import { PositionsGuard } from './guards/position.guard'; +import { TimeRecordModule } from './time-record/time-record.module'; @Module({ imports: [ @@ -80,6 +81,7 @@ import { PositionsGuard } from './guards/position.guard'; LogoutModule, FileUploadModule, WorkInterruptionModule, + TimeRecordModule, ], controllers: [AppController], providers: [ diff --git a/api_v2/src/time-record/time-record.module.ts b/api_v2/src/time-record/time-record.module.ts new file mode 100644 index 00000000..8713891e --- /dev/null +++ b/api_v2/src/time-record/time-record.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { TimeRecordResolver } from './time-record.resolver'; +import { TimeRecordService } from './time-record.service'; +import { PrismaService } from '@/prisma/prisma.service'; + +@Module({ + providers: [TimeRecordResolver, TimeRecordService, PrismaService] +}) +export class TimeRecordModule {} diff --git a/api_v2/src/time-record/time-record.resolver.spec.ts b/api_v2/src/time-record/time-record.resolver.spec.ts new file mode 100644 index 00000000..54191262 --- /dev/null +++ b/api_v2/src/time-record/time-record.resolver.spec.ts @@ -0,0 +1,25 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { TimeRecordResolver } from './time-record.resolver'; +import { TimeRecordService } from './time-record.service'; + +describe('TimeRecordResolver', () => { + let resolver: TimeRecordResolver; + const mockTimeRecordService = { + getTimeEntriesById : jest.fn() + }; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [TimeRecordResolver, TimeRecordService], + }) + .overrideProvider(TimeRecordService) + .useValue(mockTimeRecordService) + .compile(); + + resolver = module.get(TimeRecordResolver); + }); + + it('should be defined', () => { + expect(resolver).toBeDefined(); + }); +}); diff --git a/api_v2/src/time-record/time-record.resolver.ts b/api_v2/src/time-record/time-record.resolver.ts new file mode 100644 index 00000000..fbe4c26a --- /dev/null +++ b/api_v2/src/time-record/time-record.resolver.ts @@ -0,0 +1,33 @@ +import { TimeEntryDTO, UserDTO } from '@/graphql/graphql'; +import { Args, Query, Resolver } from '@nestjs/graphql'; +import { TimeRecordService } from './time-record.service'; + +@Resolver('TimeEntry') +export class TimeRecordResolver { + constructor( + private readonly timeRecordService: TimeRecordService, + ){} + + /** + * Handles the GET_EMPLOYEE_TIMESHEET request. + * + * @param {number} id - The user ID. + * @returns {Promise} The list of time entries. + */ + @Query(() => [TimeEntryDTO]) + async timeEntriesByEmployeeId(@Args('id') id: number): Promise{ + return await this.timeRecordService.getTimeEntriesById(id); + } + + /** + * Handles the GET_USER_QUERY request. + * + * @param {ShowInterruptionRequestInput} interruption - The input for fetching interruptions. + * @returns {Promise} The list of work interruptions. + */ + // + @Query(() => UserDTO) + async userById(@Args('id') id: number): Promise{ + return await this.timeRecordService.getUserById(id); + } +} diff --git a/api_v2/src/time-record/time-record.service.spec.ts b/api_v2/src/time-record/time-record.service.spec.ts new file mode 100644 index 00000000..984a61d6 --- /dev/null +++ b/api_v2/src/time-record/time-record.service.spec.ts @@ -0,0 +1,21 @@ +import { Test, TestingModule } from '@nestjs/testing'; +import { TimeRecordService } from './time-record.service'; +import { PrismaService } from '@/prisma/prisma.service'; +import { TimeRecordResolver } from './time-record.resolver'; + +describe('TimeRecordService', () => { + let service: TimeRecordService; + const mockPrismaService = {}; + + beforeEach(async () => { + const module: TestingModule = await Test.createTestingModule({ + providers: [TimeRecordService, PrismaService, TimeRecordResolver], + }).overrideProvider(PrismaService).useValue(mockPrismaService).compile(); + + service = module.get(TimeRecordService); + }); + + it('should be defined', () => { + expect(service).toBeDefined(); + }); +}); diff --git a/api_v2/src/time-record/time-record.service.ts b/api_v2/src/time-record/time-record.service.ts new file mode 100644 index 00000000..068f46a3 --- /dev/null +++ b/api_v2/src/time-record/time-record.service.ts @@ -0,0 +1,125 @@ +import { WorkStatusEnum } from '@/enums/work-status.enum'; +import { TimeEntryDTO, User, UserDTO } from '@/graphql/graphql'; +import { PrismaService } from '@/prisma/prisma.service'; +import { Injectable } from '@nestjs/common'; +import { TimeEntriesWithRelations } from '@/types/time-record.types'; + +@Injectable() +export class TimeRecordService { + constructor(private prisma: PrismaService){} + + async getTimeEntriesById(id: number): Promise { + const timeEntries: TimeEntriesWithRelations[] = await this.prisma.timeEntry.findMany({ + where: { + userId: id + }, + include: { + user: true, + workInterruptions: true, + eslChangeShiftRequests: true, + eslOffsets: true, + timeIn: true, + timeOut: true, + } + }); + + return timeEntries.map(timeEntry => this.mapTimesheet(timeEntry)); + } + + /** + * Maps a single employee timesheet from the database model to the DTO. + * + * @param {WorkInterruption} interruption - The work interruption object from the database. + * @returns {WorkInterruptionDTO} The mapped work interruption DTO. + */ + private mapTimesheet(timeEntry: any): TimeEntryDTO{ + + let workStatus, late = 0; + //let undertime = 0; + if(timeEntry.timeIn){ + workStatus = WorkStatusEnum.ONDUTY; + late = timeEntry.timeIn.timeHour - timeEntry.startTime; + //undertime = timeEntry.timeOut.timeHour - timeEntry.endTime; + } + else{ + workStatus = WorkStatusEnum.ABSENT + } + + const mappedTimesheet: TimeEntryDTO = { + user: timeEntry.user, + startTime: timeEntry.startTime ? + timeEntry.startTime.toISOString().slice(11, 19) + : null, + endTime: timeEntry.endTime ? + timeEntry.endTime.toISOString().slice(11, 19) + : null, + workedHours: timeEntry.workedHours || null, + trackedHours: timeEntry.trackedHours || null, + timeIn: timeEntry.timeIn || null, + timeOut: timeEntry.timeOut || null, + date: timeEntry.date, + late: late, + undertime: 0, //TODO add logic here maybe time out - endtime (something like that) + eslChangeShift: timeEntry.eslChangeShiftRequests.length === 0 ? + null + : timeEntry.eslChangeShiftRequests, + status: workStatus, + isLeaderApproved: timeEntry.overtime?.isLeaderApproved || null, + changeShift: timeEntry.changeShiftRequest || null, + id: timeEntry.id, + userId: timeEntry.userId, + timeInId: timeEntry.timeInId || null, + timeOutId: timeEntry.timeOutId || null, + breakStartTime: timeEntry.breakStartTime, + breakEndTime: timeEntry.breakEndTime, + overtime: timeEntry.overtime || null, + changeShiftRequest: timeEntry.changeShiftRequest || null, + workInterruptions: timeEntry.workInterruptions, + eslOffsets: timeEntry.eslOffsets || null, + createdAt: timeEntry.createdAt || null, + updatedAt: timeEntry.updatedAt || null + }; + + return mappedTimesheet; + } + + async getUserById(id: number): Promise{ + const user = await this.prisma.user.findUnique({ + where: { + id: id + }, + include: { + role: true, + position: true, + timeEntries: true, + employeeSchedule: true, + } + }); + + return this.mapUser(user as User); + } + + private mapUser(user: User): UserDTO{ + const mappedUser: UserDTO = { + id: user.id, + name: user.name, + email: user.email, + profileImageId: user.profileImageId, + profileImage: user.profileImage, + roleId: user.roleId, + positionId: user.positionId, + employeeScheduleId: user.employeeScheduleId, + paidLeaves: user.paidLeaves, + isOnline: user.isOnline, + role: user.role, + position: user.position, + employeeSchedule: user.employeeSchedule, + timeEntries: user.timeEntries, + overtimes: user.overtimes, + createdAt: user.createdAt, + updatedAt: user.updatedAt + } + + return mappedUser; + } +} diff --git a/api_v2/src/types/time-record.types.ts b/api_v2/src/types/time-record.types.ts new file mode 100644 index 00000000..90af4296 --- /dev/null +++ b/api_v2/src/types/time-record.types.ts @@ -0,0 +1,12 @@ +import { Prisma } from '@prisma/client' + +export type TimeEntriesWithRelations = Prisma.TimeEntryGetPayload<{ + include: { + user: true, + workInterruptions: true, + eslChangeShiftRequests: true, + eslOffsets: true, + timeIn: true, + timeOut: true, + } +}>; \ No newline at end of file From 33553e7b7e4fc033d1db6f3582744244767dfb04 Mon Sep 17 00:00:00 2001 From: "sunasterisk.jejercito" Date: Fri, 26 Jul 2024 19:50:20 +0800 Subject: [PATCH 3/7] added documentation --- api_v2/src/time-record/time-record.resolver.ts | 4 ++-- api_v2/src/time-record/time-record.service.ts | 17 +++++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/api_v2/src/time-record/time-record.resolver.ts b/api_v2/src/time-record/time-record.resolver.ts index fbe4c26a..149f50e6 100644 --- a/api_v2/src/time-record/time-record.resolver.ts +++ b/api_v2/src/time-record/time-record.resolver.ts @@ -22,8 +22,8 @@ export class TimeRecordResolver { /** * Handles the GET_USER_QUERY request. * - * @param {ShowInterruptionRequestInput} interruption - The input for fetching interruptions. - * @returns {Promise} The list of work interruptions. + * @param {number} id - The user ID input. + * @returns {Promise} User information. */ // @Query(() => UserDTO) diff --git a/api_v2/src/time-record/time-record.service.ts b/api_v2/src/time-record/time-record.service.ts index 068f46a3..97216e18 100644 --- a/api_v2/src/time-record/time-record.service.ts +++ b/api_v2/src/time-record/time-record.service.ts @@ -29,17 +29,16 @@ export class TimeRecordService { /** * Maps a single employee timesheet from the database model to the DTO. * - * @param {WorkInterruption} interruption - The work interruption object from the database. - * @returns {WorkInterruptionDTO} The mapped work interruption DTO. + * @param {TimeEntry} timeEntry - The timeEntry object from the database. + * @returns {TimeEntryDTO} The mapped Time Entry DTO. */ private mapTimesheet(timeEntry: any): TimeEntryDTO{ - let workStatus, late = 0; - //let undertime = 0; + let workStatus, late = 0, undertime = 0; if(timeEntry.timeIn){ workStatus = WorkStatusEnum.ONDUTY; late = timeEntry.timeIn.timeHour - timeEntry.startTime; - //undertime = timeEntry.timeOut.timeHour - timeEntry.endTime; + undertime = timeEntry.timeOut.timeHour - timeEntry.endTime; } else{ workStatus = WorkStatusEnum.ABSENT @@ -59,7 +58,7 @@ export class TimeRecordService { timeOut: timeEntry.timeOut || null, date: timeEntry.date, late: late, - undertime: 0, //TODO add logic here maybe time out - endtime (something like that) + undertime: undertime, eslChangeShift: timeEntry.eslChangeShiftRequests.length === 0 ? null : timeEntry.eslChangeShiftRequests, @@ -99,6 +98,12 @@ export class TimeRecordService { return this.mapUser(user as User); } + /** + * Maps a single user object from the database model to the DTO. + * + * @param {User} user - The user object from the database. + * @returns {UserDTO} The mapped User DTO. + */ private mapUser(user: User): UserDTO{ const mappedUser: UserDTO = { id: user.id, From 70e714d32c001673bf2823d10edac6e6ff22ab21 Mon Sep 17 00:00:00 2001 From: "sunasterisk.jejercito" Date: Mon, 29 Jul 2024 11:22:55 +0800 Subject: [PATCH 4/7] fixed negative minute values --- api_v2/src/time-record/time-record.service.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/api_v2/src/time-record/time-record.service.ts b/api_v2/src/time-record/time-record.service.ts index 97216e18..eb492b3a 100644 --- a/api_v2/src/time-record/time-record.service.ts +++ b/api_v2/src/time-record/time-record.service.ts @@ -37,8 +37,9 @@ export class TimeRecordService { let workStatus, late = 0, undertime = 0; if(timeEntry.timeIn){ workStatus = WorkStatusEnum.ONDUTY; - late = timeEntry.timeIn.timeHour - timeEntry.startTime; - undertime = timeEntry.timeOut.timeHour - timeEntry.endTime; + //Times are in milliseconds + late = Math.max(0, (timeEntry.startTime - timeEntry.timeIn.timeHour) / 60000); + undertime = Math.max(0, (timeEntry.endTime - timeEntry.timeOut.timeHour) / 60000); } else{ workStatus = WorkStatusEnum.ABSENT @@ -107,10 +108,10 @@ export class TimeRecordService { private mapUser(user: User): UserDTO{ const mappedUser: UserDTO = { id: user.id, - name: user.name, - email: user.email, - profileImageId: user.profileImageId, - profileImage: user.profileImage, + name: user.name || null, + email: user.email || null, + profileImageId: user.profileImageId || null, + profileImage: user.profileImage || null, roleId: user.roleId, positionId: user.positionId, employeeScheduleId: user.employeeScheduleId, @@ -120,7 +121,7 @@ export class TimeRecordService { position: user.position, employeeSchedule: user.employeeSchedule, timeEntries: user.timeEntries, - overtimes: user.overtimes, + overtimes: user.overtimes || [], createdAt: user.createdAt, updatedAt: user.updatedAt } From a6b8e5aaee46dd28a4626e932d1a0e291d8bfaaa Mon Sep 17 00:00:00 2001 From: "sunasterisk.jejercito" Date: Mon, 29 Jul 2024 13:46:30 +0800 Subject: [PATCH 5/7] service optimizations --- api_v2/src/time-record/time-record.service.ts | 46 ++----------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/api_v2/src/time-record/time-record.service.ts b/api_v2/src/time-record/time-record.service.ts index eb492b3a..ef44fbd9 100644 --- a/api_v2/src/time-record/time-record.service.ts +++ b/api_v2/src/time-record/time-record.service.ts @@ -46,38 +46,15 @@ export class TimeRecordService { } const mappedTimesheet: TimeEntryDTO = { - user: timeEntry.user, - startTime: timeEntry.startTime ? - timeEntry.startTime.toISOString().slice(11, 19) - : null, - endTime: timeEntry.endTime ? - timeEntry.endTime.toISOString().slice(11, 19) - : null, - workedHours: timeEntry.workedHours || null, - trackedHours: timeEntry.trackedHours || null, - timeIn: timeEntry.timeIn || null, - timeOut: timeEntry.timeOut || null, - date: timeEntry.date, + ...timeEntry, + startTime: timeEntry.startTime.toISOString().slice(11, 19), + endTime: timeEntry.endTime.toISOString().slice(11, 19), late: late, undertime: undertime, eslChangeShift: timeEntry.eslChangeShiftRequests.length === 0 ? null : timeEntry.eslChangeShiftRequests, status: workStatus, - isLeaderApproved: timeEntry.overtime?.isLeaderApproved || null, - changeShift: timeEntry.changeShiftRequest || null, - id: timeEntry.id, - userId: timeEntry.userId, - timeInId: timeEntry.timeInId || null, - timeOutId: timeEntry.timeOutId || null, - breakStartTime: timeEntry.breakStartTime, - breakEndTime: timeEntry.breakEndTime, - overtime: timeEntry.overtime || null, - changeShiftRequest: timeEntry.changeShiftRequest || null, - workInterruptions: timeEntry.workInterruptions, - eslOffsets: timeEntry.eslOffsets || null, - createdAt: timeEntry.createdAt || null, - updatedAt: timeEntry.updatedAt || null }; return mappedTimesheet; @@ -107,23 +84,8 @@ export class TimeRecordService { */ private mapUser(user: User): UserDTO{ const mappedUser: UserDTO = { - id: user.id, - name: user.name || null, - email: user.email || null, - profileImageId: user.profileImageId || null, - profileImage: user.profileImage || null, - roleId: user.roleId, - positionId: user.positionId, - employeeScheduleId: user.employeeScheduleId, - paidLeaves: user.paidLeaves, - isOnline: user.isOnline, - role: user.role, - position: user.position, - employeeSchedule: user.employeeSchedule, - timeEntries: user.timeEntries, + ...user, overtimes: user.overtimes || [], - createdAt: user.createdAt, - updatedAt: user.updatedAt } return mappedUser; From 9dd30e8b548eb4b442c217944f7f6e9aaec64743 Mon Sep 17 00:00:00 2001 From: "sunasterisk.jejercito" Date: Tue, 30 Jul 2024 12:42:14 +0800 Subject: [PATCH 6/7] created unit tests --- .../time-record/time-record.resolver.spec.ts | 31 ++++++++--- .../time-record/time-record.service.spec.ts | 54 ++++++++++++++++++- 2 files changed, 76 insertions(+), 9 deletions(-) diff --git a/api_v2/src/time-record/time-record.resolver.spec.ts b/api_v2/src/time-record/time-record.resolver.spec.ts index 54191262..10024d01 100644 --- a/api_v2/src/time-record/time-record.resolver.spec.ts +++ b/api_v2/src/time-record/time-record.resolver.spec.ts @@ -4,17 +4,18 @@ import { TimeRecordService } from './time-record.service'; describe('TimeRecordResolver', () => { let resolver: TimeRecordResolver; - const mockTimeRecordService = { - getTimeEntriesById : jest.fn() + let mockTimeRecordService = { + getUserById: jest.fn().mockResolvedValue({id: 1, name: 'Abdul Jalil Palala'}), + getTimeEntriesById: jest.fn().mockResolvedValue({startTime: "09:30:00"}), }; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [TimeRecordResolver, TimeRecordService], - }) - .overrideProvider(TimeRecordService) - .useValue(mockTimeRecordService) - .compile(); + providers: [TimeRecordResolver, { + provide: TimeRecordService, + useValue: mockTimeRecordService + }], + }).compile(); resolver = module.get(TimeRecordResolver); }); @@ -22,4 +23,20 @@ describe('TimeRecordResolver', () => { it('should be defined', () => { expect(resolver).toBeDefined(); }); + + describe('userById', () => { + it('should call the service to get user', async () => { + const result = await resolver.userById(1); + + expect(result).toEqual({id: 1, name: 'Abdul Jalil Palala'}); + }); + }); + + describe('timeEntriesByEmployeeId', () => { + it('should call the service to get time entries', async () => { + const result = await resolver.timeEntriesByEmployeeId(1); + + expect(result).toEqual({startTime: "09:30:00"}); + }); + }); }); diff --git a/api_v2/src/time-record/time-record.service.spec.ts b/api_v2/src/time-record/time-record.service.spec.ts index 984a61d6..ad210013 100644 --- a/api_v2/src/time-record/time-record.service.spec.ts +++ b/api_v2/src/time-record/time-record.service.spec.ts @@ -5,17 +5,67 @@ import { TimeRecordResolver } from './time-record.resolver'; describe('TimeRecordService', () => { let service: TimeRecordService; - const mockPrismaService = {}; + let prismaService: PrismaService; + + const mockPrismaService = { + user: { + findUnique: jest.fn(), + }, + timeEntry: { + findMany: jest.fn(), + }, + }; beforeEach(async () => { const module: TestingModule = await Test.createTestingModule({ - providers: [TimeRecordService, PrismaService, TimeRecordResolver], + providers: [TimeRecordService, TimeRecordResolver, {provide: PrismaService, useValue: mockPrismaService}], }).overrideProvider(PrismaService).useValue(mockPrismaService).compile(); service = module.get(TimeRecordService); + prismaService = module.get(PrismaService); }); it('should be defined', () => { expect(service).toBeDefined(); }); + + describe('getUserById', () => { + it('should return an object of user information', async () => { + const result = { + id: 1, + name: "Abdul Jalil Palala", + email: "abduljalil.palala@sun-asterisk.com", + overtimes: new Array, + }; + + (jest.spyOn(prismaService.user, 'findUnique') as jest.Mock).mockResolvedValue(result); + + expect(await service.getUserById(1)).toEqual(result); + }); + }); + + describe('getTimeEntriesById', () => { + it('should return an array of time entries', async () => { + const queryResult = [{ + id: 1, + workedHours: "08:00", + startTime: new Date, + endTime: new Date, + eslChangeShiftRequests: [], + }]; + + (jest.spyOn(prismaService.timeEntry, 'findMany') as jest.Mock).mockResolvedValue(queryResult); + + const result = { + id: 1, + workedHours: "08:00", + }; + + expect(await service.getTimeEntriesById(1)).toEqual( + expect.arrayContaining([ + expect.objectContaining(result) + ]) + ); + }); + }); }); From 0e893c5bec06d69dba27c2b8fce0865ce39620d8 Mon Sep 17 00:00:00 2001 From: "sunasterisk.jejercito" Date: Tue, 30 Jul 2024 12:44:30 +0800 Subject: [PATCH 7/7] test fixes for eslint --- api_v2/src/time-record/time-record.resolver.spec.ts | 2 +- api_v2/src/time-record/time-record.service.spec.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api_v2/src/time-record/time-record.resolver.spec.ts b/api_v2/src/time-record/time-record.resolver.spec.ts index 10024d01..1b4a86f7 100644 --- a/api_v2/src/time-record/time-record.resolver.spec.ts +++ b/api_v2/src/time-record/time-record.resolver.spec.ts @@ -4,7 +4,7 @@ import { TimeRecordService } from './time-record.service'; describe('TimeRecordResolver', () => { let resolver: TimeRecordResolver; - let mockTimeRecordService = { + const mockTimeRecordService = { getUserById: jest.fn().mockResolvedValue({id: 1, name: 'Abdul Jalil Palala'}), getTimeEntriesById: jest.fn().mockResolvedValue({startTime: "09:30:00"}), }; diff --git a/api_v2/src/time-record/time-record.service.spec.ts b/api_v2/src/time-record/time-record.service.spec.ts index ad210013..a233867c 100644 --- a/api_v2/src/time-record/time-record.service.spec.ts +++ b/api_v2/src/time-record/time-record.service.spec.ts @@ -35,7 +35,7 @@ describe('TimeRecordService', () => { id: 1, name: "Abdul Jalil Palala", email: "abduljalil.palala@sun-asterisk.com", - overtimes: new Array, + overtimes: [], }; (jest.spyOn(prismaService.user, 'findUnique') as jest.Mock).mockResolvedValue(result);