Commit f64c7998 authored by Eulyeon Ko's avatar Eulyeon Ko

Refactor hasStartDate- method from mixins

Make the following methods accept "timeframeItem"
explicitly as an argument:
hasStartDateForWeeks (from WeeksPresetMixin)
hasStartDateForMonths (from MonthsPresetMixin)
hasStartDateForQuarters (from QuartersPresetMixin)

This change makes it easier to reason about the
dependencies of the methods.
parent d1b77d04
......@@ -96,11 +96,11 @@ export default {
},
hasStartDate() {
if (this.presetTypeQuarters) {
return this.hasStartDateForQuarter();
return this.hasStartDateForQuarter(this.timeframeItem);
} else if (this.presetTypeMonths) {
return this.hasStartDateForMonth();
return this.hasStartDateForMonth(this.timeframeItem);
} else if (this.presetTypeWeeks) {
return this.hasStartDateForWeek();
return this.hasStartDateForWeek(this.timeframeItem);
}
return false;
},
......
......@@ -62,11 +62,11 @@ export default {
},
hasStartDate() {
if (this.presetTypeQuarters) {
return this.hasStartDateForQuarter();
return this.hasStartDateForQuarter(this.timeframeItem);
} else if (this.presetTypeMonths) {
return this.hasStartDateForMonth();
return this.hasStartDateForMonth(this.timeframeItem);
} else if (this.presetTypeWeeks) {
return this.hasStartDateForWeek();
return this.hasStartDateForWeek(this.timeframeItem);
}
return false;
},
......
......@@ -5,10 +5,10 @@ export default {
/**
* Check if current epic starts within current month (timeline cell)
*/
hasStartDateForMonth() {
hasStartDateForMonth(timeframeItem) {
return (
this.startDateValues.month === this.timeframeItem.getMonth() &&
this.startDateValues.year === this.timeframeItem.getFullYear()
this.startDateValues.month === timeframeItem.getMonth() &&
this.startDateValues.year === timeframeItem.getFullYear()
);
},
/**
......
......@@ -5,9 +5,9 @@ export default {
/**
* Check if current epic starts within current quarter (timeline cell)
*/
hasStartDateForQuarter() {
const quarterStart = this.timeframeItem.range[0];
const quarterEnd = this.timeframeItem.range[2];
hasStartDateForQuarter(timeframeItem) {
const quarterStart = timeframeItem.range[0];
const quarterEnd = timeframeItem.range[2];
return (
this.startDateValues.time >= quarterStart.getTime() &&
......
......@@ -5,9 +5,9 @@ export default {
/**
* Check if current epic starts within current week (timeline cell)
*/
hasStartDateForWeek() {
const firstDayOfWeek = this.timeframeItem;
const lastDayOfWeek = newDate(this.timeframeItem);
hasStartDateForWeek(timeframeItem) {
const firstDayOfWeek = timeframeItem;
const lastDayOfWeek = newDate(timeframeItem);
lastDayOfWeek.setDate(lastDayOfWeek.getDate() + 6);
return (
......
......@@ -39,7 +39,7 @@ describe('MonthsPresetMixin', () => {
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', () => {
......@@ -48,7 +48,7 @@ describe('MonthsPresetMixin', () => {
timeframeItem: mockTimeframeMonths[1],
});
expect(wrapper.vm.hasStartDateForMonth()).toBe(false);
expect(wrapper.vm.hasStartDateForMonth(mockTimeframeMonths[1])).toBe(false);
});
});
......
......@@ -39,7 +39,7 @@ describe('QuartersPresetMixin', () => {
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', () => {
......@@ -48,7 +48,7 @@ describe('QuartersPresetMixin', () => {
timeframeItem: mockTimeframeQuarters[1],
});
expect(wrapper.vm.hasStartDateForQuarter()).toBe(false);
expect(wrapper.vm.hasStartDateForQuarter(mockTimeframeQuarters[1])).toBe(false);
});
});
......
......@@ -39,7 +39,7 @@ describe('WeeksPresetMixin', () => {
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', () => {
......@@ -48,7 +48,7 @@ describe('WeeksPresetMixin', () => {
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