nnnjjj123
2020-11-17 1b2c1edb61190eeb19f465ff031eaa3b2a1b8dbc
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
define([
    'intern!tdd',
    'intern/chai!assert',
    'dojo/query',
    'dgrid/OnDemandList',
    'dgrid/test/data/createSyncStore',
    'dgrid/test/data/genericData'
], function (test, assert, query, OnDemandList, createSyncStore, genericData) {
    test.suite('OnDemandList with zero rowHeight', function () {
        var list;
        var store = createSyncStore({ data: genericData });
 
        test.beforeEach(function () {
            list = new OnDemandList({
                collection: store,
                renderRow: function () {
                    return document.createElement('div');
                }
            });
            document.body.appendChild(list.domNode);
            list.startup();
        });
 
        test.afterEach(function () {
            list.destroy();
        });
 
        test.test('_processScroll should bail out if rowHeight is 0', function () {
            // Bailing out with rowHeight === 0 is important because otherwise
            // _processScroll has the potential to loop infinitely.
 
            // _processScroll will call _trackError if it doesn't bail out and
            // thinks it should render more items, so replace it to fail the test
            list._trackError = function () {
                throw new assert.AssertionError({
                    message: '_processScroll with 0 rowHeight should not result in any query'
                });
            };
 
            list._processScroll();
        });
 
        test.test('refresh with zero rowHeight should only render minRowsPerPage rows', function () {
            // This tests GitHub issue #965.
            assert.strictEqual(query('.dgrid-row', list.contentNode).length, list.minRowsPerPage);
        });
    });
 
    test.suite('OnDemandList', function () {
        var list;
        var store = createSyncStore({ data: genericData });
 
        test.beforeEach(function () {
            list = new OnDemandList({
                collection: store,
                renderRow: function () {
                    var node = document.createElement('div');
                    node.innerHTML = 'Test';
                    node.style.height = '16px';
                    return node;
                }
            });
            document.body.appendChild(list.domNode);
            list.startup();
        });
 
        test.afterEach(function () {
            list.destroy();
        });
 
        test.test('calculated row height', function () {
            assert.strictEqual(16, list.preload.rowHeight);
        });
    });
});