File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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!' )
You can’t perform that action at this time.
0 commit comments