@@ -1180,6 +1180,90 @@ describe('mutation acceptOpportunityMatch', () => {
11801180 } ) ;
11811181} ) ;
11821182
1183+ describe ( 'mutation rejectOpportunityMatch' , ( ) => {
1184+ const MUTATION = /* GraphQL */ `
1185+ mutation RejectOpportunityMatch($id: ID!) {
1186+ rejectOpportunityMatch(id: $id) {
1187+ _
1188+ }
1189+ }
1190+ ` ;
1191+
1192+ it ( 'should require authentication' , async ( ) => {
1193+ await testMutationErrorCode (
1194+ client ,
1195+ {
1196+ mutation : MUTATION ,
1197+ variables : {
1198+ id : '550e8400-e29b-41d4-a716-446655440001' ,
1199+ } ,
1200+ } ,
1201+ 'UNAUTHENTICATED' ,
1202+ ) ;
1203+ } ) ;
1204+
1205+ it ( 'should accept opportunity match for authenticated user' , async ( ) => {
1206+ loggedUser = '1' ;
1207+
1208+ expect (
1209+ await con . getRepository ( OpportunityMatch ) . countBy ( {
1210+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1211+ userId : '1' ,
1212+ status : OpportunityMatchStatus . Pending ,
1213+ } ) ,
1214+ ) . toEqual ( 1 ) ;
1215+
1216+ const res = await client . mutate ( MUTATION , {
1217+ variables : {
1218+ id : '550e8400-e29b-41d4-a716-446655440001' ,
1219+ } ,
1220+ } ) ;
1221+
1222+ expect ( res . errors ) . toBeFalsy ( ) ;
1223+ expect ( res . data . rejectOpportunityMatch ) . toEqual ( { _ : true } ) ;
1224+
1225+ expect (
1226+ await con . getRepository ( OpportunityMatch ) . countBy ( {
1227+ opportunityId : '550e8400-e29b-41d4-a716-446655440001' ,
1228+ userId : '1' ,
1229+ status : OpportunityMatchStatus . CandidateRejected ,
1230+ } ) ,
1231+ ) . toEqual ( 1 ) ;
1232+ } ) ;
1233+
1234+ it ( 'should return error when the match is not pending' , async ( ) => {
1235+ loggedUser = '2' ;
1236+
1237+ await testMutationErrorCode (
1238+ client ,
1239+ {
1240+ mutation : MUTATION ,
1241+ variables : {
1242+ id : '550e8400-e29b-41d4-a716-446655440001' ,
1243+ } ,
1244+ } ,
1245+ 'FORBIDDEN' ,
1246+ 'Access denied! Match is not pending' ,
1247+ ) ;
1248+ } ) ;
1249+
1250+ it ( 'should return error when the opportunity is not live' , async ( ) => {
1251+ loggedUser = '1' ;
1252+
1253+ await testMutationErrorCode (
1254+ client ,
1255+ {
1256+ mutation : MUTATION ,
1257+ variables : {
1258+ id : '550e8400-e29b-41d4-a716-446655440003' ,
1259+ } ,
1260+ } ,
1261+ 'FORBIDDEN' ,
1262+ 'Access denied! Opportunity is not live' ,
1263+ ) ;
1264+ } ) ;
1265+ } ) ;
1266+
11831267describe ( 'mutation candidateAddKeywords' , ( ) => {
11841268 const MUTATION = /* GraphQL */ `
11851269 mutation CandidateAddKeywords($keywords: [String!]!) {
0 commit comments