1
- import { cancelCertificationCourse } from '../../../../../../src/certification/session-management/domain/usecases/cancel-certification-course .js' ;
1
+ import { cancel } from '../../../../../../src/certification/session-management/domain/usecases/cancel.js' ;
2
2
import { NotFinalizedSessionError } from '../../../../../../src/shared/domain/errors.js' ;
3
3
import CertificationCancelled from '../../../../../../src/shared/domain/events/CertificationCancelled.js' ;
4
4
import { catchErr , domainBuilder , expect , sinon } from '../../../../../test-helper.js' ;
5
5
6
- describe ( 'Certification | Session-management | Unit | Domain | UseCases | cancel-certification-course ' , function ( ) {
6
+ describe ( 'Certification | Session-management | Unit | Domain | UseCases | cancel' , function ( ) {
7
7
describe ( 'when session is finalized' , function ( ) {
8
8
it ( 'should cancel the certification course' , async function ( ) {
9
9
// given
@@ -20,22 +20,32 @@ describe('Certification | Session-management | Unit | Domain | UseCases | cancel
20
20
const sessionRepository = {
21
21
get : sinon . stub ( ) ,
22
22
} ;
23
+ const certificationRescoringRepository = {
24
+ execute : sinon . stub ( ) ,
25
+ } ;
23
26
certificationCourseRepository . get . withArgs ( { id : 123 } ) . resolves ( certificationCourse ) ;
24
27
certificationCourseRepository . update . resolves ( ) ;
28
+ certificationRescoringRepository . execute . resolves ( ) ;
25
29
sessionRepository . get . withArgs ( { id : certificationCourse . getSessionId ( ) } ) . resolves ( session ) ;
26
30
27
31
// when
28
- const cancelledEvent = await cancelCertificationCourse ( {
32
+ await cancel ( {
29
33
certificationCourseId : 123 ,
34
+ juryId,
30
35
certificationCourseRepository,
31
36
sessionRepository,
32
- juryId ,
37
+ certificationRescoringRepository ,
33
38
} ) ;
34
39
35
40
// then
36
41
expect ( certificationCourse . cancel ) . to . have . been . calledOnce ;
37
42
expect ( certificationCourseRepository . update ) . to . have . been . calledWithExactly ( { certificationCourse } ) ;
38
- expect ( cancelledEvent ) . to . deepEqualInstance ( new CertificationCancelled ( { certificationCourseId : 123 , juryId } ) ) ;
43
+ expect ( certificationRescoringRepository . execute ) . to . have . been . calledWithExactly ( {
44
+ certificationCancelledEvent : new CertificationCancelled ( {
45
+ certificationCourseId : certificationCourse . getId ( ) ,
46
+ juryId,
47
+ } ) ,
48
+ } ) ;
39
49
} ) ;
40
50
} ) ;
41
51
@@ -58,7 +68,7 @@ describe('Certification | Session-management | Unit | Domain | UseCases | cancel
58
68
sessionRepository . get . withArgs ( { id : certificationCourse . getSessionId ( ) } ) . resolves ( session ) ;
59
69
60
70
// when
61
- const error = await catchErr ( cancelCertificationCourse ) ( {
71
+ const error = await catchErr ( cancel ) ( {
62
72
certificationCourseId : 123 ,
63
73
certificationCourseRepository,
64
74
sessionRepository,
0 commit comments