Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
adds a test
  • Loading branch information
virgilchiriac committed Oct 2, 2023
1 parent 5249ee2 commit dde0a23
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -108,14 +108,22 @@ 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);

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();

Expand Down
1 change: 0 additions & 1 deletion apps/server/src/modules/board/uc/submission-item.uc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
EntityId,
isSubmissionContainerElement,
isSubmissionItem,
SubmissionContainerElement,
SubmissionItem,
UserBoardRoles,
UserRoleEnum,
Expand Down

0 comments on commit dde0a23

Please sign in to comment.