@@ -47,27 +47,27 @@ describe('Test Invite Mutations', () => {
4747
4848 test ( 'A user can accept valid invite code' , ( ) => {
4949 return expect (
50- inviteMutations . accept ( dummyUserWithRole , 'invite-code' )
50+ inviteMutations . acceptWithCode ( dummyUserWithRole , 'invite-code' )
5151 ) . resolves . toBeInstanceOf ( Invite ) ;
5252 } ) ;
5353
5454 test ( 'A user can not accept invalid code' , ( ) => {
5555 return expect (
56- inviteMutations . accept ( dummyUserWithRole , 'invalid-invite-code' )
56+ inviteMutations . acceptWithCode ( dummyUserWithRole , 'invalid-invite-code' )
5757 ) . resolves . toHaveProperty ( 'reason' , 'Invite code not found' ) ;
5858 } ) ;
5959
6060 test ( 'A user can not accept code twice' , async ( ) => {
61- await inviteMutations . accept ( dummyUserWithRole , 'invite-code' ) ;
61+ await inviteMutations . acceptWithCode ( dummyUserWithRole , 'invite-code' ) ;
6262
6363 return expect (
64- inviteMutations . accept ( dummyUserWithRole , 'invite-code' )
64+ inviteMutations . acceptWithCode ( dummyUserWithRole , 'invite-code' )
6565 ) . resolves . toHaveProperty ( 'reason' , 'Invite code already claimed' ) ;
6666 } ) ;
6767
6868 test ( 'A user can not accept expired code' , async ( ) => {
6969 return expect (
70- inviteMutations . accept ( dummyUserWithRole , 'expired-invite-code' )
70+ inviteMutations . acceptWithCode ( dummyUserWithRole , 'expired-invite-code' )
7171 ) . resolves . toHaveProperty ( 'reason' , 'Invite code has expired' ) ;
7272 } ) ;
7373
@@ -375,4 +375,43 @@ describe('Test Invite Mutations', () => {
375375 'user-office-registration-invitation-co-proposer'
376376 ) ;
377377 } ) ;
378+
379+ test ( 'A user can accept valid co proposer invite without code' , async ( ) => {
380+ const invite = await inviteMutations . acceptCoProposerInvite (
381+ { ...dummyUserWithRole , email : 'test2@example.com' } ,
382+ 'shortCode'
383+ ) ;
384+
385+ expect ( invite ) . toBeInstanceOf ( Invite ) ;
386+ } ) ;
387+
388+ test ( 'A user can not accept co proposer invite without code if email does not match' , async ( ) => {
389+ const invite = await inviteMutations . acceptCoProposerInvite (
390+ { ...dummyUserWithRole , email : 'mismatch@example.com' } ,
391+ 'shortCode'
392+ ) ;
393+
394+ expect ( invite ) . toBeInstanceOf ( Rejection ) ;
395+ expect ( ( invite as Rejection ) . reason ) . toBe ( 'Invite not found' ) ;
396+ } ) ;
397+
398+ test ( 'A user can not accept co proposer invite without code if proposal is invalid' , async ( ) => {
399+ const invite = await inviteMutations . acceptCoProposerInvite (
400+ dummyUserWithRole ,
401+ 'invalid-short-code'
402+ ) ;
403+
404+ expect ( invite ) . toBeInstanceOf ( Rejection ) ;
405+ expect ( ( invite as Rejection ) . reason ) . toBe ( 'Proposal not found' ) ;
406+ } ) ;
407+
408+ test ( 'A user cannot accept a non existing co proposer invite for an existing proposal without code' , async ( ) => {
409+ const invite = await inviteMutations . acceptCoProposerInvite (
410+ dummyUserWithRole ,
411+ 'no-invite'
412+ ) ;
413+
414+ expect ( invite ) . toBeInstanceOf ( Rejection ) ;
415+ expect ( ( invite as Rejection ) . reason ) . toBe ( 'Invite not found' ) ;
416+ } ) ;
378417} ) ;
0 commit comments