mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Added repeatable tests back
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { shouldDo } from '../../website/common/script/cron';
|
import { shouldDo, DAY_MAPPING } from '../../website/common/script/cron';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
// import 'moment-recur';
|
import 'moment-recur';
|
||||||
|
|
||||||
describe('shouldDo', () => {
|
describe('shouldDo', () => {
|
||||||
let day, dailyTask;
|
let day, dailyTask;
|
||||||
@@ -481,215 +481,215 @@ describe('shouldDo', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// context('Every X Weeks', () => {
|
context('Every X Weeks', () => {
|
||||||
// it('leaves daily inactive if it has not been the specified number of weeks', () => {
|
it('leaves daily inactive if it has not been the specified number of weeks', () => {
|
||||||
// dailyTask.everyX = 3;
|
dailyTask.everyX = 3;
|
||||||
// let tomorrow = moment().add(1, 'day').toDate();
|
let tomorrow = moment().add(1, 'day').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('leaves daily inactive if on every (x) week on weekday it is incorrect weekday', () => {
|
it('leaves daily inactive if on every (x) week on weekday it is incorrect weekday', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// day = moment();
|
day = moment();
|
||||||
// dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
|
dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
|
||||||
// dailyTask.everyX = 3;
|
dailyTask.everyX = 3;
|
||||||
// let threeWeeksFromTodayPlusOne = day.add(1, 'day').add(3, 'weeks').toDate();
|
let threeWeeksFromTodayPlusOne = day.add(1, 'day').add(3, 'weeks').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(threeWeeksFromTodayPlusOne, dailyTask, options)).to.equal(false);
|
expect(shouldDo(threeWeeksFromTodayPlusOne, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily on matching week', () => {
|
it('activates Daily on matching week', () => {
|
||||||
// dailyTask.everyX = 3;
|
dailyTask.everyX = 3;
|
||||||
// let threeWeeksFromToday = moment().add(3, 'weeks').toDate();
|
let threeWeeksFromToday = moment().add(3, 'weeks').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
|
expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily on every (x) week on weekday', () => {
|
it('activates Daily on every (x) week on weekday', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// day = moment();
|
day = moment();
|
||||||
// dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
|
dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
|
||||||
// dailyTask.everyX = 3;
|
dailyTask.everyX = 3;
|
||||||
// let threeWeeksFromToday = day.add(6, 'weeks').day(day.day()).toDate();
|
let threeWeeksFromToday = day.add(6, 'weeks').day(day.day()).toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
|
expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// context('Monthly - Every X Months on a specified date', () => {
|
context('Monthly - Every X Months on a specified date', () => {
|
||||||
// it('leaves daily inactive if not day of the month', () => {
|
it('leaves daily inactive if not day of the month', () => {
|
||||||
// dailyTask.everyX = 1;
|
dailyTask.everyX = 1;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// dailyTask.daysOfMonth = [15];
|
dailyTask.daysOfMonth = [15];
|
||||||
// let tomorrow = moment().add(1, 'day').toDate();// @TODO: make sure this is not the 15
|
let tomorrow = moment().add(1, 'day').toDate();// @TODO: make sure this is not the 15
|
||||||
//
|
|
||||||
// expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily on matching day of month', () => {
|
it('activates Daily on matching day of month', () => {
|
||||||
// day = moment();
|
day = moment();
|
||||||
// dailyTask.everyX = 1;
|
dailyTask.everyX = 1;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// dailyTask.daysOfMonth = [day.date()];
|
dailyTask.daysOfMonth = [day.date()];
|
||||||
// day = day.add(1, 'months').date(day.date()).toDate();
|
day = day.add(1, 'months').date(day.date()).toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('leaves daily inactive if not on date of the x month', () => {
|
it('leaves daily inactive if not on date of the x month', () => {
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// dailyTask.daysOfMonth = [15];
|
dailyTask.daysOfMonth = [15];
|
||||||
// let tomorrow = moment().add(2, 'months').add(1, 'day').toDate();
|
let tomorrow = moment().add(2, 'months').add(1, 'day').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
expect(shouldDo(tomorrow, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily if on date of the x month', () => {
|
it('activates Daily if on date of the x month', () => {
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// dailyTask.daysOfMonth = [15];
|
dailyTask.daysOfMonth = [15];
|
||||||
// day = moment().add(2, 'months').date(15).toDate();
|
day = moment().add(2, 'months').date(15).toDate();
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// context('Monthly - Certain days of the nth Week', () => {
|
context('Monthly - Certain days of the nth Week', () => {
|
||||||
// it('leaves daily inactive if not the correct week of the month on the day of the start date', () => {
|
it('leaves daily inactive if not the correct week of the month on the day of the start date', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// let today = moment('01/27/2017');
|
let today = moment('2017-01-27');
|
||||||
// let week = today.monthWeek();
|
let week = today.monthWeek();
|
||||||
// let dayOfWeek = today.day();
|
let dayOfWeek = today.day();
|
||||||
// dailyTask.startDate = today.toDate();
|
dailyTask.startDate = today.toDate();
|
||||||
// dailyTask.weeksOfMonth = [week];
|
dailyTask.weeksOfMonth = [week];
|
||||||
// dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
||||||
// dailyTask.everyX = 1;
|
dailyTask.everyX = 1;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// day = moment('02/23/2017');
|
day = moment('2017-02-23');
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily if correct week of the month on the day of the start date', () => {
|
it('activates Daily if correct week of the month on the day of the start date', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// let today = moment('01/27/2017');
|
let today = moment('2017-01-27');
|
||||||
// let week = today.monthWeek();
|
let week = today.monthWeek();
|
||||||
// let dayOfWeek = today.day();
|
let dayOfWeek = today.day();
|
||||||
// dailyTask.startDate = today.toDate();
|
dailyTask.startDate = today.toDate();
|
||||||
// dailyTask.weeksOfMonth = [week];
|
dailyTask.weeksOfMonth = [week];
|
||||||
// dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
||||||
// dailyTask.everyX = 1;
|
dailyTask.everyX = 1;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
// day = moment('02/24/2017');
|
day = moment('2017-02-24');
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('leaves daily inactive if not day of the month with every x month on weekday', () => {
|
it('leaves daily inactive if not day of the month with every x month on weekday', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// let today = moment('01/26/2017');
|
let today = moment('2017-01-26');
|
||||||
// let week = today.monthWeek();
|
let week = today.monthWeek();
|
||||||
// let dayOfWeek = today.day();
|
let dayOfWeek = today.day();
|
||||||
// dailyTask.startDate = today.toDate();
|
dailyTask.startDate = today.toDate();
|
||||||
// dailyTask.weeksOfMonth = [week];
|
dailyTask.weeksOfMonth = [week];
|
||||||
// dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
//
|
|
||||||
// day = moment('03/24/2017');
|
day = moment('2017-03-24');
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily if on nth weekday of the x month', () => {
|
it('activates Daily if on nth weekday of the x month', () => {
|
||||||
// dailyTask.repeat = {
|
dailyTask.repeat = {
|
||||||
// su: false,
|
su: false,
|
||||||
// s: false,
|
s: false,
|
||||||
// f: false,
|
f: false,
|
||||||
// th: false,
|
th: false,
|
||||||
// w: false,
|
w: false,
|
||||||
// t: false,
|
t: false,
|
||||||
// m: false,
|
m: false,
|
||||||
// };
|
};
|
||||||
//
|
|
||||||
// let today = moment('01/27/2017');
|
let today = moment('2017-01-27');
|
||||||
// let week = today.monthWeek();
|
let week = today.monthWeek();
|
||||||
// let dayOfWeek = today.day();
|
let dayOfWeek = today.day();
|
||||||
// dailyTask.startDate = today.toDate();
|
dailyTask.startDate = today.toDate();
|
||||||
// dailyTask.weeksOfMonth = [week];
|
dailyTask.weeksOfMonth = [week];
|
||||||
// dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
dailyTask.repeat[DAY_MAPPING[dayOfWeek]] = true;
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'monthly';
|
dailyTask.frequency = 'monthly';
|
||||||
//
|
|
||||||
// day = moment('03/24/2017');
|
day = moment('2017-03-24');
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// context('Every X Years', () => {
|
context('Every X Years', () => {
|
||||||
// it('leaves daily inactive if not the correct year', () => {
|
it('leaves daily inactive if not the correct year', () => {
|
||||||
// day = moment();
|
day = moment();
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'yearly';
|
dailyTask.frequency = 'yearly';
|
||||||
// day = day.add(1, 'day').toDate();
|
day = day.add(1, 'day').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
expect(shouldDo(day, dailyTask, options)).to.equal(false);
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// it('activates Daily on matching year', () => {
|
it('activates Daily on matching year', () => {
|
||||||
// day = moment();
|
day = moment();
|
||||||
// dailyTask.everyX = 2;
|
dailyTask.everyX = 2;
|
||||||
// dailyTask.frequency = 'yearly';
|
dailyTask.frequency = 'yearly';
|
||||||
// day = day.add(2, 'years').toDate();
|
day = day.add(2, 'years').toDate();
|
||||||
//
|
|
||||||
// expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
expect(shouldDo(day, dailyTask, options)).to.equal(true);
|
||||||
// });
|
});
|
||||||
// });
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user