Check against the contract dates instead of the current maxStart and minEnd values to calculate the new maxStart and minEnds

This commit is contained in:
leigh-mil 2019-10-01 12:02:54 -04:00
parent b7677018c2
commit a5d34f9bb2
2 changed files with 6 additions and 4 deletions

View File

@ -20,13 +20,13 @@ describe('PopDateRange Test', () => {
const component = new Vue(PopDateRange) const component = new Vue(PopDateRange)
it('should calculate the max start date', () => { it('should calculate the max start date', () => {
component.maxStartDate = new Date('2020-01-01') component.contractEnd = new Date('2020-01-01')
const date = new Date('2019-12-31') const date = new Date('2019-12-31')
expect(component.calcMaxStartDate(date)).toEqual(date) expect(component.calcMaxStartDate(date)).toEqual(date)
}) })
it('should calculate the min end date', () => { it('should calculate the min end date', () => {
component.minEndDate = new Date('2020-01-01') component.contractStart = new Date('2020-01-01')
const date = new Date('2020-02-02') const date = new Date('2020-02-02')
expect(component.calcMinEndDate(date)).toEqual(date) expect(component.calcMinEndDate(date)).toEqual(date)
}) })

View File

@ -45,6 +45,8 @@ export default {
return { return {
maxStartDate: maxStartDate, maxStartDate: maxStartDate,
minEndDate: minEndDate, minEndDate: minEndDate,
contractStart: contractStart,
contractEnd: contractEnd,
} }
}, },
@ -60,7 +62,7 @@ export default {
}, },
calcMaxStartDate: function(date) { calcMaxStartDate: function(date) {
if (!!date && date < this.maxStartDate) { if (!!date && date < this.contractEnd) {
return date return date
} else { } else {
return this.maxStartDate return this.maxStartDate
@ -68,7 +70,7 @@ export default {
}, },
calcMinEndDate: function(date) { calcMinEndDate: function(date) {
if (!!date && date > this.minEndDate) { if (!!date && date > this.contractStart) {
return date return date
} else { } else {
return this.minEndDate return this.minEndDate