Skip to content

Commit

Permalink
Updated DonationTest
Browse files Browse the repository at this point in the history
100% coverage.
  • Loading branch information
roaraf committed Apr 23, 2026
1 parent e41e4d5 commit e0e37f0
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.UUID;

import ntnu.systemutvikling.team6.models.user.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

class DonationTest {
private Settings settings;
private User user;
private Charity charity;

Expand All @@ -20,7 +21,6 @@ public void setup() {

user =
new User(
"Name",
"username",
"Valid@gmail.com",
"123",
Expand All @@ -43,6 +43,19 @@ void testDonationInitialization() {
assertEquals(user, donation.getDonor());
}

@Test
void testDonationFromDatabaseInitialization() {
LocalDateTime now = LocalDateTime.now();

Donation donation = new Donation(UUID.randomUUID().toString(), 500.0, LocalDate.from(now), charity, user, false);

assertNotNull(donation.getCharityId());
assertEquals(500.0, donation.getAmount());
assertEquals(LocalDate.from(now), donation.getDate());
assertEquals(charity, donation.getCharity());
assertEquals(user, donation.getDonor());
}

@Test
void testAnonymousFlagWhenUserIsAnonymous() {
user.setSettings(new Settings(false, Language.ENGLISH, false));
Expand Down

0 comments on commit e0e37f0

Please sign in to comment.