add minimum duration for DOM parser

This commit is contained in:
Ondřej Synáček 2020-07-16 10:39:32 +02:00
parent 401ff587e2
commit 8458ae0b69
2 changed files with 5 additions and 3 deletions

View File

@ -20,9 +20,11 @@ const parseDate = (timeText = '') => {
const normalizedEndTime = endTime.isValid() ? endTime : dayjs(new Date())
const { start, duration } = parseDates(normalizedStartTime, normalizedEndTime)
const minimumDuration = { ...duration, minutes: duration.minutes || 120 }
return {
start,
duration,
duration: minimumDuration,
}
}

View File

@ -72,7 +72,7 @@ describe(parseUsingDOM, () => {
})
it('should return duration based on current time if ' +
it('should return duration of minimum 120 minutes if ' +
'no time data is found', () => {
const now = new Date('2020-01-01 12:00:00')
const spy = jest
@ -95,7 +95,7 @@ describe(parseUsingDOM, () => {
spy.mockRestore()
expect(duration).to.deep.equal({ minutes: 0 })
expect(duration).to.deep.equal({ minutes: 120 })
})