Skip to content

Commit

Permalink
EW-1060 covered code with tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Fshmit committed Dec 13, 2024
1 parent 7ae761d commit 01d36c3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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 () => {
Expand All @@ -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)
);
});
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 01d36c3

Please sign in to comment.