mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Added zone back
This commit is contained in:
@@ -24,6 +24,7 @@ describe('shouldDo', () => {
|
|||||||
},
|
},
|
||||||
startDate: new Date(),
|
startDate: new Date(),
|
||||||
};
|
};
|
||||||
|
options = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false if task type is not a daily', () => {
|
it('returns false if task type is not a daily', () => {
|
||||||
@@ -39,10 +40,6 @@ describe('shouldDo', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
context('Timezone variations', () => {
|
context('Timezone variations', () => {
|
||||||
beforeEach(() => {
|
|
||||||
dailyTask.frequency = 'daily';
|
|
||||||
});
|
|
||||||
|
|
||||||
context('User timezone is UTC', () => {
|
context('User timezone is UTC', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
options.timezoneOffset = 0;
|
options.timezoneOffset = 0;
|
||||||
@@ -57,6 +54,11 @@ describe('shouldDo', () => {
|
|||||||
dailyTask.startDate = moment().toDate();
|
dailyTask.startDate = moment().toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns false if Start Date is after today', () => {
|
||||||
|
dailyTask.startDate = moment().add(1, 'days').toDate();
|
||||||
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
context('User timezone is between UTC-12 and UTC (0~720)', () => {
|
context('User timezone is between UTC-12 and UTC (0~720)', () => {
|
||||||
@@ -76,15 +78,15 @@ describe('shouldDo', () => {
|
|||||||
|
|
||||||
it('returns true if the user\'s current time is after start date and Custom Day Start', () => {
|
it('returns true if the user\'s current time is after start date and Custom Day Start', () => {
|
||||||
options.dayStart = 4;
|
options.dayStart = 4;
|
||||||
day = moment().utcOffset(options.timezoneOffset).startOf('day').add(6, 'hours').toDate();
|
day = moment().zone(options.timezoneOffset).startOf('day').add(6, 'hours').toDate();
|
||||||
dailyTask.startDate = moment().utcOffset(options.timezoneOffset).subtract(1, 'day').toDate();
|
dailyTask.startDate = moment().zone(options.timezoneOffset).startOf('day').toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
||||||
options.dayStart = 8;
|
options.dayStart = 8;
|
||||||
day = moment().utcOffset(options.timezoneOffset).startOf('day').add(2, 'hours').toDate();
|
day = moment().zone(options.timezoneOffset).startOf('day').add(2, 'hours').toDate();
|
||||||
dailyTask.startDate = moment().utcOffset(options.timezoneOffset).startOf('day').toDate();
|
dailyTask.startDate = moment().zone(options.timezoneOffset).startOf('day').toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -106,13 +108,13 @@ describe('shouldDo', () => {
|
|||||||
|
|
||||||
it('returns true if the user\'s current time is after Custom Day Start', () => {
|
it('returns true if the user\'s current time is after Custom Day Start', () => {
|
||||||
options.dayStart = 4;
|
options.dayStart = 4;
|
||||||
day = moment().utcOffset(options.timezoneOffset).startOf('day').add(6, 'hours').toDate();
|
day = moment().zone(options.timezoneOffset).startOf('day').add(6, 'hours').toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
it('returns false if the user\'s current time is before Custom Day Start', () => {
|
||||||
options.dayStart = 8;
|
options.dayStart = 8;
|
||||||
day = moment().utcOffset(options.timezoneOffset).startOf('day').add(2, 'hours').toDate();
|
day = moment().zone(options.timezoneOffset).startOf('day').add(2, 'hours').toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -278,9 +280,6 @@ describe('shouldDo', () => {
|
|||||||
day = moment().subtract(3, 'days').toDate();
|
day = moment().subtract(3, 'days').toDate();
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
day = moment(day).add(7, 'days');
|
|
||||||
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user