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
define([
    'intern!tdd',
    'intern/chai!assert',
    'dgrid/List',
    'dgrid/Grid',
    'dgrid/GridFromHtml',
    'dojo/_base/array',
    'dojo/parser',
    'dojo/dom-class',
    'dojo/dom-construct',
    'dojo/text!../resources/setClass.html'
], function (test, assert, List, Grid, GridFromHtml, arrayUtil, parser, domClass, domConstruct, gridTemplate) {
 
    test.suite('setClass', function () {
        // Tests
        test.test('Lists + initially-defined classes', function () {
            function renderRow(item) {
                var div = document.createElement('div');
                div.appendChild(document.createTextNode(item.name));
                return div;
            }
            // Build three lists
            var listC = window.listC = new List({
                    'class': 'c',
                    renderRow: renderRow
                }),
                listCN = window.listCN = new List({
                    className: 'cn',
                    renderRow: renderRow
                }),
                listDOM = window.listDOM = new List({
                    renderRow: renderRow
                }, domConstruct.create('div', {'class': 'dom'}));
 
            // Check the classes on each List.domNode
            assert.ok(domClass.contains(listC.domNode, 'c'));
            assert.ok(domClass.contains(listCN.domNode, 'cn'));
            assert.ok(domClass.contains(listDOM.domNode, 'dom'));
 
            // Destroy the lists after performing the tests
            listC.destroy();
            listCN.destroy();
            listDOM.destroy();
        });
 
        test.test('Grids + initially-defined classes', function () {
            // Build three grids
            var columns = {
                    order: 'step', // give column a custom name
                    name: {},
                    description: { label: 'what to do', sortable: false }
                },
                gridC = window.gridC = new Grid({
                    'class': 'c',
                    columns: columns
                }),
                gridCN = window.gridCN = new Grid({
                    'class': 'cn',
                    columns: columns
                }),
                gridDOM = window.gridDOM = new Grid({
                    columns: columns
                }, domConstruct.create('div', { 'class': 'dom' }));
 
            // Check the classes on each List.domNode
            assert.ok(domClass.contains(gridC.domNode, 'c'));
            assert.ok(domClass.contains(gridCN.domNode, 'cn'));
            assert.ok(domClass.contains(gridDOM.domNode, 'dom'));
 
            // Destroy the grids after performing the tests
            gridC.destroy();
            gridCN.destroy();
            gridDOM.destroy();
        });
 
        test.test('Declarative Grid + initially-defined class', function () {
            /* global gridDecl */
 
            // Create markup for a grid to be declaratively parsed
            var node = domConstruct.create('div', {
                innerHTML: gridTemplate
            });
 
            // Expose GridFromHtml via a global namespace for parser to use
            window.dgrid = { GridFromHtml: GridFromHtml };
            parser.parse(node);
 
            // Make sure the expected class exists on the parsed instance
            assert.ok(domClass.contains(gridDecl.domNode, 'dom'));
 
            // Destroy the grid after performing the test
            gridDecl.destroy();
        });
    });
});