Skip to content

Commit 3497d40

Browse files
committed
Fix virtualScroll spec
1 parent c6a2a97 commit 3497d40

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

src/components/virtual-scroll/test/virtual-scroll.spec.ts

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ describe('VirtualScroll', () => {
2222
ftrWidth: viewportWidth,
2323
ftrHeight: HEIGHT_FOOTER
2424
};
25-
window.getComputedStyle = function() {
25+
window.getComputedStyle = function () {
2626
var styles: any = {
2727
marginTop: '0px',
2828
marginRight: '0px',
@@ -33,7 +33,7 @@ describe('VirtualScroll', () => {
3333
};
3434
});
3535

36-
describe('estimateHeight', () => {
36+
describe('estimateHeight', () => {
3737

3838
it('should return zero when no records', () => {
3939
const h = estimateHeight(0, undefined, 100, .25);
@@ -42,14 +42,14 @@ describe('VirtualScroll', () => {
4242

4343
});
4444

45-
describe('processRecords', () => {
45+
describe('processRecords', () => {
4646

4747
it('should load data for 100% width items', () => {
4848
records = [0, 1, 2, 3, 4];
4949
let stopAtHeight = 200;
5050

5151
processRecords(stopAtHeight, records, cells,
52-
headerFn, footerFn, data);
52+
headerFn, footerFn, data);
5353

5454
expect(cells.length).toBe(4);
5555

@@ -81,16 +81,16 @@ describe('VirtualScroll', () => {
8181
data.hdrWidth = data.viewWidth; // 100%, 1 per row
8282
data.ftrWidth = data.viewWidth; // 100%, 1 per row
8383

84-
headerFn = function(record: any) {
84+
headerFn = function (record: any) {
8585
return (record === 0) ? 'Header' : null;
8686
};
8787

88-
footerFn = function(record: any) {
88+
footerFn = function (record: any) {
8989
return (record === 4) ? 'Footer' : null;
9090
};
9191

9292
processRecords(stopAtHeight, records, cells,
93-
headerFn, footerFn, data);
93+
headerFn, footerFn, data);
9494

9595
expect(cells.length).toBe(7);
9696

@@ -165,12 +165,12 @@ describe('VirtualScroll', () => {
165165
data.itmWidth = 90; // 2 per row
166166
data.hdrWidth = data.viewWidth; // 100%, 1 per row
167167

168-
headerFn = function(record: any) {
168+
headerFn = function (record: any) {
169169
return (record === 0) ? 'Header' : null;
170170
};
171171

172172
processRecords(stopAtHeight, records, cells,
173-
headerFn, footerFn, data);
173+
headerFn, footerFn, data);
174174

175175
expect(cells.length).toBe(5);
176176

@@ -188,7 +188,7 @@ describe('VirtualScroll', () => {
188188

189189
stopAtHeight = 150;
190190
processRecords(stopAtHeight, records, cells,
191-
headerFn, footerFn, data);
191+
headerFn, footerFn, data);
192192

193193
expect(cells[2].row).toBe(1);
194194
expect(cells[2].top).toBe(HEIGHT_HEADER);
@@ -206,7 +206,7 @@ describe('VirtualScroll', () => {
206206

207207
stopAtHeight = 20000;
208208
processRecords(stopAtHeight, records, cells,
209-
headerFn, footerFn, data);
209+
headerFn, footerFn, data);
210210

211211
expect(cells.length).toBe(11);
212212

@@ -230,36 +230,36 @@ describe('VirtualScroll', () => {
230230
let endCellIndex = 0;
231231

232232
populateNodeData(startCellIndex, endCellIndex, true,
233-
cells, records, nodes, viewContainer,
234-
itmTmp, hdrTmp, ftrTmp, false);
233+
cells, records, nodes, viewContainer,
234+
itmTmp, hdrTmp, ftrTmp);
235235

236236
expect(nodes.length).toBe(0);
237237
});
238238

239239
it('should skip already rendered, and create nodes', () => {
240240
cells = [
241-
{row: 0, tmpl: TEMPLATE_ITEM},
242-
{row: 1, tmpl: TEMPLATE_ITEM},
243-
{row: 2, tmpl: TEMPLATE_HEADER},
244-
{row: 3, tmpl: TEMPLATE_ITEM},
245-
{row: 4, tmpl: TEMPLATE_FOOTER},
246-
{row: 5, tmpl: TEMPLATE_ITEM},
247-
{row: 6, tmpl: TEMPLATE_ITEM, reads: 0}
241+
{ row: 0, tmpl: TEMPLATE_ITEM },
242+
{ row: 1, tmpl: TEMPLATE_ITEM },
243+
{ row: 2, tmpl: TEMPLATE_HEADER },
244+
{ row: 3, tmpl: TEMPLATE_ITEM },
245+
{ row: 4, tmpl: TEMPLATE_FOOTER },
246+
{ row: 5, tmpl: TEMPLATE_ITEM },
247+
{ row: 6, tmpl: TEMPLATE_ITEM, reads: 0 }
248248
];
249249

250250
nodes = [
251-
{cell: 0, tmpl: TEMPLATE_ITEM, view: getView()},
252-
{cell: 1, tmpl: TEMPLATE_ITEM, view: getView()},
253-
{cell: 2, tmpl: TEMPLATE_HEADER, view: getView()},
254-
{cell: 3, tmpl: TEMPLATE_ITEM, view: getView()},
251+
{ cell: 0, tmpl: TEMPLATE_ITEM, view: getView() },
252+
{ cell: 1, tmpl: TEMPLATE_ITEM, view: getView() },
253+
{ cell: 2, tmpl: TEMPLATE_HEADER, view: getView() },
254+
{ cell: 3, tmpl: TEMPLATE_ITEM, view: getView() },
255255
];
256256

257257
let startCellIndex = 2;
258258
let endCellIndex = 5;
259259

260260
populateNodeData(startCellIndex, endCellIndex, true,
261-
cells, records, nodes, viewContainer,
262-
itmTmp, hdrTmp, ftrTmp, false);
261+
cells, records, nodes, viewContainer,
262+
itmTmp, hdrTmp, ftrTmp);
263263

264264
expect(nodes.length).toBe(5);
265265

@@ -274,21 +274,21 @@ describe('VirtualScroll', () => {
274274

275275
it('should create nodes', () => {
276276
cells = [
277-
{row: 0, tmpl: TEMPLATE_ITEM},
278-
{row: 1, tmpl: TEMPLATE_ITEM},
279-
{row: 2, tmpl: TEMPLATE_HEADER},
280-
{row: 3, tmpl: TEMPLATE_ITEM},
281-
{row: 4, tmpl: TEMPLATE_FOOTER},
282-
{row: 5, tmpl: TEMPLATE_ITEM},
283-
{row: 6, tmpl: TEMPLATE_ITEM}
277+
{ row: 0, tmpl: TEMPLATE_ITEM },
278+
{ row: 1, tmpl: TEMPLATE_ITEM },
279+
{ row: 2, tmpl: TEMPLATE_HEADER },
280+
{ row: 3, tmpl: TEMPLATE_ITEM },
281+
{ row: 4, tmpl: TEMPLATE_FOOTER },
282+
{ row: 5, tmpl: TEMPLATE_ITEM },
283+
{ row: 6, tmpl: TEMPLATE_ITEM }
284284
];
285285

286286
let startCellIndex = 2;
287287
let endCellIndex = 4;
288288

289289
populateNodeData(startCellIndex, endCellIndex, true,
290-
cells, records, nodes, viewContainer,
291-
itmTmp, hdrTmp, ftrTmp, true);
290+
cells, records, nodes, viewContainer,
291+
itmTmp, hdrTmp, ftrTmp);
292292

293293
expect(nodes.length).toBe(3);
294294

@@ -308,21 +308,21 @@ describe('VirtualScroll', () => {
308308
it('should get all the row heights w/ 30% width rows', () => {
309309
let firstTop = 13;
310310
nodes = [
311-
{cell: 0, tmpl: TEMPLATE_HEADER, view: getView(data.viewWidth, HEIGHT_HEADER, firstTop, 0)},
312-
{cell: 1, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 0)},
313-
{cell: 2, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 90)},
314-
{cell: 3, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 180)},
315-
{cell: 4, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM + firstTop, 0)},
316-
{cell: 5, tmpl: TEMPLATE_FOOTER, view: getView(data.viewWidth, HEIGHT_FOOTER, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM + firstTop, 0)},
311+
{ cell: 0, tmpl: TEMPLATE_HEADER, view: getView(data.viewWidth, HEIGHT_HEADER, firstTop, 0) },
312+
{ cell: 1, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 0) },
313+
{ cell: 2, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 90) },
314+
{ cell: 3, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + firstTop, 180) },
315+
{ cell: 4, tmpl: TEMPLATE_ITEM, view: getView(90, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM + firstTop, 0) },
316+
{ cell: 5, tmpl: TEMPLATE_FOOTER, view: getView(data.viewWidth, HEIGHT_FOOTER, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM + firstTop, 0) },
317317
];
318318

319319
cells = [
320-
{row: 0, tmpl: TEMPLATE_HEADER, reads: 0},
321-
{row: 0, tmpl: TEMPLATE_ITEM, reads: 0},
322-
{row: 0, tmpl: TEMPLATE_ITEM, reads: 0},
323-
{row: 0, tmpl: TEMPLATE_ITEM, reads: 0},
324-
{row: 0, tmpl: TEMPLATE_ITEM, reads: 0},
325-
{row: 0, tmpl: TEMPLATE_FOOTER, reads: 0},
320+
{ row: 0, tmpl: TEMPLATE_HEADER, reads: 0 },
321+
{ row: 0, tmpl: TEMPLATE_ITEM, reads: 0 },
322+
{ row: 0, tmpl: TEMPLATE_ITEM, reads: 0 },
323+
{ row: 0, tmpl: TEMPLATE_ITEM, reads: 0 },
324+
{ row: 0, tmpl: TEMPLATE_ITEM, reads: 0 },
325+
{ row: 0, tmpl: TEMPLATE_FOOTER, reads: 0 },
326326
];
327327

328328
initReadNodes(mockPlatform(), nodes, cells, data);
@@ -360,19 +360,19 @@ describe('VirtualScroll', () => {
360360

361361
it('should get all the row heights w/ all 100% width rows', () => {
362362
nodes = [
363-
{cell: 0, tmpl: TEMPLATE_HEADER, view: getView(data.viewWidth, HEIGHT_HEADER, 0, 0)},
364-
{cell: 1, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER, 0)},
365-
{cell: 2, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM, 0)},
366-
{cell: 3, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM, 0)},
367-
{cell: 4, tmpl: TEMPLATE_FOOTER, view: getView(data.viewWidth, HEIGHT_FOOTER, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM + HEIGHT_ITEM, 0)},
363+
{ cell: 0, tmpl: TEMPLATE_HEADER, view: getView(data.viewWidth, HEIGHT_HEADER, 0, 0) },
364+
{ cell: 1, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER, 0) },
365+
{ cell: 2, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM, 0) },
366+
{ cell: 3, tmpl: TEMPLATE_ITEM, view: getView(data.viewWidth, HEIGHT_ITEM, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM, 0) },
367+
{ cell: 4, tmpl: TEMPLATE_FOOTER, view: getView(data.viewWidth, HEIGHT_FOOTER, HEIGHT_HEADER + HEIGHT_ITEM + HEIGHT_ITEM + HEIGHT_ITEM, 0) },
368368
];
369369

370370
cells = [
371-
{row: 0, tmpl: TEMPLATE_HEADER, reads: 0},
372-
{row: 1, tmpl: TEMPLATE_ITEM, reads: 0},
373-
{row: 2, tmpl: TEMPLATE_ITEM, reads: 0},
374-
{row: 3, tmpl: TEMPLATE_ITEM, reads: 0},
375-
{row: 4, tmpl: TEMPLATE_FOOTER, reads: 0},
371+
{ row: 0, tmpl: TEMPLATE_HEADER, reads: 0 },
372+
{ row: 1, tmpl: TEMPLATE_ITEM, reads: 0 },
373+
{ row: 2, tmpl: TEMPLATE_ITEM, reads: 0 },
374+
{ row: 3, tmpl: TEMPLATE_ITEM, reads: 0 },
375+
{ row: 4, tmpl: TEMPLATE_FOOTER, reads: 0 },
376376
];
377377

378378
initReadNodes(mockPlatform(), nodes, cells, data);
@@ -400,7 +400,7 @@ describe('VirtualScroll', () => {
400400

401401
it('should adjust when all the way to the top, scrolling down', () => {
402402
for (var i = 0; i < 100; i++) {
403-
cells.push({top: i, height: 1, row: i});
403+
cells.push({ top: i, height: 1, row: i });
404404
}
405405
data.scrollDiff = 1;
406406
data.viewHeight = 20;
@@ -418,7 +418,7 @@ describe('VirtualScroll', () => {
418418

419419
it('should adjust when in the middle, scrolling down', () => {
420420
for (var i = 0; i < 100; i++) {
421-
cells.push({top: i, height: 1, row: i});
421+
cells.push({ top: i, height: 1, row: i });
422422
}
423423
data.scrollDiff = 1;
424424
data.viewHeight = 20;
@@ -436,7 +436,7 @@ describe('VirtualScroll', () => {
436436

437437
it('should adjust when all the way to the bottom, scrolling down', () => {
438438
for (var i = 0; i < 100; i++) {
439-
cells.push({top: i, height: 1, row: i});
439+
cells.push({ top: i, height: 1, row: i });
440440
}
441441
data.scrollDiff = 1;
442442
data.viewHeight = 20;
@@ -454,7 +454,7 @@ describe('VirtualScroll', () => {
454454

455455
it('should adjust when all the way to the bottom, scrolling up', () => {
456456
for (var i = 0; i < 100; i++) {
457-
cells.push({top: i, height: 1, row: i});
457+
cells.push({ top: i, height: 1, row: i });
458458
}
459459
data.scrollDiff = -1;
460460
data.viewHeight = 20;
@@ -546,10 +546,10 @@ describe('VirtualScroll', () => {
546546
let hdrTmp: any = {};
547547
let ftrTmp: any = {};
548548
let viewContainer: any = {
549-
createEmbeddedView: function() {
549+
createEmbeddedView: function () {
550550
return getView();
551551
},
552-
indexOf: function() {
552+
indexOf: function () {
553553
return 0;
554554
}
555555
};
@@ -570,10 +570,10 @@ describe('VirtualScroll', () => {
570570
left: ''
571571
},
572572
classList: {
573-
add: function(){},
574-
remove: function(){}
573+
add: function () { },
574+
remove: function () { }
575575
},
576-
setAttribute: function(){},
576+
setAttribute: function () { },
577577
innerHTML: '',
578578
}]
579579
};

0 commit comments

Comments
 (0)