refactor: event instances
Signed-off-by: Sebastian Krupinski <krupinski01@gmail.com>
This commit is contained in:
@@ -66,6 +66,21 @@ describe('occurrence index', () => {
|
||||
expect(occurrencesForDay(index, new Date(2026, 5, 21))).toHaveLength(0)
|
||||
})
|
||||
|
||||
it('treats UTC timestamps on timeless events as floating calendar dates', () => {
|
||||
const allDay = eventEntity(
|
||||
'utc-all-day',
|
||||
'2025-03-27T00:00:00+00:00',
|
||||
'2025-03-28T00:00:00+00:00',
|
||||
true,
|
||||
)
|
||||
const index = buildOccurrenceIndex([allDay])
|
||||
|
||||
expect(occurrencesForDay(index, new Date(2025, 2, 26))).toHaveLength(0)
|
||||
expect(occurrencesForDay(index, new Date(2025, 2, 27))).toHaveLength(1)
|
||||
expect(occurrencesForDay(index, new Date(2025, 2, 28))).toHaveLength(0)
|
||||
expect(new Date(index.sorted[0].startMs).getHours()).toBe(0)
|
||||
})
|
||||
|
||||
it('retrieves overlapping occurrences without duplicates', () => {
|
||||
const spanning = eventEntity(
|
||||
'spanning',
|
||||
|
||||
@@ -87,6 +87,32 @@ describe('daily recurrence', () => {
|
||||
|
||||
expect(occurrences.map(occurrence => new Date(occurrence.startMs).getHours())).toEqual([9, 9, 9])
|
||||
})
|
||||
|
||||
it('preserves exclusive calendar-day duration for recurring timeless events', () => {
|
||||
const entity = recurringEntity({
|
||||
pattern: 'absolute',
|
||||
precision: 'daily',
|
||||
interval: 1,
|
||||
}, {}, '2026-03-07T00:00:00+00:00')
|
||||
const event = entity.properties as unknown as {
|
||||
endsOn: string
|
||||
timeless: boolean
|
||||
}
|
||||
event.endsOn = '2026-03-08T00:00:00+00:00'
|
||||
event.timeless = true
|
||||
|
||||
const occurrences = expandEntityOccurrences(
|
||||
entity,
|
||||
daysVisibleRange(new Date(2026, 2, 7), 3),
|
||||
)
|
||||
|
||||
expect(occurrences).toHaveLength(3)
|
||||
expect(occurrences.map(occurrence => new Date(occurrence.startMs).getHours())).toEqual([0, 0, 0])
|
||||
expect(occurrences.map(occurrence => {
|
||||
const end = new Date(occurrence.endMs)
|
||||
return [end.getDate(), end.getHours()]
|
||||
})).toEqual([[8, 0], [9, 0], [10, 0]])
|
||||
})
|
||||
})
|
||||
|
||||
describe('weekly recurrence', () => {
|
||||
|
||||
Reference in New Issue
Block a user