Updates the all-day event layout engine for better event rendering, especially when dealing with partial week views. The layout engine now correctly clips events that start before or end after the visible date range, ensuring that only relevant portions of events are displayed. It also fixes event ordering. Includes new unit tests to validate date range filtering and clipping logic.
43 lines
No EOL
1.7 KiB
TypeScript
43 lines
No EOL
1.7 KiB
TypeScript
import { describe, it, expect, beforeEach } from 'vitest';
|
|
import { AllDayManager } from '../../src/managers/AllDayManager';
|
|
import { setupMockDOM, createMockEvent } from '../helpers/dom-helpers';
|
|
|
|
describe('AllDayManager - Manager Functionality', () => {
|
|
let allDayManager: AllDayManager;
|
|
|
|
beforeEach(() => {
|
|
setupMockDOM();
|
|
allDayManager = new AllDayManager();
|
|
});
|
|
|
|
describe('Layout Calculation Integration', () => {
|
|
it('should delegate layout calculation to AllDayLayoutEngine', () => {
|
|
// Simple integration test to verify manager uses the layout engine correctly
|
|
const event = createMockEvent('test', 'Test Event', '2024-09-24', '2024-09-24');
|
|
const weekDates = ['2024-09-22', '2024-09-23', '2024-09-24', '2024-09-25', '2024-09-26'];
|
|
|
|
const layouts = allDayManager.calculateAllDayEventsLayout([event], weekDates);
|
|
|
|
expect(layouts.size).toBe(1);
|
|
expect(layouts.has('test')).toBe(true);
|
|
|
|
const layout = layouts.get('test');
|
|
expect(layout?.startColumn).toBe(3); // Sept 24 is column 3
|
|
expect(layout?.row).toBe(1);
|
|
});
|
|
|
|
it('should handle empty event list', () => {
|
|
const weekDates = ['2024-09-22', '2024-09-23', '2024-09-24', '2024-09-25', '2024-09-26'];
|
|
const layouts = allDayManager.calculateAllDayEventsLayout([], weekDates);
|
|
|
|
expect(layouts.size).toBe(0);
|
|
});
|
|
|
|
it('should handle empty week dates', () => {
|
|
const event = createMockEvent('test', 'Test Event', '2024-09-24', '2024-09-24');
|
|
const layouts = allDayManager.calculateAllDayEventsLayout([event], []);
|
|
|
|
expect(layouts.size).toBe(0);
|
|
});
|
|
});
|
|
}); |