Skip to content

Commit 79f72f3

Browse files
Scheduler New Form — Refactor mock: merge width/height into classRects for cell elements
1 parent eb322e9 commit 79f72f3

1 file changed

Lines changed: 13 additions & 19 deletions

File tree

packages/devextreme/js/__internal/scheduler/__tests__/__mock__/m_mock_scheduler.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,30 +50,24 @@ export const setupSchedulerTestEnvironment = ({
5050
width: 0, height: 0, top: 0, left: 0, bottom: 0, right: 0, x: 0, y: 0, toJSON: (): void => {},
5151
};
5252

53+
const cellRect = {
54+
width, height, bottom: height, right: width,
55+
};
56+
57+
const mergedRects: ClassRects = {
58+
'dx-scheduler-date-table-cell': cellRect,
59+
'dx-scheduler-all-day-table-cell': cellRect,
60+
...classRects,
61+
};
62+
5363
Element.prototype.getBoundingClientRect = jest.fn(function (): DOMRect {
5464
const classList: string[] = Array.from(this.classList);
5565

56-
const matchedClass = classList.find((className) => classRects[className]);
66+
const matchedClass = classList.find((className) => mergedRects[className]);
5767
if (matchedClass) {
58-
return { ...defaultRect, ...classRects[matchedClass] };
68+
return { ...defaultRect, ...mergedRects[matchedClass] };
5969
}
6070

61-
switch (true) {
62-
case classList.includes('dx-scheduler-date-table-cell')
63-
|| classList.includes('dx-scheduler-all-day-table-cell'):
64-
return {
65-
width,
66-
height,
67-
top: 0,
68-
left: 0,
69-
bottom: height,
70-
right: width,
71-
x: 0,
72-
y: 0,
73-
toJSON: (): void => {},
74-
};
75-
default:
76-
return defaultRect;
77-
}
71+
return defaultRect;
7872
});
7973
};

0 commit comments

Comments
 (0)