@@ -393,7 +393,7 @@ describe('Recruitment Tests', () => {
393393 'buttonTxt' ,
394394 'buttonLink'
395395 )
396- ) . rejects . toThrow ( new AccessDeniedAdminOnlyException ( 'edit guest definition' ) ) ;
396+ ) . rejects . toThrow ( new AccessDeniedAdminOnlyException ( 'edit a guest definition' ) ) ;
397397 } ) ;
398398
399399 it ( 'Fails if guest definition doesn`t exist' , async ( ) => {
@@ -409,7 +409,70 @@ describe('Recruitment Tests', () => {
409409 'buttonTxt' ,
410410 'buttonLink'
411411 )
412- ) . rejects . toThrow ( new NotFoundException ( 'Milestone' , 1 ) ) ;
412+ ) . rejects . toThrow ( new NotFoundException ( 'Guest Definition' , 'definition id' ) ) ;
413+ } ) ;
414+
415+ it ( 'Successful edit guest definition' , async ( ) => {
416+ const def = await RecruitmentServices . createGuestDefinition (
417+ superman ,
418+ organization ,
419+ 'test term' ,
420+ 'test description' ,
421+ 2 ,
422+ 'iconname' ,
423+ 'buttonTxt' ,
424+ 'buttonLink'
425+ ) ;
426+
427+ const edited = await RecruitmentServices . editGuestDefinition (
428+ await createTestUser ( batmanAppAdmin , orgId ) ,
429+ organization ,
430+ 'new term' ,
431+ 'new description' ,
432+ def . definitionId ,
433+ 4 ,
434+ 'new icon' ,
435+ 'new text' ,
436+ 'new link'
437+ ) ;
438+
439+ expect ( edited . term ) . toBe ( 'new term' ) ;
440+ expect ( edited . description ) . toBe ( 'new description' ) ;
441+ expect ( edited . order ) . toBe ( 4 ) ;
442+ expect ( edited . icon ) . toBe ( 'new icon' ) ;
443+ expect ( edited . buttonText ) . toBe ( 'new text' ) ;
444+ expect ( edited . buttonLink ) . toBe ( 'new link' ) ;
445+ } ) ;
446+
447+ it ( 'Edit guest definition fails if defintion is deleted' , async ( ) => {
448+ const def = await RecruitmentServices . createGuestDefinition (
449+ superman ,
450+ organization ,
451+ 'test term' ,
452+ 'test description' ,
453+ 2 ,
454+ 'iconname' ,
455+ 'buttonTxt' ,
456+ 'buttonLink'
457+ ) ;
458+
459+ const batman = await createTestUser ( batmanAppAdmin , orgId ) ;
460+
461+ await RecruitmentServices . deleteGuestDefinition ( batman , def . definitionId , organization ) ;
462+
463+ await expect (
464+ async ( ) =>
465+ await RecruitmentServices . editGuestDefinition (
466+ batman ,
467+ organization ,
468+ 'term' ,
469+ 'description' ,
470+ def . definitionId ,
471+ 2 ,
472+ 'buttonTxt' ,
473+ 'buttonLink'
474+ )
475+ ) . rejects . toThrow ( new DeletedException ( 'Guest Definition' , def . definitionId ) ) ;
413476 } ) ;
414477
415478 it ( 'Fails if milestone is deleted' , async ( ) => {
0 commit comments