Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
micners committed Mar 29, 2024
1 parent a04ef30 commit f97f053
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
DomainName,
DomainOperationReportBuilder,
OperationType,
} from '@src/modules/deletion';
} from '@modules/deletion';
import { CalendarEvent } from '../interface/calendar-event.interface';
import { CalendarMapper } from '../mapper/calendar.mapper';

Expand Down Expand Up @@ -131,10 +131,13 @@ describe('CalendarServiceSpec', () => {
});
});
describe('When calling the delete events method with scopeId which does not exist', () => {
it('should throw error if cannot delete a events', async () => {
const setup = () => {
const error = 'error';
httpService.delete.mockReturnValue(throwError(() => error));
};

it('should throw error if cannot delete a events', async () => {
setup();
await expect(service.deleteEventsByScopeId('invalid eventId')).rejects.toThrowError(
InternalServerErrorException
);
Expand Down Expand Up @@ -174,7 +177,7 @@ describe('CalendarServiceSpec', () => {
const userId: EntityId = '1';

const expectedResult = DomainDeletionReportBuilder.build(DomainName.CALENDAR, [
DomainOperationReportBuilder.build(OperationType.DELETE, Number.NaN, [userId]),
DomainOperationReportBuilder.build(OperationType.DELETE, 0, [userId]),
]);

return {
Expand Down
6 changes: 3 additions & 3 deletions apps/server/src/infra/calendar/service/calendar.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
OperationType,
StatusModel,
UserDeletedEvent,
} from '@src/modules/deletion';
} from '@modules/deletion';
import { EntityId } from '@shared/domain/types';
import { CalendarEventDto } from '../dto/calendar-event.dto';
import { CalendarEvent } from '../interface/calendar-event.interface';
Expand Down Expand Up @@ -63,7 +63,7 @@ export class CalendarService implements DeletionService, IEventHandler<UserDelet
await this.deleteEventsByScopeId(userId);

const result = DomainDeletionReportBuilder.build(DomainName.CALENDAR, [
DomainOperationReportBuilder.build(OperationType.DELETE, Number.NaN, [userId]),
DomainOperationReportBuilder.build(OperationType.DELETE, 0, [userId]),
]);

this.logger.info(
Expand All @@ -73,7 +73,7 @@ export class CalendarService implements DeletionService, IEventHandler<UserDelet
userId,
StatusModel.FINISHED,
0,
Number.NaN
0
)
);

Expand Down

0 comments on commit f97f053

Please sign in to comment.