fix(habits): reset counters when sleeping (#8898)

This commit is contained in:
Sabe Jones
2017-08-02 08:35:20 -07:00
committed by GitHub
parent d3967d6567
commit 576285c004
2 changed files with 51 additions and 33 deletions

View File

@@ -566,6 +566,17 @@ describe('cron', () => {
expect(tasksByType.habits[0].counterDown).to.equal(0);
});
it('should reset habit counters even if user is resting in the Inn', () => {
user.preferences.sleep = true;
tasksByType.habits[0].counterUp = 1;
tasksByType.habits[0].counterDown = 1;
cron({user, tasksByType, daysMissed, analytics});
expect(tasksByType.habits[0].counterUp).to.equal(0);
expect(tasksByType.habits[0].counterDown).to.equal(0);
});
it('should reset a weekly habit counter each Monday', () => {
tasksByType.habits[0].frequency = 'weekly';
tasksByType.habits[0].counterUp = 1;