|
| 1 | +import { SkillDTO } from '../../../../../src/learning-content/application/api/models/SkillDTO.js'; |
| 2 | +import * as skillsApi from '../../../../../src/learning-content/application/api/skills-api.js'; |
| 3 | +import { databaseBuilder, expect } from '../../../../test-helper.js'; |
| 4 | + |
| 5 | +describe('Integration | LearningContent | Application | Api | skills', function () { |
| 6 | + describe('#findByIds', function () { |
| 7 | + it('should return an empty array when wrong ids collection provided', async function () { |
| 8 | + // given |
| 9 | + const emptySkillIds = []; |
| 10 | + const brokenSkillIds = null; |
| 11 | + |
| 12 | + // when |
| 13 | + const resultForEmpty = await skillsApi.findByIds({ ids: emptySkillIds }); |
| 14 | + const resultForBroken = await skillsApi.findByIds({ ids: brokenSkillIds }); |
| 15 | + |
| 16 | + // then |
| 17 | + expect(resultForEmpty).to.deepEqualArray([]); |
| 18 | + expect(resultForBroken).to.deepEqualArray([]); |
| 19 | + }); |
| 20 | + |
| 21 | + it('should return the skillDTOs collection corresponding to provided skill ids', async function () { |
| 22 | + // given |
| 23 | + databaseBuilder.factory.learningContent.buildSkill({ |
| 24 | + id: 'skillA', |
| 25 | + level: 4, |
| 26 | + tubeId: 'tubeA', |
| 27 | + }); |
| 28 | + databaseBuilder.factory.learningContent.buildSkill({ |
| 29 | + id: 'skillC', |
| 30 | + level: 1, |
| 31 | + tubeId: 'tubeC', |
| 32 | + }); |
| 33 | + databaseBuilder.factory.learningContent.buildSkill({ |
| 34 | + id: 'skillB', |
| 35 | + level: 3, |
| 36 | + tubeId: 'tubeB', |
| 37 | + }); |
| 38 | + await databaseBuilder.commit(); |
| 39 | + const skillIds = ['skillA', 'skillB']; |
| 40 | + |
| 41 | + // when |
| 42 | + const result = await skillsApi.findByIds({ ids: skillIds }); |
| 43 | + |
| 44 | + // then |
| 45 | + expect(result).to.deepEqualArray([ |
| 46 | + new SkillDTO({ id: 'skillA', difficulty: 4, tubeId: 'tubeA' }), |
| 47 | + new SkillDTO({ id: 'skillB', difficulty: 3, tubeId: 'tubeB' }), |
| 48 | + ]); |
| 49 | + }); |
| 50 | + }); |
| 51 | +}); |
0 commit comments