Skip to content

Commit c31639a

Browse files
authored
fix: for TimeSlots (jquense#1462)
* Fix for TimeSlots * Fixes tests
1 parent 70b3e96 commit c31639a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/utils/TimeSlots.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
131131
const rangeStartMin = positionFromDate(rangeStart)
132132
const rangeEndMin = positionFromDate(rangeEnd)
133133
const top =
134-
rangeEndMin - rangeStartMin < step && !dates.eq(end, rangeEnd)
134+
rangeEndMin > step * (numSlots - 1) && !dates.eq(end, rangeEnd)
135135
? ((rangeStartMin - step) / (step * numSlots)) * 100
136136
: (rangeStartMin / (step * numSlots)) * 100
137137

test/utils/TimeSlots.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { getSlotMetrics } from '../../src/utils/TimeSlots'
22
import * as dates from '../../src/utils/dates'
33

44
describe('getSlotMetrics', () => {
5-
const min = dates.startOf(new Date(), 'day')
6-
const max = dates.endOf(new Date(), 'day')
5+
const min = dates.startOf(new Date(2018, 0, 29, 0, 0, 0), 'day')
6+
const max = dates.endOf(new Date(2018, 0, 29, 59, 59, 59), 'day')
77
const slotMetrics = getSlotMetrics({ min, max, step: 60, timeslots: 1 })
88
test('getSlotMetrics.closestSlotToPosition: always returns timeslot if valid percentage is given', () => {
99
expect(slotMetrics.closestSlotToPosition(0)).toBeDefined()
@@ -24,8 +24,8 @@ describe('getSlotMetrics', () => {
2424
})
2525

2626
describe('getRange', () => {
27-
const min = dates.startOf(new Date(), 'day')
28-
const max = dates.endOf(new Date(), 'day')
27+
const min = dates.startOf(new Date(2018, 0, 29, 0, 0, 0), 'day')
28+
const max = dates.endOf(new Date(2018, 0, 29, 59, 59, 59), 'day')
2929
const slotMetrics = getSlotMetrics({ min, max, step: 60, timeslots: 1 })
3030

3131
test('getRange: 15 minute start of day appointment stays within calendar', () => {

0 commit comments

Comments
 (0)