-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
177d38d
commit 20152eb
Showing
7 changed files
with
136 additions
and
12 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
api/src/certification/enrolment/domain/read-models/UserCertificationEligibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class UserCertificationEligibility { | ||
constructor({ id, isCertifiable, certificationEligibilities = [] }) { | ||
this.id = id; | ||
this.isCertifiable = isCertifiable; | ||
this.certificationEligibilities = certificationEligibilities; | ||
} | ||
} | ||
|
||
class CertificationEligibility { | ||
constructor({ label, imageUrl, isOutdated, isAcquiredExpectedLevel }) { | ||
this.label = label; | ||
this.imageUrl = imageUrl; | ||
this.isOutdated = isOutdated; | ||
this.isAcquiredExpectedLevel = isAcquiredExpectedLevel; | ||
} | ||
} | ||
|
||
export { CertificationEligibility, UserCertificationEligibility }; |
11 changes: 9 additions & 2 deletions
11
api/src/certification/enrolment/domain/usecases/get-user-certification-eligibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
const getUserCertificationEligibility = async function () { | ||
return true; | ||
import { UserCertificationEligibility } from '../read-models/UserCertificationEligibility.js'; | ||
|
||
const getUserCertificationEligibility = async function ({ userId, limitDate, placementProfileService }) { | ||
const placementProfile = await placementProfileService.getPlacementProfile({ userId, limitDate }); | ||
return new UserCertificationEligibility({ | ||
id: userId, | ||
isCertifiable: placementProfile.isCertifiable(), | ||
certificationEligibilities: [], | ||
}); | ||
}; | ||
|
||
export { getUserCertificationEligibility }; |
62 changes: 62 additions & 0 deletions
62
...s/certification/enrolment/unit/domain/usecases/get-user-certification-eligibility_test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { getUserCertificationEligibility } from '../../../../../../src/certification/enrolment/domain/usecases/get-user-certification-eligibility.js'; | ||
import { domainBuilder, expect, sinon } from '../../../../../test-helper.js'; | ||
|
||
describe('Certification | Enrolment | Unit | Usecases | get-user-certification-eligibility', function () { | ||
const userId = 123; | ||
const limitDate = new Date('2024-09-06'); | ||
let dependencies; | ||
const placementProfileService = {}; | ||
|
||
beforeEach(function () { | ||
placementProfileService.getPlacementProfile = sinon.stub(); | ||
dependencies = { | ||
userId, | ||
limitDate, | ||
placementProfileService, | ||
}; | ||
}); | ||
|
||
context('certificability', function () { | ||
context('when user is certifiable', function () { | ||
it('returns a user certification eligibility with is certifiable set to true', async function () { | ||
placementProfileService.getPlacementProfile.withArgs({ userId, limitDate }).resolves( | ||
domainBuilder.buildPlacementProfile.buildCertifiable({ | ||
profileDate: limitDate, | ||
userId, | ||
}), | ||
); | ||
|
||
const userCertificationEligibility = await getUserCertificationEligibility(dependencies); | ||
|
||
expect(userCertificationEligibility).to.deep.equal( | ||
domainBuilder.certification.enrolment.buildUserCertificationEligibility({ | ||
id: userId, | ||
isCertifiable: true, | ||
certificationEligibilities: [], | ||
}), | ||
); | ||
}); | ||
}); | ||
context('when user is not certifiable', function () { | ||
it('returns a user certification eligibility with is certifiable set to false', async function () { | ||
placementProfileService.getPlacementProfile.withArgs({ userId, limitDate }).resolves( | ||
domainBuilder.buildPlacementProfile({ | ||
profileDate: limitDate, | ||
userId, | ||
userCompetences: [domainBuilder.buildUserCompetence({ estimatedLevel: 1, pixScore: 1 })], | ||
}), | ||
); | ||
|
||
const userCertificationEligibility = await getUserCertificationEligibility(dependencies); | ||
|
||
expect(userCertificationEligibility).to.deep.equal( | ||
domainBuilder.certification.enrolment.buildUserCertificationEligibility({ | ||
id: userId, | ||
isCertifiable: false, | ||
certificationEligibilities: [], | ||
}), | ||
); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...ng/domain-builder/factory/certification/enrolment/build-user-certification-eligibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { UserCertificationEligibility } from '../../../../../../src/certification/enrolment/domain/read-models/UserCertificationEligibility.js'; | ||
import { domainBuilder } from '../../../domain-builder.js'; | ||
|
||
const buildUserCertificationEligibility = function ({ | ||
id = 123, | ||
isCertifiable = false, | ||
certificationEligibilities = [domainBuilder.certification.enrolment.buildV3UserCertificationEligibility()], | ||
} = {}) { | ||
return new UserCertificationEligibility({ | ||
id, | ||
isCertifiable, | ||
certificationEligibilities, | ||
}); | ||
}; | ||
|
||
export { buildUserCertificationEligibility }; |
17 changes: 17 additions & 0 deletions
17
...ling/domain-builder/factory/certification/enrolment/build-v3-certification-eligibility.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { CertificationEligibility } from '../../../../../../src/certification/enrolment/domain/read-models/UserCertificationEligibility.js'; | ||
|
||
const buildV3UserCertificationEligibility = function ({ | ||
label = "Label d'éligibilité", | ||
imageUrl = "url d'image", | ||
isOutdated = false, | ||
isAcquiredExpectedLevel = true, | ||
} = {}) { | ||
return new CertificationEligibility({ | ||
label, | ||
imageUrl, | ||
isOutdated, | ||
isAcquiredExpectedLevel, | ||
}); | ||
}; | ||
|
||
export { buildV3UserCertificationEligibility }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters