Skip to content

Commit

Permalink
Test users without donations
Browse files Browse the repository at this point in the history
  • Loading branch information
estevamfurtado committed Oct 15, 2024
1 parent 8fb26e4 commit a7b3111
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions use_cases/getRankingList.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ beforeAll(async () => {

// Create users and contributions
const users = [
{ email: "[email protected]", degree: "Computer Science", admissionYear: 2020 },
{ email: "[email protected]", degree: "Computer Science", admissionYear: 2021 },
{ email: "[email protected]", degree: "Industrial Engineering", admissionYear: 2020 },
{ email: "[email protected]", degree: "Computer Science", admissionYear: 2020, amount: 0 },
{ email: "[email protected]", degree: "Computer Science", admissionYear: 2020, amount: 200_00 },
{ email: "[email protected]", degree: "Computer Science", admissionYear: 2021, amount: 300_00 },
{ email: "[email protected]", degree: "Industrial Engineering", admissionYear: 2020, amount: 500_00 },
];

for (const user of users) {
Expand All @@ -35,17 +36,19 @@ beforeAll(async () => {
volunteeringInterest: false
});

const contribution = await createContribution({
dbClient: prisma,
amountInCents: 100_00,
email: user.email,
});
if (user.amount > 0) {
const contribution = await createContribution({
dbClient: prisma,
amountInCents: user.amount,
email: user.email,
});

await completeContribution({
dbClient: prisma,
contributionId: contribution.id,
externalId: "test123",
});
await completeContribution({
dbClient: prisma,
contributionId: contribution.id,
externalId: "test123",
});
}
}
});

Expand All @@ -63,23 +66,23 @@ describe("getRankingList", () => {
});

expect(result).toEqual({
amount: 300,
amount: 1000,
numberOfDonors: 3,
ranking: [
{
position: 1,
degree: "Computer Science",
initialYear: 2020,
finalYear: 2024,
amount: 200,
amount: 500,
numberOfDonors: 2,
},
{
position: 2,
degree: "Industrial Engineering",
initialYear: 2020,
finalYear: 2024,
amount: 100,
amount: 500,
numberOfDonors: 1,
},
],
Expand All @@ -94,15 +97,15 @@ describe("getRankingList", () => {
});

expect(result).toEqual({
amount: 200,
amount: 500,
numberOfDonors: 2,
ranking: [
{
position: 1,
degree: "Computer Science",
initialYear: 2020,
finalYear: 2024,
amount: 200,
amount: 500,
numberOfDonors: 2,
},
],
Expand Down

0 comments on commit a7b3111

Please sign in to comment.