mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
chore(test): Unpend cancel subscription test
This commit is contained in:
@@ -157,8 +157,8 @@ describe('payments/index', () => {
|
|||||||
data = { user };
|
data = { user };
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds a month termination date by default', () => {
|
it('adds a month termination date by default', async () => {
|
||||||
api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
||||||
@@ -166,10 +166,10 @@ describe('payments/index', () => {
|
|||||||
expect(daysTillTermination).to.be.within(29, 30); // 1 month +/- 1 days
|
expect(daysTillTermination).to.be.within(29, 30); // 1 month +/- 1 days
|
||||||
});
|
});
|
||||||
|
|
||||||
it('adds extraMonths to dateTerminated value', () => {
|
it('adds extraMonths to dateTerminated value', async () => {
|
||||||
user.purchased.plan.extraMonths = 2;
|
user.purchased.plan.extraMonths = 2;
|
||||||
|
|
||||||
api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
||||||
@@ -177,10 +177,10 @@ describe('payments/index', () => {
|
|||||||
expect(daysTillTermination).to.be.within(89, 90); // 3 months +/- 1 days
|
expect(daysTillTermination).to.be.within(89, 90); // 3 months +/- 1 days
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles extra month fractions', () => {
|
it('handles extra month fractions', async () => {
|
||||||
user.purchased.plan.extraMonths = 0.3;
|
user.purchased.plan.extraMonths = 0.3;
|
||||||
|
|
||||||
api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
||||||
@@ -188,10 +188,10 @@ describe('payments/index', () => {
|
|||||||
expect(daysTillTermination).to.be.within(38, 39); // should be about 1 month + 1/3 month
|
expect(daysTillTermination).to.be.within(38, 39); // should be about 1 month + 1/3 month
|
||||||
});
|
});
|
||||||
|
|
||||||
it('terminates at next billing date if it exists', () => {
|
it('terminates at next billing date if it exists', async () => {
|
||||||
data.nextBill = moment().add({ days: 15 });
|
data.nextBill = moment().add({ days: 15 });
|
||||||
|
|
||||||
api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
||||||
@@ -199,15 +199,15 @@ describe('payments/index', () => {
|
|||||||
expect(daysTillTermination).to.be.within(13, 15);
|
expect(daysTillTermination).to.be.within(13, 15);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('resets plan.extraMonths', () => {
|
it('resets plan.extraMonths', async () => {
|
||||||
user.purchased.plan.extraMonths = 5;
|
user.purchased.plan.extraMonths = 5;
|
||||||
|
|
||||||
api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
expect(user.purchased.plan.extraMonths).to.eql(0);
|
expect(user.purchased.plan.extraMonths).to.eql(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
xit('sends an email (the spy is not being properly restored in the aftereach, for some reason)', async () => {
|
it('sends an email', async () => {
|
||||||
await api.cancelSubscription(data);
|
await api.cancelSubscription(data);
|
||||||
|
|
||||||
expect(sender.sendTxn).to.be.calledOnce;
|
expect(sender.sendTxn).to.be.calledOnce;
|
||||||
|
|||||||
Reference in New Issue
Block a user