mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Move from deprecated moment#zone to moment#utcOffset (#12207)
* Issue 10209 - Remove read usages of zone * Issue 10209 - Add coverage on daysSince and startOfDay cron utility functions * Issue 10209 - Add unit test for daysUserHasMissed method * Issue 10209 - Remove usages of deprecated `moment.js#zone` method. * Issue 10209 - Add helper function to centralise logic Also simplify timezoneOffsetToUtc function in site.vue * Issue 10209 - Also add getUtcOffset as method on user Co-authored-by: Matteo Pagliazzi <matteopagliazzi@gmail.com>
This commit is contained in:
@@ -5,6 +5,8 @@ import 'moment-recur';
|
||||
describe('shouldDo', () => {
|
||||
let day; let
|
||||
dailyTask;
|
||||
// Options is a mapping of user.preferences, therefor `timezoneOffset` still holds old zone
|
||||
// values instead of utcOffset values.
|
||||
let options = {};
|
||||
let nextDue = [];
|
||||
|
||||
@@ -80,17 +82,17 @@ describe('shouldDo', () => {
|
||||
|
||||
it('returns true if the user\'s current time is after start date and Custom Day Start', () => {
|
||||
options.dayStart = 4;
|
||||
day = moment().zone(options.timezoneOffset).startOf('day').add(6, 'hours')
|
||||
day = moment().utcOffset(-options.timezoneOffset).startOf('day').add(6, 'hours')
|
||||
.toDate();
|
||||
dailyTask.startDate = moment().zone(options.timezoneOffset).startOf('day').toDate();
|
||||
dailyTask.startDate = moment().utcOffset(-options.timezoneOffset).startOf('day').toDate();
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
||||
options.dayStart = 8;
|
||||
day = moment().zone(options.timezoneOffset).startOf('day').add(2, 'hours')
|
||||
day = moment().utcOffset(-options.timezoneOffset).startOf('day').add(2, 'hours')
|
||||
.toDate();
|
||||
dailyTask.startDate = moment().zone(options.timezoneOffset).startOf('day').toDate();
|
||||
dailyTask.startDate = moment().utcOffset(-options.timezoneOffset).startOf('day').toDate();
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||
});
|
||||
});
|
||||
@@ -112,14 +114,14 @@ describe('shouldDo', () => {
|
||||
|
||||
it('returns true if the user\'s current time is after Custom Day Start', () => {
|
||||
options.dayStart = 4;
|
||||
day = moment().zone(options.timezoneOffset).startOf('day').add(6, 'hours')
|
||||
day = moment().utcOffset(-options.timezoneOffset).startOf('day').add(6, 'hours')
|
||||
.toDate();
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||
});
|
||||
|
||||
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
||||
options.dayStart = 8;
|
||||
day = moment().zone(options.timezoneOffset).startOf('day').add(2, 'hours')
|
||||
day = moment().utcOffset(-options.timezoneOffset).startOf('day').add(2, 'hours')
|
||||
.toDate();
|
||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user