Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for TimeSlots #1462

Merged
merged 2 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utils/TimeSlots.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export function getSlotMetrics({ min: start, max: end, step, timeslots }) {
const rangeStartMin = positionFromDate(rangeStart)
const rangeEndMin = positionFromDate(rangeEnd)
const top =
rangeEndMin - rangeStartMin < step && !dates.eq(end, rangeEnd)
rangeEndMin > step * (numSlots - 1) && !dates.eq(end, rangeEnd)
? ((rangeStartMin - step) / (step * numSlots)) * 100
: (rangeStartMin / (step * numSlots)) * 100

Expand Down
8 changes: 4 additions & 4 deletions test/utils/TimeSlots.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { getSlotMetrics } from '../../src/utils/TimeSlots'
import * as dates from '../../src/utils/dates'

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

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

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