jxdnsong
2020-10-23 a7929e6b3ec9ac17233f39e55a2b8ac63ea75f42
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
define([
    'intern!tdd',
    'intern/chai!assert',
    'dojo/_base/declare',
    'dgrid/Grid',
    'dgrid/extensions/SingleQuery',
    'dgrid/test/data/createSyncStore',
    'dgrid/test/data/genericData',
    'dojo/domReady!'
], function (test, assert, declare, Grid, SingleQuery, createSyncStore, genericData) {
    var grid;
    var SingleQueryGrid = declare([ Grid, SingleQuery ]);
 
    function getColumns() {
        return {
            id: 'id',
            col1: 'Column 1'
        };
    }
 
    test.suite('SingleQuery', function () {
        var store = createSyncStore({ data: genericData });
        var numItems = store.storage.fullData.length;
 
        test.beforeEach(function () {
            grid = new SingleQueryGrid({
                collection: store,
                columns: getColumns()
            });
            document.body.appendChild(grid.domNode);
            grid.startup();
        });
 
        test.afterEach(function () {
            grid.destroy();
        });
 
        test.test('Should render all results at once', function () {
            assert.strictEqual(grid.contentNode.children.length, numItems,
                'A grid row should exist for every item in the collection');
        });
 
        test.test('Should expose total via get(\'total\')', function () {
            assert.strictEqual(grid.get('total'), numItems,
                'grid.get(\'total\') should return total number of items');
        });
    });
});