fix(subscriptions): don't reset Gems midmonth

This commit is contained in:
Sabe Jones
2016-10-10 15:52:33 +00:00
parent ff08e8b586
commit 3c4c64b023
2 changed files with 23 additions and 1 deletions

View File

@@ -71,6 +71,17 @@ describe('cron', () => {
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('does not reset plans.gemsBought within the month', () => {
let clock = sinon.useFakeTimers(Number(moment().startOf('month').add(2, 'days').toDate()));
user.purchased.plan.dateUpdated = moment().startOf('month').toDate();
user.purchased.plan.gemsBought = 10;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.gemsBought).to.equal(10);
clock.restore();
});
it('resets plan.dateUpdated on a new month', () => {
let currentMonth = moment().startOf('month');
cron({user, tasksByType, daysMissed, analytics});
@@ -173,6 +184,17 @@ describe('cron', () => {
expect(user.purchased.plan.gemsBought).to.equal(0);
});
it('does not reset plans.gemsBought within the month', () => {
let clock = sinon.useFakeTimers(Number(moment().startOf('month').add(2, 'days').toDate()));
user.purchased.plan.dateUpdated = moment().startOf('month').toDate();
user.purchased.plan.gemsBought = 10;
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.gemsBought).to.equal(10);
clock.restore();
});
it('does not reset plan.dateUpdated on a new month', () => {
cron({user, tasksByType, daysMissed, analytics});
expect(user.purchased.plan.dateUpdated).to.be.empty;