mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +01:00
Added test to recreate early cron issue (#9668)
* Added test to recreate early cron issue * Gave user extra time based on reverse timezone change
This commit is contained in:
@@ -323,4 +323,48 @@ describe('User Model', () => {
|
||||
expect(user.achievements.beastMaster).to.not.equal(true);
|
||||
});
|
||||
});
|
||||
|
||||
context('days missed', () => {
|
||||
// http://forbrains.co.uk/international_tools/earth_timezones
|
||||
let user;
|
||||
|
||||
beforeEach(() => {
|
||||
user = new User();
|
||||
});
|
||||
|
||||
it('should not cron early when going back a timezone', () => {
|
||||
const yesterday = moment('2017-12-05T00:00:00.000-06:00'); // 11 pm on 4 Texas
|
||||
const timezoneOffset = moment().zone('-06:00').zone();
|
||||
user.lastCron = yesterday;
|
||||
user.preferences.timezoneOffset = timezoneOffset;
|
||||
|
||||
const today = moment('2017-12-06T00:00:00.000-06:00'); // 11 pm on 4 Texas
|
||||
const req = {};
|
||||
req.header = () => {
|
||||
return timezoneOffset + 60;
|
||||
};
|
||||
|
||||
const {daysMissed} = user.daysUserHasMissed(today, req);
|
||||
|
||||
expect(daysMissed).to.eql(0);
|
||||
});
|
||||
|
||||
it('should not cron early when going back a timezone with a custom day start', () => {
|
||||
const yesterday = moment('2017-12-05T02:00:00.000-08:00');
|
||||
const timezoneOffset = moment().zone('-08:00').zone();
|
||||
user.lastCron = yesterday;
|
||||
user.preferences.timezoneOffset = timezoneOffset;
|
||||
user.preferences.dayStart = 2;
|
||||
|
||||
const today = moment('2017-12-06T02:00:00.000-08:00');
|
||||
const req = {};
|
||||
req.header = () => {
|
||||
return timezoneOffset + 60;
|
||||
};
|
||||
|
||||
const {daysMissed} = user.daysUserHasMissed(today, req);
|
||||
|
||||
expect(daysMissed).to.eql(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user