Commit 3e55ec99 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch 'euko-small-roadmap-preset-mixins-refactor' into 'master'

Refactor hasStartDate* methods from roadmap preset mixins

See merge request gitlab-org/gitlab!49530
parents 780210f4 f64c7998
...@@ -96,11 +96,11 @@ export default { ...@@ -96,11 +96,11 @@ export default {
}, },
hasStartDate() { hasStartDate() {
if (this.presetTypeQuarters) { if (this.presetTypeQuarters) {
return this.hasStartDateForQuarter(); return this.hasStartDateForQuarter(this.timeframeItem);
} else if (this.presetTypeMonths) { } else if (this.presetTypeMonths) {
return this.hasStartDateForMonth(); return this.hasStartDateForMonth(this.timeframeItem);
} else if (this.presetTypeWeeks) { } else if (this.presetTypeWeeks) {
return this.hasStartDateForWeek(); return this.hasStartDateForWeek(this.timeframeItem);
} }
return false; return false;
}, },
......
...@@ -62,11 +62,11 @@ export default { ...@@ -62,11 +62,11 @@ export default {
}, },
hasStartDate() { hasStartDate() {
if (this.presetTypeQuarters) { if (this.presetTypeQuarters) {
return this.hasStartDateForQuarter(); return this.hasStartDateForQuarter(this.timeframeItem);
} else if (this.presetTypeMonths) { } else if (this.presetTypeMonths) {
return this.hasStartDateForMonth(); return this.hasStartDateForMonth(this.timeframeItem);
} else if (this.presetTypeWeeks) { } else if (this.presetTypeWeeks) {
return this.hasStartDateForWeek(); return this.hasStartDateForWeek(this.timeframeItem);
} }
return false; return false;
}, },
......
...@@ -5,10 +5,10 @@ export default { ...@@ -5,10 +5,10 @@ export default {
/** /**
* Check if current epic starts within current month (timeline cell) * Check if current epic starts within current month (timeline cell)
*/ */
hasStartDateForMonth() { hasStartDateForMonth(timeframeItem) {
return ( return (
this.startDateValues.month === this.timeframeItem.getMonth() && this.startDateValues.month === timeframeItem.getMonth() &&
this.startDateValues.year === this.timeframeItem.getFullYear() this.startDateValues.year === timeframeItem.getFullYear()
); );
}, },
/** /**
......
...@@ -5,9 +5,9 @@ export default { ...@@ -5,9 +5,9 @@ export default {
/** /**
* Check if current epic starts within current quarter (timeline cell) * Check if current epic starts within current quarter (timeline cell)
*/ */
hasStartDateForQuarter() { hasStartDateForQuarter(timeframeItem) {
const quarterStart = this.timeframeItem.range[0]; const quarterStart = timeframeItem.range[0];
const quarterEnd = this.timeframeItem.range[2]; const quarterEnd = timeframeItem.range[2];
return ( return (
this.startDateValues.time >= quarterStart.getTime() && this.startDateValues.time >= quarterStart.getTime() &&
......
...@@ -5,9 +5,9 @@ export default { ...@@ -5,9 +5,9 @@ export default {
/** /**
* Check if current epic starts within current week (timeline cell) * Check if current epic starts within current week (timeline cell)
*/ */
hasStartDateForWeek() { hasStartDateForWeek(timeframeItem) {
const firstDayOfWeek = this.timeframeItem; const firstDayOfWeek = timeframeItem;
const lastDayOfWeek = newDate(this.timeframeItem); const lastDayOfWeek = newDate(timeframeItem);
lastDayOfWeek.setDate(lastDayOfWeek.getDate() + 6); lastDayOfWeek.setDate(lastDayOfWeek.getDate() + 6);
return ( return (
......
...@@ -39,7 +39,7 @@ describe('MonthsPresetMixin', () => { ...@@ -39,7 +39,7 @@ describe('MonthsPresetMixin', () => {
timeframeItem: mockTimeframeMonths[1], timeframeItem: mockTimeframeMonths[1],
}); });
expect(wrapper.vm.hasStartDateForMonth()).toBe(true); expect(wrapper.vm.hasStartDateForMonth(mockTimeframeMonths[1])).toBe(true);
}); });
it('returns false when Epic.startDate does not fall within timeframeItem', () => { it('returns false when Epic.startDate does not fall within timeframeItem', () => {
...@@ -48,7 +48,7 @@ describe('MonthsPresetMixin', () => { ...@@ -48,7 +48,7 @@ describe('MonthsPresetMixin', () => {
timeframeItem: mockTimeframeMonths[1], timeframeItem: mockTimeframeMonths[1],
}); });
expect(wrapper.vm.hasStartDateForMonth()).toBe(false); expect(wrapper.vm.hasStartDateForMonth(mockTimeframeMonths[1])).toBe(false);
}); });
}); });
......
...@@ -39,7 +39,7 @@ describe('QuartersPresetMixin', () => { ...@@ -39,7 +39,7 @@ describe('QuartersPresetMixin', () => {
timeframeItem: mockTimeframeQuarters[1], timeframeItem: mockTimeframeQuarters[1],
}); });
expect(wrapper.vm.hasStartDateForQuarter()).toBe(true); expect(wrapper.vm.hasStartDateForQuarter(mockTimeframeQuarters[1])).toBe(true);
}); });
it('returns false when Epic.startDate does not fall within timeframeItem', () => { it('returns false when Epic.startDate does not fall within timeframeItem', () => {
...@@ -48,7 +48,7 @@ describe('QuartersPresetMixin', () => { ...@@ -48,7 +48,7 @@ describe('QuartersPresetMixin', () => {
timeframeItem: mockTimeframeQuarters[1], timeframeItem: mockTimeframeQuarters[1],
}); });
expect(wrapper.vm.hasStartDateForQuarter()).toBe(false); expect(wrapper.vm.hasStartDateForQuarter(mockTimeframeQuarters[1])).toBe(false);
}); });
}); });
......
...@@ -39,7 +39,7 @@ describe('WeeksPresetMixin', () => { ...@@ -39,7 +39,7 @@ describe('WeeksPresetMixin', () => {
timeframeItem: mockTimeframeWeeks[1], timeframeItem: mockTimeframeWeeks[1],
}); });
expect(wrapper.vm.hasStartDateForWeek()).toBe(true); expect(wrapper.vm.hasStartDateForWeek(mockTimeframeWeeks[1])).toBe(true);
}); });
it('returns false when Epic.startDate does not fall within timeframeItem', () => { it('returns false when Epic.startDate does not fall within timeframeItem', () => {
...@@ -48,7 +48,7 @@ describe('WeeksPresetMixin', () => { ...@@ -48,7 +48,7 @@ describe('WeeksPresetMixin', () => {
timeframeItem: mockTimeframeWeeks[1], timeframeItem: mockTimeframeWeeks[1],
}); });
expect(wrapper.vm.hasStartDateForWeek()).toBe(false); expect(wrapper.vm.hasStartDateForWeek(mockTimeframeWeeks[1])).toBe(false);
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment