mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Merge branch 'develop' into api-v3
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
/* eslint-disable camelcase, func-names, no-shadow */
|
||||
import {
|
||||
DAY_MAPPING,
|
||||
startOfWeek,
|
||||
startOfDay,
|
||||
daysSince,
|
||||
} from '../../common/script/cron';
|
||||
|
||||
let expect = require('expect.js');
|
||||
let sinon = require('sinon');
|
||||
let moment = require('moment');
|
||||
@@ -205,7 +212,7 @@ let repeatWithoutLastWeekday = () => {
|
||||
s: true,
|
||||
};
|
||||
|
||||
if (shared.startOfWeek(moment().zone(0)).isoWeekday() === 1) {
|
||||
if (startOfWeek(moment().zone(0)).isoWeekday() === 1) {
|
||||
repeat.su = false;
|
||||
} else {
|
||||
repeat.s = false;
|
||||
@@ -301,7 +308,7 @@ describe('User', () => {
|
||||
|
||||
let yesterday = moment().subtract(1, 'days');
|
||||
|
||||
user.dailys[0].repeat[shared.dayMapping[yesterday.day()]] = false;
|
||||
user.dailys[0].repeat[DAY_MAPPING[yesterday.day()]] = false;
|
||||
_.each(user.dailys.slice(1), (d) => {
|
||||
d.completed = true;
|
||||
});
|
||||
@@ -383,7 +390,7 @@ describe('User', () => {
|
||||
it('does not reset checklist on grey incomplete dailies', () => {
|
||||
let yesterday = moment().subtract(1, 'days');
|
||||
|
||||
user.dailys[0].repeat[shared.dayMapping[yesterday.day()]] = false;
|
||||
user.dailys[0].repeat[DAY_MAPPING[yesterday.day()]] = false;
|
||||
user.dailys[0].checklist = [
|
||||
{
|
||||
text: '1',
|
||||
@@ -407,7 +414,7 @@ describe('User', () => {
|
||||
it('resets checklist on complete grey complete dailies', () => {
|
||||
let yesterday = moment().subtract(1, 'days');
|
||||
|
||||
user.dailys[0].repeat[shared.dayMapping[yesterday.day()]] = false;
|
||||
user.dailys[0].repeat[DAY_MAPPING[yesterday.day()]] = false;
|
||||
user.dailys[0].checklist = [
|
||||
{
|
||||
text: '1',
|
||||
@@ -1185,7 +1192,7 @@ describe('Cron', () => {
|
||||
let fstr = 'YYYY-MM-DD HH: mm: ss';
|
||||
|
||||
it('startOfDay before dayStart', () => {
|
||||
let start = shared.startOfDay({
|
||||
let start = startOfDay({
|
||||
now: moment('2014-10-09 02: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1193,7 +1200,7 @@ describe('Cron', () => {
|
||||
expect(start.format(fstr)).to.eql('2014-10-08 04: 00: 00');
|
||||
});
|
||||
it('startOfDay after dayStart', () => {
|
||||
let start = shared.startOfDay({
|
||||
let start = startOfDay({
|
||||
now: moment('2014-10-09 05: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1202,7 +1209,7 @@ describe('Cron', () => {
|
||||
});
|
||||
it('daysSince cron before, now after', () => {
|
||||
let lastCron = moment('2014-10-09 02: 30: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-09 11: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1211,7 +1218,7 @@ describe('Cron', () => {
|
||||
});
|
||||
it('daysSince cron before, now before', () => {
|
||||
let lastCron = moment('2014-10-09 02: 30: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-09 03: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1220,7 +1227,7 @@ describe('Cron', () => {
|
||||
});
|
||||
it('daysSince cron after, now after', () => {
|
||||
let lastCron = moment('2014-10-09 05: 30: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-09 06: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1229,7 +1236,7 @@ describe('Cron', () => {
|
||||
});
|
||||
it('daysSince cron after, now tomorrow before', () => {
|
||||
let lastCron = moment('2014-10-09 12: 30: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-10 01: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1238,7 +1245,7 @@ describe('Cron', () => {
|
||||
});
|
||||
it('daysSince cron after, now tomorrow after', () => {
|
||||
let lastCron = moment('2014-10-09 12: 30: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-10 10: 30: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1247,7 +1254,7 @@ describe('Cron', () => {
|
||||
});
|
||||
xit('daysSince, last cron before new dayStart', () => {
|
||||
let lastCron = moment('2014-10-09 01: 00: 00');
|
||||
let days = shared.daysSince(lastCron, {
|
||||
let days = daysSince(lastCron, {
|
||||
now: moment('2014-10-09 05: 00: 00'),
|
||||
dayStart,
|
||||
});
|
||||
@@ -1266,7 +1273,7 @@ describe('Cron', () => {
|
||||
|
||||
function runCron (options) {
|
||||
_.each([480, 240, 0, -120], function (timezoneOffset) {
|
||||
let now = shared.startOfWeek({
|
||||
let now = startOfWeek({
|
||||
timezoneOffset,
|
||||
}).add(options.currentHour || 0, 'hours');
|
||||
|
||||
@@ -1496,17 +1503,17 @@ describe('Helper', () => {
|
||||
let today = '2013-01-01 00: 00: 00';
|
||||
let zone = moment(today).zone();
|
||||
|
||||
expect(shared.startOfDay({
|
||||
expect(startOfDay({
|
||||
now: new Date(2013, 0, 1, 0),
|
||||
}, {
|
||||
timezoneOffset: zone,
|
||||
}).format(fstr)).to.eql(today);
|
||||
expect(shared.startOfDay({
|
||||
expect(startOfDay({
|
||||
now: new Date(2013, 0, 1, 5),
|
||||
}, {
|
||||
timezoneOffset: zone,
|
||||
}).format(fstr)).to.eql(today);
|
||||
expect(shared.startOfDay({
|
||||
expect(startOfDay({
|
||||
now: new Date(2013, 0, 1, 23, 59, 59),
|
||||
timezoneOffset: zone,
|
||||
}).format(fstr)).to.eql(today);
|
||||
|
||||
Reference in New Issue
Block a user