-
Notifications
You must be signed in to change notification settings - Fork 156
/
Copy pathRow.spec.ts
188 lines (179 loc) · 6.34 KB
/
Row.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
import { sampleData, zerothRecord } from './datasource.spec';
import { createGrid, destroy } from './treegridutil.spec';
import { TreeGrid } from '../../src';
import { Data } from '@syncfusion/ej2-grids';
import { profile, inMB, getMemoryProfile } from '../common.spec';
describe('TreeGrid Row module', () => {
beforeAll(() => {
const isDef = (o: any) => o !== undefined && o !== null;
if (!isDef(window.performance)) {
console.log('Unsupported environment, window.performance.memory is unavailable');
pending(); //Skips test (in Chai)
return;
}
});
describe('gridLines', () => {
let gridObj: TreeGrid;
let rows: Element[];
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
gridLines: 'None',
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('gridline testing', () => {
expect(gridObj.grid.element.classList.contains('e-hidelines')).toBe(true);
});
it('gridline setmodel testing', () => {
gridObj.gridLines = 'Vertical';
gridObj.dataBind();
expect(gridObj.grid.element.classList.contains('e-verticallines')).toBe(true);
});
afterAll(() => {
destroy(gridObj);
});
});
it('memory leak', () => {
profile.sample();
const average: any = inMB(profile.averageChange);
//Check average change in memory samples to not be over 10MB
expect(average).toBeLessThan(10);
const memory: any = inMB(getMemoryProfile());
//Check the final memory usage against the first usage, there should be little change if everything was properly deallocated
expect(memory).toBeLessThan(profile.samples[0] + 0.25);
});
});
describe('gridhover, alt row, rowHeight', () => {
let gridObj: TreeGrid;
let rows: Element[];
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('row hoversetmodel testing', () => {
gridObj.enableHover = false;
gridObj.dataBind();
expect(gridObj.grid.element.classList.contains('e-gridhover')).toBe(false);
gridObj.enableAltRow = false;
expect(gridObj.grid.element.classList.contains('e-altrow')).toBe(false);
});
it('row hoversetmodel testing', (done: Function) => {
gridObj.dataBound = (args: Object) => {
expect(gridObj.getRows()[1].style.height).toBe('60px');
done();
};
gridObj.rowHeight = 60;
gridObj.dataBind();
});
afterAll(() => {
destroy(gridObj);
});
});
describe('rows methods', () => {
let gridObj: TreeGrid;
let rows: Element[];
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('methods', () => {
rows = gridObj.getDataRows();
expect(rows.length).toEqual(gridObj.getCurrentViewRecords().length);
expect(gridObj.getRowInfo(<Element | EventTarget>gridObj.element).toString()).toBe({}.toString());
});
afterAll(() => {
destroy(gridObj);
});
});
describe('Indent for 0th level Row', () => {
let gridObj: TreeGrid;
let rows: Element[];
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: zerothRecord,
childMapping: 'subtasks',
treeColumnIndex: 1,
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('Testing Indent for 0th level Row that has no childrecords and 0th level record with chidrecord', () => {
expect(gridObj.getRowByIndex(0).querySelector('.e-icons.e-none')).not.toBe(null);
expect(gridObj.getRowByIndex(1).querySelector('.e-icons.e-none')).not.toBe(null);
expect((gridObj.getRowByIndex(0).querySelectorAll('.e-icons.e-none')).length).toBe(2);
expect((gridObj.getRowByIndex(1).querySelectorAll('.e-icons.e-none')).length).toBe(1);
});
afterAll(() => {
destroy(gridObj);
});
});
describe('height set through setmodel', () => {
let gridObj: TreeGrid;
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
height: 200,
treeColumnIndex: 1,
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('height set through setmodel method', () => {
gridObj.height = 600;
gridObj.dataBind();
expect((gridObj.getContent().firstChild as HTMLElement).style.height).toBe('600px');
});
afterAll(() => {
destroy(gridObj);
});
});
describe('alt row without paging', () => {
let gridObj: TreeGrid;
let rows: Element[];
beforeAll((done: Function) => {
gridObj = createGrid(
{
dataSource: sampleData,
childMapping: 'subtasks',
treeColumnIndex: 1,
columns: ['taskID', 'taskName', 'startDate', 'endDate', 'duration', 'progress']
},
done
);
});
it('checking alt row without paging', () => {
gridObj.enableAltRow = true;
rows = gridObj.getRows();
expect(rows[11].classList.contains('e-altrow')).toBe(true);
(rows[5].getElementsByClassName('e-treegridexpand')[0] as HTMLElement).click();
expect(rows[11].classList.contains('e-altrow')).toBe(false);
});
afterAll(() => {
destroy(gridObj);
});
});