mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 21:27:23 +01:00
fix(subscriptions): use correct termination date field and add extra check when it is missing
This commit is contained in:
@@ -72,10 +72,18 @@ describe('#calculateSubscriptionTerminationDate', () => {
|
||||
|
||||
it('returns current terminated date if it exists and is later than newly calculated date', () => {
|
||||
const expectedTerminationDate = moment().add({ months: 5 }).toDate();
|
||||
plan.terminationDate = expectedTerminationDate;
|
||||
plan.dateTerminated = expectedTerminationDate;
|
||||
|
||||
const terminationDate = calculateSubscriptionTerminationDate(nextBill, plan, groupPlanId);
|
||||
|
||||
expect(terminationDate).to.equal(expectedTerminationDate);
|
||||
});
|
||||
|
||||
it('returns the calculated termination date if the plan does not have one', () => {
|
||||
nextBill = moment().add(5, 'days');
|
||||
const expectedTerminationDate = moment().add(5, 'days');
|
||||
|
||||
const terminationDate = calculateSubscriptionTerminationDate(nextBill, plan, groupPlanId);
|
||||
expect(expectedTerminationDate.diff(terminationDate, 'days')).to.eql(0);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user