-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1929 - Current days of study/studybreaks count is 1 short of total #1975
Changes from 1 commit
20ddc7d
0ca1a6e
027a28d
7e6bd7c
a2374a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,192 @@ | ||
import { OfferingStudyBreakCalculationContext } from "../../education-program-offering-validation.models"; | ||
import { EducationProgramOfferingService } from "../../education-program-offering.service"; | ||
|
||
describe("EducationProgramOfferingService-getCalculatedStudyBreaksAndWeeks", () => { | ||
it("Should calculate fundedStudyPeriodDays and totalDays counting start and end dates when studyStartDate and studyEndDate are available.", () => { | ||
//Arrange | ||
const offeringStudyBreakCalculationContext: OfferingStudyBreakCalculationContext = | ||
{ | ||
studyStartDate: "2023-01-01", | ||
studyEndDate: "2023-01-10", | ||
studyBreaks: [], | ||
}; | ||
|
||
// Act | ||
const calculatedStudyBreaksAndWeeks = | ||
EducationProgramOfferingService.getCalculatedStudyBreaksAndWeeks( | ||
offeringStudyBreakCalculationContext, | ||
); | ||
|
||
// Assert | ||
expect(calculatedStudyBreaksAndWeeks).toEqual({ | ||
allowableStudyBreaksDaysAmount: 1, | ||
fundedStudyPeriodDays: 10, | ||
studyBreaks: [], | ||
sumOfTotalEligibleBreakDays: 0, | ||
sumOfTotalIneligibleBreakDays: 0, | ||
totalDays: 10, | ||
totalFundedWeeks: 2, | ||
unfundedStudyPeriodDays: 0, | ||
}); | ||
}); | ||
|
||
it("Should not calculate fundedStudyPeriodDays and totalDays counting start and end dates when studyStartDate is not available.", () => { | ||
//Arrange | ||
const offeringStudyBreakCalculationContext: OfferingStudyBreakCalculationContext = | ||
{ | ||
studyStartDate: "", | ||
studyEndDate: "2023-01-10", | ||
studyBreaks: [], | ||
}; | ||
|
||
// Act | ||
const calculatedStudyBreaksAndWeeks = | ||
EducationProgramOfferingService.getCalculatedStudyBreaksAndWeeks( | ||
offeringStudyBreakCalculationContext, | ||
); | ||
|
||
// Assert | ||
expect(calculatedStudyBreaksAndWeeks).toEqual({ | ||
allowableStudyBreaksDaysAmount: NaN, | ||
fundedStudyPeriodDays: NaN, | ||
studyBreaks: [], | ||
sumOfTotalEligibleBreakDays: 0, | ||
sumOfTotalIneligibleBreakDays: 0, | ||
totalDays: NaN, | ||
totalFundedWeeks: NaN, | ||
unfundedStudyPeriodDays: NaN, | ||
}); | ||
}); | ||
|
||
it("Should not calculate fundedStudyPeriodDays and totalDays counting start and end dates when studyEndDate is not available.", () => { | ||
//Arrange | ||
const offeringStudyBreakCalculationContext: OfferingStudyBreakCalculationContext = | ||
{ | ||
studyStartDate: "2023-01-01", | ||
studyEndDate: "", | ||
studyBreaks: [], | ||
}; | ||
|
||
// Act | ||
const calculatedStudyBreaksAndWeeks = | ||
EducationProgramOfferingService.getCalculatedStudyBreaksAndWeeks( | ||
offeringStudyBreakCalculationContext, | ||
); | ||
|
||
// Assert | ||
expect(calculatedStudyBreaksAndWeeks).toEqual({ | ||
allowableStudyBreaksDaysAmount: NaN, | ||
fundedStudyPeriodDays: NaN, | ||
studyBreaks: [], | ||
sumOfTotalEligibleBreakDays: 0, | ||
sumOfTotalIneligibleBreakDays: 0, | ||
totalDays: NaN, | ||
totalFundedWeeks: NaN, | ||
unfundedStudyPeriodDays: NaN, | ||
}); | ||
}); | ||
|
||
it("Should calculate studyBreaks counting start and end dates when study break dates available.", () => { | ||
//Arrange | ||
const offeringStudyBreakCalculationContext: OfferingStudyBreakCalculationContext = | ||
{ | ||
studyStartDate: "", | ||
studyEndDate: "", | ||
studyBreaks: [ | ||
{ | ||
breakStartDate: "2023-05-29", | ||
breakEndDate: "2023-06-06", | ||
}, | ||
{ | ||
breakStartDate: "2023-06-08", | ||
breakEndDate: "2023-06-13", | ||
}, | ||
], | ||
}; | ||
|
||
// Act | ||
const calculatedStudyBreaksAndWeeks = | ||
EducationProgramOfferingService.getCalculatedStudyBreaksAndWeeks( | ||
offeringStudyBreakCalculationContext, | ||
); | ||
|
||
// Assert | ||
expect(calculatedStudyBreaksAndWeeks).toEqual({ | ||
allowableStudyBreaksDaysAmount: NaN, | ||
fundedStudyPeriodDays: NaN, | ||
studyBreaks: [ | ||
{ | ||
breakDays: 9, | ||
breakEndDate: "2023-06-06", | ||
breakStartDate: "2023-05-29", | ||
eligibleBreakDays: 9, | ||
ineligibleBreakDays: 0, | ||
}, | ||
{ | ||
breakDays: 6, | ||
breakEndDate: "2023-06-13", | ||
breakStartDate: "2023-06-08", | ||
eligibleBreakDays: 6, | ||
ineligibleBreakDays: 0, | ||
}, | ||
], | ||
sumOfTotalEligibleBreakDays: 15, | ||
sumOfTotalIneligibleBreakDays: 0, | ||
totalDays: NaN, | ||
totalFundedWeeks: NaN, | ||
unfundedStudyPeriodDays: NaN, | ||
}); | ||
}); | ||
|
||
it("Should calculate funded periods and allowed study breaks when there are data available.", () => { | ||
//Arrange | ||
const offeringStudyBreakCalculationContext: OfferingStudyBreakCalculationContext = | ||
{ | ||
studyStartDate: "2023-05-29", | ||
studyEndDate: "2023-09-29", | ||
studyBreaks: [ | ||
{ | ||
breakStartDate: "2023-05-29", | ||
breakEndDate: "2023-06-06", | ||
}, | ||
{ | ||
breakStartDate: "2023-06-08", | ||
breakEndDate: "2023-06-30", | ||
}, | ||
], | ||
}; | ||
|
||
// Act | ||
const calculatedStudyBreaksAndWeeks = | ||
EducationProgramOfferingService.getCalculatedStudyBreaksAndWeeks( | ||
offeringStudyBreakCalculationContext, | ||
); | ||
|
||
// Assert | ||
expect(calculatedStudyBreaksAndWeeks).toEqual({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a benefit of using There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case we can use Benefits of using
I changed the comparions to |
||
allowableStudyBreaksDaysAmount: 12.4, | ||
fundedStudyPeriodDays: 104.4, | ||
studyBreaks: [ | ||
{ | ||
breakDays: 9, | ||
breakEndDate: "2023-06-06", | ||
breakStartDate: "2023-05-29", | ||
eligibleBreakDays: 9, | ||
ineligibleBreakDays: 0, | ||
}, | ||
{ | ||
breakDays: 23, | ||
breakEndDate: "2023-06-30", | ||
breakStartDate: "2023-06-08", | ||
eligibleBreakDays: 21, | ||
ineligibleBreakDays: 2, | ||
}, | ||
], | ||
sumOfTotalEligibleBreakDays: 30, | ||
sumOfTotalIneligibleBreakDays: 2, | ||
totalDays: 124, | ||
totalFundedWeeks: 15, | ||
unfundedStudyPeriodDays: 19.6, | ||
}); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great to see some tests added to this ❤️