Tests all-day event layout calculations
Adds comprehensive tests for the AllDayManager, covering various overlap scenarios. Tests ensure correct row and column assignments for all-day events based on date ranges and overlaps. Replaces individual event layout calculation with batch calculation for improved performance and test coverage.
This commit is contained in:
parent
a624394ffb
commit
a551bc59ff
2 changed files with 126 additions and 77 deletions
40
test/helpers/dom-helpers.ts
Normal file
40
test/helpers/dom-helpers.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { CalendarEvent } from '../../src/types/CalendarTypes';
|
||||
|
||||
/**
|
||||
* Setup mock DOM for testing
|
||||
*/
|
||||
export function setupMockDOM(): void {
|
||||
// Create basic DOM structure for testing
|
||||
document.body.innerHTML = `
|
||||
<div class="swp-calendar-grid" data-current="true">
|
||||
<div class="swp-day-header" data-date="2024-09-22"></div>
|
||||
<div class="swp-day-header" data-date="2024-09-23"></div>
|
||||
<div class="swp-day-header" data-date="2024-09-24"></div>
|
||||
<div class="swp-day-header" data-date="2024-09-25"></div>
|
||||
<div class="swp-day-header" data-date="2024-09-26"></div>
|
||||
</div>
|
||||
<swp-calendar-header>
|
||||
<swp-allday-container></swp-allday-container>
|
||||
</swp-calendar-header>
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create mock CalendarEvent for testing
|
||||
*/
|
||||
export function createMockEvent(
|
||||
id: string,
|
||||
title: string,
|
||||
startDate: string,
|
||||
endDate: string
|
||||
): CalendarEvent {
|
||||
return {
|
||||
id,
|
||||
title,
|
||||
start: new Date(startDate),
|
||||
end: new Date(endDate),
|
||||
type: 'work',
|
||||
allDay: true,
|
||||
syncStatus: 'synced'
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue