Skip to content

Commit

Permalink
feat(orga): fixing tests for ke snapshots in lib
Browse files Browse the repository at this point in the history
  • Loading branch information
alicegoarnisson committed Dec 18, 2024
1 parent 6f778e3 commit dd20ffd
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
let userId1, userId2;
let snappedAt1, snappedAt2, snappedAt3;
let knowledgeElement1, knowledgeElement2, knowledgeElement3;
let campaignParticipation1, campaignParticipation2, campaignParticipation3;
let learningContent;

beforeEach(async function () {
Expand All @@ -190,8 +191,9 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
learningContent = domainBuilder.buildCampaignLearningContent.fromFrameworks([framework]);

snappedAt1 = new Date('2020-01-02');
campaignParticipation1 = 123;
databaseBuilder.factory.buildCampaignParticipation({
id: 123,
id: campaignParticipation1,
userId: userId1,
sharedAt: snappedAt1,
});
Expand All @@ -204,12 +206,13 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
userId: userId1,
snappedAt: snappedAt1,
snapshot: JSON.stringify([knowledgeElement1]),
campaignParticipationId: 123,
campaignParticipationId: campaignParticipation1,
});

snappedAt2 = new Date('2020-02-02');
campaignParticipation2 = 456;
databaseBuilder.factory.buildCampaignParticipation({
id: 456,
id: campaignParticipation2,
userId: userId2,
sharedAt: snappedAt2,
});
Expand All @@ -222,12 +225,13 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
userId: userId2,
snappedAt: snappedAt2,
snapshot: JSON.stringify([knowledgeElement2]),
campaignParticipation: 456,
campaignParticipation: campaignParticipation2,
});

snappedAt3 = new Date('2022-02-02');
campaignParticipation3 = 789;
databaseBuilder.factory.buildCampaignParticipation({
id: 789,
id: campaignParticipation3,
userId: userId2,
sharedAt: snappedAt3,
});
Expand All @@ -240,7 +244,7 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
userId: userId2,
snappedAt: snappedAt3,
snapshot: JSON.stringify([knowledgeElement3]),
campaignParticipation: 789,
campaignParticipation: campaignParticipation3,
});

await databaseBuilder.commit();
Expand All @@ -250,9 +254,9 @@ describe('Integration | Repository | KnowledgeElementSnapshotRepository', functi
// when
const knowledgeElementsByUserId =
await knowledgeElementSnapshotRepository.findMultipleUsersFromUserIdsAndSnappedAtDates([
{ userId: userId1, sharedAt: snappedAt1 },
{ userId: userId2, sharedAt: snappedAt2 },
{ userId: userId2, sharedAt: snappedAt3 },
{ userId: userId1, sharedAt: snappedAt1, campaignParticipationId: campaignParticipation1 },
{ userId: userId2, sharedAt: snappedAt2, campaignParticipationId: campaignParticipation2 },
{ userId: userId2, sharedAt: snappedAt3, campaignParticipationId: campaignParticipation3 },
]);

// then
Expand Down

0 comments on commit dd20ffd

Please sign in to comment.