Should do diff week fix (#9551)

* Fixed week difference when changing year

* Added year switchover test

* Fixed start date setting
This commit is contained in:
Keith Holliday
2017-11-20 12:22:01 -06:00
committed by GitHub
parent 1eb0f5baa5
commit 20a99e526d
2 changed files with 35 additions and 9 deletions

View File

@@ -644,7 +644,27 @@ describe('shouldDo', () => {
day = moment();
dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
dailyTask.everyX = 3;
let threeWeeksFromToday = day.add(6, 'weeks').day(day.day()).toDate();
const threeWeeksFromToday = day.add(6, 'weeks').day(day.day()).toDate();
expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
});
it('activates Daily on every (x) week on weekday across a year', () => {
dailyTask.repeat = {
su: false,
s: false,
f: false,
th: false,
w: false,
t: false,
m: false,
};
day = moment('2017-11-19');
dailyTask.startDate = day.toDate();
dailyTask.repeat[DAY_MAPPING[day.day()]] = true;
dailyTask.everyX = 3;
const threeWeeksFromToday = moment('2018-01-21');
expect(shouldDo(threeWeeksFromToday, dailyTask, options)).to.equal(true);
});
@@ -970,7 +990,7 @@ describe('shouldDo', () => {
m: false,
};
let today = moment('2017-01-26');
let today = moment('2017-01-26:00:00.000-00:00');
let week = today.monthWeek();
let dayOfWeek = today.day();
dailyTask.startDate = today.toDate();
@@ -979,7 +999,7 @@ describe('shouldDo', () => {
dailyTask.everyX = 2;
dailyTask.frequency = 'monthly';
day = moment('2017-03-24');
day = moment('2017-03-24:00:00.000-00:00');
expect(shouldDo(day, dailyTask, options)).to.equal(false);
});
@@ -995,7 +1015,7 @@ describe('shouldDo', () => {
m: false,
};
let today = moment('2017-01-27');
let today = moment('2017-01-27:00:00.000-00:00');
let week = today.monthWeek();
let dayOfWeek = today.day();
dailyTask.startDate = today.toDate();
@@ -1004,7 +1024,7 @@ describe('shouldDo', () => {
dailyTask.everyX = 2;
dailyTask.frequency = 'monthly';
day = moment('2017-03-24');
day = moment('2017-03-24:00:00.000-00:00');
expect(shouldDo(day, dailyTask, options)).to.equal(true);
});
@@ -1020,7 +1040,7 @@ describe('shouldDo', () => {
m: false,
};
let today = moment('2017-01-27');
let today = moment('2017-01-27:00:00.000-00:00');
let week = today.monthWeek();
let dayOfWeek = today.day();
dailyTask.startDate = today.toDate();
@@ -1029,7 +1049,7 @@ describe('shouldDo', () => {
dailyTask.everyX = 2;
dailyTask.frequency = 'monthly';
day = moment('2017-03-24');
day = moment('2017-03-24:00:00.000-00:00');
expect(shouldDo(day, dailyTask, options)).to.equal(true);
});