Refactors layout engine tests to use arrays
Updates tests to use arrays instead of Maps for storing layouts. This simplifies the data structures and allows for more straightforward assertions.
This commit is contained in:
parent
6ccc071587
commit
7fc401b1df
2 changed files with 20 additions and 22 deletions
|
|
@ -102,11 +102,11 @@ describe('AllDay Layout Engine - Pure Data Tests', () => {
|
|||
const layouts = layoutEngine.calculateLayout(testCase.events);
|
||||
|
||||
// Verify we got layouts for all events
|
||||
expect(layouts.size).toBe(testCase.events.length);
|
||||
expect(layouts.length).toBe(testCase.events.length);
|
||||
|
||||
// Check each expected result
|
||||
testCase.expected.forEach(expected => {
|
||||
const actualLayout = layouts.get(expected.id);
|
||||
const actualLayout = layouts.find(layout => layout.calenderEvent.id === expected.id);
|
||||
expect(actualLayout).toBeDefined();
|
||||
expect(actualLayout!.gridArea).toBe(expected.gridArea);
|
||||
});
|
||||
|
|
@ -168,16 +168,16 @@ describe('AllDay Layout Engine - Partial Week Views', () => {
|
|||
const layouts = engine.calculateLayout(events);
|
||||
|
||||
// Both events are now visible since '112' ends on Wednesday (visible range start)
|
||||
expect(layouts.size).toBe(2);
|
||||
expect(layouts.has('112')).toBe(true); // Now visible since it ends on Wed
|
||||
expect(layouts.has('113')).toBe(true); // Still visible
|
||||
expect(layouts.length).toBe(2);
|
||||
expect(layouts.some(layout => layout.calenderEvent.id === '112')).toBe(true); // Now visible since it ends on Wed
|
||||
expect(layouts.some(layout => layout.calenderEvent.id === '113')).toBe(true); // Still visible
|
||||
|
||||
const layout112 = layouts.get('112')!;
|
||||
const layout112 = layouts.find(layout => layout.calenderEvent.id === '112')!;
|
||||
expect(layout112.startColumn).toBe(1); // Clipped to Wed (first visible day)
|
||||
expect(layout112.endColumn).toBe(1); // Wed only
|
||||
expect(layout112.row).toBe(1);
|
||||
|
||||
const layout113 = layouts.get('113')!;
|
||||
const layout113 = layouts.find(layout => layout.calenderEvent.id === '113')!;
|
||||
expect(layout113.startColumn).toBe(2); // Thursday = column 2 in Wed-Fri view
|
||||
expect(layout113.endColumn).toBe(3); // Friday = column 3
|
||||
expect(layout113.row).toBe(1);
|
||||
|
|
@ -211,17 +211,17 @@ describe('AllDay Layout Engine - Partial Week Views', () => {
|
|||
|
||||
const layouts = engine.calculateLayout(events);
|
||||
|
||||
expect(layouts.size).toBe(2);
|
||||
expect(layouts.length).toBe(2);
|
||||
|
||||
// First event should be clipped to start at Wed (column 1) and end at Fri (column 3)
|
||||
const firstLayout = layouts.get('114')!;
|
||||
const firstLayout = layouts.find(layout => layout.calenderEvent.id === '114')!;
|
||||
expect(firstLayout.startColumn).toBe(1); // Clipped to Wed (first visible day)
|
||||
expect(firstLayout.endColumn).toBe(3); // Fri (now ends on Friday due to 2025-09-26T00:00:00)
|
||||
expect(firstLayout.columnSpan).toBe(3);
|
||||
expect(firstLayout.gridArea).toBe('1 / 1 / 2 / 4');
|
||||
|
||||
// Second event should span Thu-Fri, but clipped beyond visible range
|
||||
const secondLayout = layouts.get('115')!;
|
||||
const secondLayout = layouts.find(layout => layout.calenderEvent.id === '115')!;
|
||||
expect(secondLayout.startColumn).toBe(2); // Thu (actual start date) = column 2 in Wed-Fri view
|
||||
expect(secondLayout.endColumn).toBe(3); // Clipped to Fri (last visible day) = column 3
|
||||
expect(secondLayout.columnSpan).toBe(2);
|
||||
|
|
@ -256,11 +256,11 @@ describe('AllDay Layout Engine - Partial Week Views', () => {
|
|||
|
||||
const layouts = engine.calculateLayout(events);
|
||||
|
||||
expect(layouts.size).toBe(1); // Only Monday event should be included - weekend event should be filtered out
|
||||
expect(layouts.has('116')).toBe(true); // Monday event should be included
|
||||
expect(layouts.has('117')).toBe(false); // Weekend event should be filtered out
|
||||
expect(layouts.length).toBe(1); // Only Monday event should be included - weekend event should be filtered out
|
||||
expect(layouts.some(layout => layout.calenderEvent.id === '116')).toBe(true); // Monday event should be included
|
||||
expect(layouts.some(layout => layout.calenderEvent.id === '117')).toBe(false); // Weekend event should be filtered out
|
||||
|
||||
const mondayLayout = layouts.get('116')!;
|
||||
const mondayLayout = layouts.find(layout => layout.calenderEvent.id === '116')!;
|
||||
expect(mondayLayout.startColumn).toBe(1); // Monday = column 1
|
||||
expect(mondayLayout.endColumn).toBe(2); // Now ends on Tuesday due to 2025-09-23T00:00:00
|
||||
expect(mondayLayout.row).toBe(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue