From dde0a23bafdf9142322b14dd3c148ee5d827a8ca Mon Sep 17 00:00:00 2001 From: virgilchiriac Date: Mon, 2 Oct 2023 12:00:33 +0200 Subject: [PATCH] fix linter adds a test --- .../board/service/submission-item.service.spec.ts | 14 +++++++++++--- .../src/modules/board/uc/submission-item.uc.ts | 1 - 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/server/src/modules/board/service/submission-item.service.spec.ts b/apps/server/src/modules/board/service/submission-item.service.spec.ts index 0dd2c9efbf9..fef2bf00ae6 100644 --- a/apps/server/src/modules/board/service/submission-item.service.spec.ts +++ b/apps/server/src/modules/board/service/submission-item.service.spec.ts @@ -1,9 +1,9 @@ import { createMock, DeepMocked } from '@golevelup/ts-jest'; -import { NotFoundException } from '@nestjs/common'; +import { NotFoundException, UnprocessableEntityException } from '@nestjs/common'; import { Test, TestingModule } from '@nestjs/testing'; import { SubmissionItem } from '@shared/domain'; import { ValidationError } from '@shared/common'; -import { setupEntities, userFactory } from '@shared/testing'; +import { richTextElementFactory, setupEntities, userFactory } from '@shared/testing'; import { cardFactory, submissionContainerElementFactory, @@ -108,7 +108,7 @@ describe(SubmissionItemService.name, () => { return { submissionContainer, submissionItem }; }; - it('should fetch the SubmissionContainer parent', async () => { + it('should fetch the parent', async () => { const { submissionItem } = setup(); await service.update(submissionItem, true); @@ -116,6 +116,14 @@ describe(SubmissionItemService.name, () => { expect(boardDoRepo.findParentOfId).toHaveBeenCalledWith(submissionItem.id); }); + it('should throw if parent is not SubmissionContainerElement', async () => { + const submissionItem = submissionItemFactory.build(); + const richTextElement = richTextElementFactory.build(); + boardDoRepo.findParentOfId.mockResolvedValueOnce(richTextElement); + + await expect(service.update(submissionItem, true)).rejects.toThrow(UnprocessableEntityException); + }); + it('should call bord repo to save submission item', async () => { const { submissionItem, submissionContainer } = setup(); diff --git a/apps/server/src/modules/board/uc/submission-item.uc.ts b/apps/server/src/modules/board/uc/submission-item.uc.ts index dd788fb4011..e59afa4b49b 100644 --- a/apps/server/src/modules/board/uc/submission-item.uc.ts +++ b/apps/server/src/modules/board/uc/submission-item.uc.ts @@ -4,7 +4,6 @@ import { EntityId, isSubmissionContainerElement, isSubmissionItem, - SubmissionContainerElement, SubmissionItem, UserBoardRoles, UserRoleEnum,