From 01d36c392ef3b7642c8aaad3f74ac3d7aa8aad1d Mon Sep 17 00:00:00 2001 From: Firas Shmit Date: Fri, 13 Dec 2024 15:19:50 +0100 Subject: [PATCH] EW-1060 covered code with tests --- .../common-cartridge-export.service.spec.ts | 30 +++++++++++++++++-- .../common-cartridge-export.service.ts | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts index 1e2d7fab28..ffc209887a 100644 --- a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts +++ b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.spec.ts @@ -304,7 +304,7 @@ describe('CommonCartridgeExportService', () => { }); }); - describe('When topics array is empty', () => { + describe('when topics array is empty', () => { const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, false, true, true); it("shouldn't add lessons", async () => { @@ -316,7 +316,7 @@ describe('CommonCartridgeExportService', () => { }); }); - describe('When tasks array is empty', () => { + describe('when tasks array is empty', () => { const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, true, false, true); it("shouldn't add tasks", async () => { @@ -326,7 +326,7 @@ describe('CommonCartridgeExportService', () => { }); }); - describe('When columnBoards array is empty', () => { + describe('when columnBoards array is empty', () => { const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, true, true, false); it("shouldn't add column boards", async () => { @@ -337,5 +337,29 @@ describe('CommonCartridgeExportService', () => { ); }); }); + + describe('when topics has no linked tasks', () => { + const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, false, true, true); + + it('should add lesson without linked tasks', async () => { + const { archive, lesson } = await setup(); + lesson.linkedTasks = undefined; + + expect(getFileContent(archive, 'imsmanifest.xml')).not.toContain(createXmlString('title', lesson.name)); + }); + }); + + describe('when columnBoards has no cards', () => { + const setup = async () => setupParams(CommonCartridgeVersion.V_1_1_0, true, true, false); + + it('should add column boards without cards', async () => { + const { archive, boardSkeleton } = await setup(); + boardSkeleton.columns[0].cards = []; + + expect(getFileContent(archive, 'imsmanifest.xml')).not.toContain( + createXmlString('title', boardSkeleton.columns[0].title) + ); + }); + }); }); }); diff --git a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts index 586106f330..0628e8579b 100644 --- a/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts +++ b/apps/server/src/modules/common-cartridge/service/common-cartridge-export.service.ts @@ -168,7 +168,7 @@ export class CommonCartridgeExportService { identifier: createIdentifier(columnId), }); - if (column.cards?.length) { + if (column.cards.length) { const cardsIds = column.cards.map((card) => card.cardId); const listOfCards: CardListResponseDto = await this.findAllCardsByIds(cardsIds);