Skip to content

Commit 37a82c0

Browse files
committed
test: reerrange tests
1 parent 7f828cf commit 37a82c0

File tree

2 files changed

+75
-72
lines changed

2 files changed

+75
-72
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import {
2+
describe, expect, it, jest,
3+
} from '@jest/globals';
4+
5+
import { getResourceManagerMock } from '../__mock__/resource_manager.mock';
6+
import SchedulerTimelineDay from '../workspaces/m_timeline_day';
7+
import SchedulerTimelineMonth from '../workspaces/m_timeline_month';
8+
import SchedulerTimelineWeek from '../workspaces/m_timeline_week';
9+
import SchedulerTimelineWorkWeek from '../workspaces/m_timeline_work_week';
10+
import type SchedulerWorkSpace from '../workspaces/m_work_space';
11+
import SchedulerWorkSpaceDay from '../workspaces/m_work_space_day';
12+
import SchedulerWorkSpaceMonth from '../workspaces/m_work_space_month';
13+
import SchedulerWorkSpaceWeek from '../workspaces/m_work_space_week';
14+
import SchedulerWorkSpaceWorkWeek from '../workspaces/m_work_space_work_week';
15+
16+
type WorkspaceConstructor<T> = new (container: Element, options?: any) => T;
17+
18+
const createWorkspace = <T extends SchedulerWorkSpace>(
19+
WorkSpace: WorkspaceConstructor<T>,
20+
currentView: string,
21+
): T => {
22+
const container = document.createElement('div');
23+
const workspace = new WorkSpace(container, {
24+
views: [currentView],
25+
currentView,
26+
currentDate: new Date(2017, 4, 25),
27+
firstDayOfWeek: 0,
28+
getResourceManager: () => getResourceManagerMock([]),
29+
});
30+
(workspace as any)._isVisible = () => true;
31+
expect(container.classList).toContain('dx-scheduler-work-space');
32+
33+
return workspace;
34+
};
35+
const workSpaces: {
36+
currentView: string;
37+
WorkSpace: WorkspaceConstructor<SchedulerWorkSpace>;
38+
}[] = [
39+
{ currentView: 'day', WorkSpace: SchedulerWorkSpaceDay },
40+
{ currentView: 'week', WorkSpace: SchedulerWorkSpaceWeek },
41+
{ currentView: 'workWeek', WorkSpace: SchedulerWorkSpaceWorkWeek },
42+
{ currentView: 'month', WorkSpace: SchedulerWorkSpaceMonth },
43+
{ currentView: 'timelineDay', WorkSpace: SchedulerTimelineDay },
44+
{ currentView: 'timelineWeek', WorkSpace: SchedulerTimelineWeek },
45+
{ currentView: 'timelineWorkWeek', WorkSpace: SchedulerTimelineWorkWeek },
46+
{ currentView: 'timelineMonth', WorkSpace: SchedulerTimelineMonth },
47+
];
48+
49+
describe('scheduler workspace', () => {
50+
workSpaces.forEach(({ currentView, WorkSpace }) => {
51+
it(`should clear cache on dimension change, view: ${currentView}`, () => {
52+
const workspace = createWorkspace(WorkSpace, currentView);
53+
jest.spyOn(workspace.cache, 'clear');
54+
55+
workspace.cache.memo('test', () => 'value');
56+
workspace._dimensionChanged();
57+
58+
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
59+
});
60+
61+
it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
62+
const workspace = createWorkspace(WorkSpace, currentView);
63+
jest.spyOn(workspace.cache, 'clear');
64+
65+
workspace.cache.memo('test', () => 'value');
66+
workspace._cleanView();
67+
68+
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
69+
expect(workspace.cache.size).toBe(0);
70+
});
71+
});
72+
});

packages/devextreme/js/__internal/scheduler/__tests__/workspace.test.ts

Lines changed: 3 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@ import { getWidth } from '@js/core/utils/size';
66

