|
1 | 1 | import * as targetProfileApi from '../../../../../../src/prescription/target-profile/application/api/target-profile-api.js';
|
2 | 2 | import { TargetProfile } from '../../../../../../src/prescription/target-profile/application/api/TargetProfile.js';
|
| 3 | +import { TargetProfileSkill } from '../../../../../../src/prescription/target-profile/application/api/TargetProfileSkill.js'; |
3 | 4 | import { TargetProfileForSpecifier } from '../../../../../../src/prescription/target-profile/domain/read-models/TargetProfileForSpecifier.js';
|
4 | 5 | import { usecases } from '../../../../../../src/prescription/target-profile/domain/usecases/index.js';
|
5 | 6 | import { catchErr, expect, sinon } from '../../../../../test-helper.js';
|
6 | 7 | import { domainBuilder } from '../../../../../tooling/domain-builder/domain-builder.js';
|
| 8 | +import { buildSkill } from '../../../../../tooling/learning-content-builder/build-skill.js'; |
7 | 9 |
|
8 | 10 | describe('Unit | API | TargetProfile', function () {
|
9 | 11 | describe('#getById', function () {
|
@@ -85,4 +87,35 @@ describe('Unit | API | TargetProfile', function () {
|
85 | 87 | expect(result).to.have.lengthOf(0);
|
86 | 88 | });
|
87 | 89 | });
|
| 90 | + |
| 91 | + describe('#findSkillsByTargetProfileIds', function () { |
| 92 | + it('should return empty array if no skill found', async function () { |
| 93 | + const findSkillsByTargetProfileIdsStub = sinon.stub(usecases, 'findSkillsByTargetProfileIds'); |
| 94 | + findSkillsByTargetProfileIdsStub.rejects(); |
| 95 | + findSkillsByTargetProfileIdsStub.withArgs({ targetProfileIds: ['targetProfileId'] }).resolves([]); |
| 96 | + |
| 97 | + // when |
| 98 | + const result = await targetProfileApi.findSkillsByTargetProfileIds(['targetProfileId']); |
| 99 | + |
| 100 | + // then |
| 101 | + expect(result).to.have.lengthOf(0); |
| 102 | + }); |
| 103 | + |
| 104 | + it('should return an array of TargetProfileSkill', async function () { |
| 105 | + const findSkillsByTargetProfileIdsStub = sinon.stub(usecases, 'findSkillsByTargetProfileIds'); |
| 106 | + findSkillsByTargetProfileIdsStub.rejects(); |
| 107 | + findSkillsByTargetProfileIdsStub |
| 108 | + .withArgs({ targetProfileIds: ['targetProfileId'] }) |
| 109 | + .resolves([buildSkill({ id: 'monSkillId', level: 18 })]); |
| 110 | + |
| 111 | + // when |
| 112 | + const result = await targetProfileApi.findSkillsByTargetProfileIds(['targetProfileId']); |
| 113 | + |
| 114 | + // then |
| 115 | + expect(result).to.have.lengthOf(1); |
| 116 | + expect(result[0]).instanceOf(TargetProfileSkill); |
| 117 | + expect(result[0].id).equals('monSkillId'); |
| 118 | + expect(result[0].level).equals(18); |
| 119 | + }); |
| 120 | + }); |
88 | 121 | });
|
0 commit comments