|
1 |
| -import { uncancelCertificationCourse } from '../../../../../../src/certification/session-management/domain/usecases/uncancel-certification-course.js'; |
| 1 | +import { uncancel } from '../../../../../../src/certification/session-management/domain/usecases/uncancel.js'; |
| 2 | +import CertificationUncancelled from '../../../../../../src/shared/domain/events/CertificationUncancelled.js'; |
2 | 3 | import { domainBuilder, expect, sinon } from '../../../../../test-helper.js';
|
3 | 4 |
|
4 |
| -describe('Certification | Session-management | Unit | Domain | UseCases | uncancel-certification-course', function () { |
| 5 | +describe('Certification | Session-management | Unit | Domain | UseCases | uncancel', function () { |
5 | 6 | it('should uncancel the certification course', async function () {
|
6 | 7 | // given
|
| 8 | + const juryId = 123; |
7 | 9 | const certificationCourse = domainBuilder.buildCertificationCourse({ id: 123 });
|
8 | 10 | sinon.spy(certificationCourse, 'uncancel');
|
9 | 11 | const certificationCourseRepository = {
|
10 | 12 | update: sinon.stub(),
|
11 | 13 | get: sinon.stub(),
|
12 | 14 | };
|
| 15 | + const certificationRescoringRepository = { |
| 16 | + execute: sinon.stub(), |
| 17 | + }; |
13 | 18 | certificationCourseRepository.get.withArgs({ id: 123 }).resolves(certificationCourse);
|
14 | 19 | certificationCourseRepository.update.resolves();
|
| 20 | + certificationRescoringRepository.execute.resolves(); |
15 | 21 |
|
16 | 22 | // when
|
17 |
| - await uncancelCertificationCourse({ |
| 23 | + await uncancel({ |
18 | 24 | certificationCourseId: 123,
|
| 25 | + juryId, |
19 | 26 | certificationCourseRepository,
|
| 27 | + certificationRescoringRepository, |
20 | 28 | });
|
21 | 29 |
|
22 | 30 | // then
|
23 | 31 | expect(certificationCourse.uncancel).to.have.been.calledOnce;
|
24 | 32 | expect(certificationCourseRepository.update).to.have.been.calledWithExactly({ certificationCourse });
|
| 33 | + expect(certificationRescoringRepository.execute).to.have.been.calledWithExactly({ |
| 34 | + event: new CertificationUncancelled({ |
| 35 | + certificationCourseId: certificationCourse.getId(), |
| 36 | + juryId, |
| 37 | + }), |
| 38 | + }); |
25 | 39 | });
|
26 | 40 | });
|
0 commit comments