Skip to content

Commit

Permalink
♻️ api: better name for reconcilement usecase
Browse files Browse the repository at this point in the history
  • Loading branch information
Steph0 committed Sep 24, 2024
1 parent 8c5fe8a commit fe4f043
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @typedef {import ('./index.js').EnrolledCandidateRepository} EnrolledCandidateRepository
* @typedef {import ('../../domain/models/Candidate.js').Candidate} Candidate
*/

import { usecases } from '../../domain/usecases/index.js';
Expand All @@ -13,7 +13,7 @@ import { usecases } from '../../domain/usecases/index.js';
* @param {string} params.lastName
* @param {Date} params.birthdate
* @param {Function} params.normalizeStringFnc
* @returns {Promise<EnrolledCandidate>}
* @returns {Promise<Candidate>}
*/
export const registerCandidateParticipation = async ({
userId,
Expand All @@ -36,7 +36,7 @@ export const registerCandidateParticipation = async ({
return candidate;
}

return usecases.linkUserToCandidate({
return usecases.reconcileCandidate({
userId,
candidate,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { UserNotAuthorizedToCertifyError } from '../../../../shared/domain/error
*
* @returns {Promise<Candidate>}
*/
export async function linkUserToCandidate({ userId, candidate, candidateRepository, placementProfileService }) {
export async function reconcileCandidate({ userId, candidate, candidateRepository, placementProfileService }) {
candidate.reconcile(userId);

if (candidate.hasCoreSubscription()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ describe('Unit | Application | Service | register-candidate-participation', func
get: sinon.stub(),
};
normalizeStringFnc = sinon.stub();
sinon.stub(usecases, 'linkUserToCandidate');
sinon.stub(usecases, 'reconcileCandidate');
});

context('when the candidate is already link to a user', function () {
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('Unit | Application | Service | register-candidate-participation', func
sessionId,
normalizeStringFnc,
});
expect(usecases.linkUserToCandidate).to.not.have.been.called;
expect(usecases.reconcileCandidate).to.not.have.been.called;
});
});

Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Unit | Application | Service | register-candidate-participation', func
sessionId,
normalizeStringFnc,
});
expect(usecases.linkUserToCandidate).to.have.been.calledWithExactly({
expect(usecases.reconcileCandidate).to.have.been.calledWithExactly({
candidate: unlinkedCandidate,
userId,
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { DomainTransaction } from '../../../../../../lib/infrastructure/DomainTransaction.js';
import { linkUserToCandidate } from '../../../../../../src/certification/enrolment/domain/usecases/link-user-to-candidate.js';
import { reconcileCandidate } from '../../../../../../src/certification/enrolment/domain/usecases/reconcile-candidate.js';
import { UserNotAuthorizedToCertifyError } from '../../../../../../src/shared/domain/errors.js';
import { catchErr, domainBuilder, expect, sinon } from '../../../../../test-helper.js';

describe('Certification | Enrolment | Unit | Domain | UseCase | link-user-to-candidate', function () {
describe('Certification | Enrolment | Unit | Domain | UseCase | reconcile-candidate', function () {
let candidateRepository;
let placementProfileService;
let dependencies;
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | link-user-to-can
});

// when
const error = await catchErr(linkUserToCandidate)({
const error = await catchErr(reconcileCandidate)({
candidate,
...dependencies,
});
Expand All @@ -72,7 +72,7 @@ describe('Certification | Enrolment | Unit | Domain | UseCase | link-user-to-can
candidateRepository.update.withArgs(candidate).resolves();

// when
await linkUserToCandidate({
await reconcileCandidate({
candidate,
...dependencies,
});
Expand Down

0 comments on commit fe4f043

Please sign in to comment.