77
import fx from '../../../common/core/animation/fx';
88
import CustomStore from '../../../data/custom_store';
9-
import { getResourceManagerMock } from '../__mock__/resource_manager.mock';
10-
import SchedulerTimelineDay from '../workspaces/m_timeline_day';
11-
import SchedulerTimelineMonth from '../workspaces/m_timeline_month';
12-
import SchedulerTimelineWeek from '../workspaces/m_timeline_week';
13-
import SchedulerTimelineWorkWeek from '../workspaces/m_timeline_work_week';
14-
import type SchedulerWorkSpace from '../workspaces/m_work_space';
15-
import SchedulerWorkSpaceDay from '../workspaces/m_work_space_day';
16-
import SchedulerWorkSpaceMonth from '../workspaces/m_work_space_month';
17-
import SchedulerWorkSpaceWeek from '../workspaces/m_work_space_week';
18-
import SchedulerWorkSpaceWorkWeek from '../workspaces/m_work_space_work_week';
199
import { createScheduler } from './__mock__/create_scheduler';
2010
import { setupSchedulerTestEnvironment } from './__mock__/m_mock_scheduler';
2111

@@ -24,67 +14,8 @@ const CLASSES = {
2414
workSpace: 'dx-scheduler-work-space',
2515
};
2616

27-
type WorkspaceConstructor<T> = new (container: Element, options?: any) => T;
28-
29-
const createWorkspace = <T extends SchedulerWorkSpace>(
30-
WorkSpace: WorkspaceConstructor<T>,
31-
currentView: string,
32-
): T => {
33-
const container = document.createElement('div');
34-
const workspace = new WorkSpace(container, {
35-
views: [currentView],
36-
currentView,
37-
currentDate: new Date(2017, 4, 25),
38-
firstDayOfWeek: 0,
39-
getResourceManager: () => getResourceManagerMock([]),
40-
});
41-
(workspace as any)._isVisible = () => true;
42-
expect(container.classList).toContain('dx-scheduler-work-space');
43-
44-
return workspace;
45-
};
46-
47-
const workSpaces: {
48-
currentView: string;
49-
WorkSpace: WorkspaceConstructor<SchedulerWorkSpace>;
50-
}[] = [
51-
{ currentView: 'day', WorkSpace: SchedulerWorkSpaceDay },
52-
{ currentView: 'week', WorkSpace: SchedulerWorkSpaceWeek },
53-
{ currentView: 'workWeek', WorkSpace: SchedulerWorkSpaceWorkWeek },
54-
{ currentView: 'month', WorkSpace: SchedulerWorkSpaceMonth },
55-
{ currentView: 'timelineDay', WorkSpace: SchedulerTimelineDay },
56-
{ currentView: 'timelineWeek', WorkSpace: SchedulerTimelineWeek },
57-
{ currentView: 'timelineWorkWeek', WorkSpace: SchedulerTimelineWorkWeek },
58-
{ currentView: 'timelineMonth', WorkSpace: SchedulerTimelineMonth },
59-
];
60-
6117
describe('Workspace', () => {
62-
describe('Base functionality', () => {
63-
workSpaces.forEach(({ currentView, WorkSpace }) => {
64-
it(`should clear cache on dimension change, view: ${currentView}`, () => {
65-
const workspace = createWorkspace(WorkSpace, currentView);
66-
jest.spyOn(workspace.cache, 'clear');
67-
68-
workspace.cache.memo('test', () => 'value');
69-
workspace._dimensionChanged();
70-
71-
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
72-
});
73-
74-
it(`should clear cache on _cleanView call, view: ${currentView}`, () => {
75-
const workspace = createWorkspace(WorkSpace, currentView);
76-
jest.spyOn(workspace.cache, 'clear');
77-
78-
workspace.cache.memo('test', () => 'value');
79-
workspace._cleanView();
80-
81-
expect(workspace.cache.clear).toHaveBeenCalledTimes(1);
82-
expect(workspace.cache.size).toBe(0);
83-
});
84-
});
85-
});
86-
87-
describe('Recalculation with Async Templates', () => {
18+
describe('Recalculation with Async Templates (T661335)', () => {
8819
beforeEach(() => {
8920
fx.off = true;
9021
setupSchedulerTestEnvironment({ height: 600 });
@@ -149,7 +80,7 @@ describe('Workspace', () => {
14980
});
15081
});
15182

152-
describe('scrollTo', () => {
83+
describe('scrollTo (T1310544)', () => {
15384
beforeEach(() => {
15485
fx.off = true;
15586
setupSchedulerTestEnvironment({ height: 600 });
@@ -160,7 +91,7 @@ describe('Workspace', () => {
16091
fx.off = false;
16192
});
16293

163-
it('should scroll to date with offset (T1310544)', async () => {
94+
it('T1310544: should scroll to date with offset: 720 (12 hours)', async () => {
16495
const { scheduler } = await createScheduler({
16596
views: ['timelineDay'],
16697
currentView: 'timelineDay',

0 commit comments

Comments
 (0)