mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-04-14 19:47:03 +00:00
chore(test): Unpend cancel subscription test
This commit is contained in:
parent
37e638a64d
commit
c9f2389765
1 changed files with 11 additions and 11 deletions
|
|
@ -157,8 +157,8 @@ describe('payments/index', () => {
|
|||
data = { user };
|
||||
});
|
||||
|
||||
it('adds a month termination date by default', () => {
|
||||
api.cancelSubscription(data);
|
||||
it('adds a month termination date by default', async () => {
|
||||
await api.cancelSubscription(data);
|
||||
|
||||
let now = new Date();
|
||||
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
|
||||
});
|
||||
|
||||
it('adds extraMonths to dateTerminated value', () => {
|
||||
it('adds extraMonths to dateTerminated value', async () => {
|
||||
user.purchased.plan.extraMonths = 2;
|
||||
|
||||
api.cancelSubscription(data);
|
||||
await api.cancelSubscription(data);
|
||||
|
||||
let now = new Date();
|
||||
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
|
||||
});
|
||||
|
||||
it('handles extra month fractions', () => {
|
||||
it('handles extra month fractions', async () => {
|
||||
user.purchased.plan.extraMonths = 0.3;
|
||||
|
||||
api.cancelSubscription(data);
|
||||
await api.cancelSubscription(data);
|
||||
|
||||
let now = new Date();
|
||||
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
|
||||
});
|
||||
|
||||
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 });
|
||||
|
||||
api.cancelSubscription(data);
|
||||
await api.cancelSubscription(data);
|
||||
|
||||
let now = new Date();
|
||||
let daysTillTermination = moment(user.purchased.plan.dateTerminated).diff(now, 'days');
|
||||
|
|
@ -199,15 +199,15 @@ describe('payments/index', () => {
|
|||
expect(daysTillTermination).to.be.within(13, 15);
|
||||
});
|
||||
|
||||
it('resets plan.extraMonths', () => {
|
||||
it('resets plan.extraMonths', async () => {
|
||||
user.purchased.plan.extraMonths = 5;
|
||||
|
||||
api.cancelSubscription(data);
|
||||
await api.cancelSubscription(data);
|
||||
|
||||
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);
|
||||
|
||||
expect(sender.sendTxn).to.be.calledOnce;
|
||||
|
|
|
|||
Loading…
Reference in a new issue