Improves all-day event row height calculation
Ensures consistent all-day event row height calculation across CSS and TypeScript. The all-day event row height calculation is adjusted by removing redundant container padding from the TypeScript constant and synchronizing the CSS variable with the event height. Additionally, the layout engine is directly tested in the test file for better coverage.
This commit is contained in:
parent
a1e1c5d185
commit
f2ad13776f
5 changed files with 58 additions and 53 deletions
|
|
@ -1,41 +1,43 @@
|
|||
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.length).toBe(1);
|
||||
expect(layouts[0].calenderEvent.id).toBe('test');
|
||||
expect(layouts[0].startColumn).toBe(3); // Sept 24 is column 3
|
||||
expect(layouts[0].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.length).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.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { AllDayLayoutEngine } from '../../src/utils/AllDayLayoutEngine';
|
||||
import { setupMockDOM, createMockEvent } from '../helpers/dom-helpers';
|
||||
|
||||
describe('AllDayManager - Layout Engine Integration', () => {
|
||||
let layoutEngine: AllDayLayoutEngine;
|
||||
|
||||
beforeEach(() => {
|
||||
setupMockDOM();
|
||||
});
|
||||
|
||||
describe('Layout Calculation Integration', () => {
|
||||
it('should delegate layout calculation to AllDayLayoutEngine', () => {
|
||||
// Test AllDayLayoutEngine directly since calculateAllDayEventsLayout is private
|
||||
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'];
|
||||
|
||||
layoutEngine = new AllDayLayoutEngine(weekDates);
|
||||
const layouts = layoutEngine.calculateLayout([event]);
|
||||
|
||||
expect(layouts.length).toBe(1);
|
||||
expect(layouts[0].calenderEvent.id).toBe('test');
|
||||
expect(layouts[0].startColumn).toBe(3); // Sept 24 is column 3
|
||||
expect(layouts[0].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'];
|
||||
layoutEngine = new AllDayLayoutEngine(weekDates);
|
||||
const layouts = layoutEngine.calculateLayout([]);
|
||||
|
||||
expect(layouts.length).toBe(0);
|
||||
});
|
||||
|
||||
it('should handle empty week dates', () => {
|
||||
const event = createMockEvent('test', 'Test Event', '2024-09-24', '2024-09-24');
|
||||
layoutEngine = new AllDayLayoutEngine([]);
|
||||
const layouts = layoutEngine.calculateLayout([event]);
|
||||
|
||||
expect(layouts.length).toBe(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue