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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
define([
    'intern!tdd',
    'intern/chai!assert',
    'dojo/_base/declare',
    'dojo/query',
    'dstore/Memory',
    'dstore/Trackable',
    'dgrid/Grid',
    'dgrid/OnDemandGrid',
    'dgrid/extensions/Pagination',
    'dgrid/extensions/SingleQuery'
], function (test, assert, declare, query, Memory, Trackable, Grid, OnDemandGrid, Pagination, SingleQuery) {
 
    var grid;
 
    var PaginationGrid = declare([Grid, Pagination]);
    var SingleQueryGrid = declare([OnDemandGrid, SingleQuery]);
    var PaginationSingleQueryGrid = declare([Grid, Pagination, SingleQuery]);
    var TrackableStore = declare([Memory, Trackable]);
 
    function createGrid(Grid, options) {
        grid = new Grid(options);
        document.body.appendChild(grid.domNode);
        grid.startup();
    }
 
    function testNoDataNodeExists(exists) {
        assert.strictEqual(query('.dgrid-no-data', grid.domNode).length, exists ? 1 : 0);
    }
 
    test.suite('_insertNoDataNode', function () {
 
        test.afterEach(function () {
            if (grid) {
                grid.destroy();
                grid = undefined;
            }
        });
 
        test.suite('Pagination', function () {
 
            test.test('empty store with refresh', function () {
                createGrid(PaginationGrid, {
                    collection: new TrackableStore({}),
                    noDataMessage: 'No data'
                });
                testNoDataNodeExists(true);
                grid.refresh();
                testNoDataNodeExists(true);
            });
        });
 
        test.suite('SingleQuery', function () {
            test.test('empty store with refresh', function () {
                createGrid(SingleQueryGrid, {
                    collection: new TrackableStore({}),
                    noDataMessage: 'No data'
                });
                testNoDataNodeExists(true);
                grid.refresh();
                testNoDataNodeExists(true);
            });
 
            test.test('empty store add and remove', function () {
                var store = new TrackableStore();
                createGrid(SingleQueryGrid, {
                    collection: store,
                    columns: {
                        id: 'ID',
                        name: 'Name'
                    },
                    noDataMessage: 'No data'
                });
                testNoDataNodeExists(true);
                store.add({
                    id: 1,
                    name: 'Fred'
                });
                testNoDataNodeExists(false);
                store.remove(1);
                testNoDataNodeExists(true);
            });
        });
 
        test.suite('PaginationSingleQuery', function () {
 
            test.test('empty store with refresh', function () {
                createGrid(PaginationSingleQueryGrid, {
                    collection: new TrackableStore({}),
                    noDataMessage: 'No data'
                });
                testNoDataNodeExists(true);
                grid.refresh();
                testNoDataNodeExists(true);
            });
        });
    });
});