Skip to content

Commit

Permalink
test to show more homogenous timegrid event width
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed May 6, 2021
1 parent f78e5b3 commit 9dbe94a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Expand Up @@ -5,9 +5,9 @@ v5.7.0
- feature: timeGridEventShortHeight
- fix: events can be completely hidden behind others with custom eventOrder (#6019)
- fix: +more shows on days with less events than dayMaxEvents (#6187)
- fix: less homogeneous event widths in timegrid (#5004)

write tests:
- fix: less homogeneous event widths in timegrid (#5004)
- feature: +more popover for timegrid (#4218)
- feature: +more popover for timeline (#4827)

Expand Down
32 changes: 32 additions & 0 deletions packages/__tests__/src/event-render/timeGrid-events.ts
Expand Up @@ -135,4 +135,36 @@ describe('timeGrid event rendering', () => {

expect(obscured).toBe(false)
})

// https://github.com/fullcalendar/fullcalendar/issues/5004
it('renders event widths somewhat equally', () => {
let calendar = initCalendar({
initialView: 'timeGridDay',
initialDate: '2019-08-01',
slotDuration: '00:15:00',
slotEventOverlap: false,
events: [
{start: '2019-08-01 08:00', end: '2019-08-01 09:00'},
{start: '2019-08-01 08:00', end: '2019-08-01 09:00'},
{start: '2019-08-01 08:30', end: '2019-08-01 09:30'},
{start: '2019-08-01 09:00', end: '2019-08-01 10:00'},
{start: '2019-08-01 09:00', end: '2019-08-01 10:00'},
{start: '2019-08-01 09:30', end: '2019-08-01 10:30'},
{start: '2019-08-01 09:30', end: '2019-08-01 10:30'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
{start: '2019-08-01 10:00', end: '2019-08-01 11:00'},
],
})
let timeGridWrapper = new TimeGridViewWrapper(calendar).timeGrid
let eventEls = timeGridWrapper.getEventEls()
let eventWidths = eventEls.map((eventEl) => eventEl.getBoundingClientRect().width)
eventWidths.sort() // sorts highest to lowest
eventWidths.splice(0, 1) // remove first item, which is exceptionally wide event
expect(Math.abs(eventWidths[0] - eventWidths[eventWidths.length - 1])).toBeLessThan(1)
})
})

0 comments on commit 9dbe94a

Please sign in to comment.