Skip to content

Commit 0ea4b83

Browse files
committed
#1521: Added Doc comment for method and fixed test
1 parent 6689782 commit 0ea4b83

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

src/backend/src/services/projects.services.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,13 @@ export default class ProjectsService {
603603
).map(linkTypeTransformer);
604604
}
605605

606+
/**
607+
* Creates a new Manufacturer
608+
* @param submitter the user who's creating the manufacturer
609+
* @param name the name of the manufacturer
610+
* @returns the newly created manufacturer
611+
* @throws if the submitter is a guest or the given manufacturer name already exists
612+
*/
606613
static async createManufacturer(submitter: User, name: string) {
607614
if (isGuest(submitter.role)) throw new AccessDeniedGuestException('create manufacturers');
608615

@@ -612,7 +619,7 @@ export default class ProjectsService {
612619
}
613620
});
614621

615-
if (!!manufacturer) throw new HttpException(400, `${name} already exists as a manufacturer!`);
622+
if (manufacturer) throw new HttpException(400, `${name} already exists as a manufacturer!`);
616623

617624
const newManufacturer = await prisma.manufacturer.create({
618625
data: { name, dateCreated: new Date(), creatorId: submitter.userId }

src/backend/tests/projects.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ describe('Projects', () => {
262262
});
263263

264264
test('createManufacturer throws an error if manufacturer already exists', async () => {
265-
vi.spyOn(prisma.manufacturer, 'create').mockResolvedValue(prismaManufacturer1);
265+
vi.spyOn(prisma.manufacturer, 'findUnique').mockResolvedValue(prismaManufacturer1);
266266

267267
await expect(ProjectsService.createManufacturer(batman, 'Manufacturer1')).rejects.toThrow(
268268
new HttpException(400, 'Manufacturer1 already exists as a manufacturer!')

0 commit comments

Comments
 (0)