Add datatables-1.9.4 and jquery-1.10.2 libraries
[proteocache.git] / webapp / resources / datatables-1.9.4 / media / unit_testing / tests_onhold / 1_dom / fnSetColumnVis2.js
1 // DATA_TEMPLATE: complex_header_2
2 oTest.fnStart( "fnSetColumnVis with complex headers" );
3
4 $(document).ready( function () {
5         /* Check the default */
6         var oTable = $('#example').dataTable();
7         var oSettings = oTable.fnSettings();
8         
9         oTest.fnTest( 
10                 "All columns are visible by default",
11                 null,
12                 function () { return $('#example tbody tr:eq(0) td').length == 5; }
13         );
14         
15         oTest.fnTest( 
16                 "Hide the first column",
17                 function () {
18                         $('#example').dataTable().fnSetColumnVis( 0, false );
19                 },
20                 function () { return $('#example tbody tr:eq(0) td').length == 4; }
21         );
22         
23         oTest.fnTest(
24                 "First cell is '2' - first column hidden",
25                 null,
26                 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "2"; }
27         );
28         
29         oTest.fnTest(
30                 "First cell has colspan of 3",
31                 null,
32                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 3; }
33         );
34         
35         oTest.fnTest(
36                 "First cell has rowspan of 2",
37                 null,
38                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 2; }
39         );
40         
41         oTest.fnTest(
42                 "First cell in last column is '11'",
43                 null,
44                 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 11; }
45         );
46         
47         oTest.fnTest(
48                 "First cell in last column has been truncated to one column",
49                 null,
50                 function () { return $('#example thead tr:eq(4) th:eq(0)')[0].getAttribute('colspan') == 1; }
51         );
52         
53         
54         oTest.fnTest( 
55                 "Hide the second column",
56                 function () {
57                         $('#example').dataTable().fnSetColumnVis( 0, true );
58                         $('#example').dataTable().fnSetColumnVis( 1, false );
59                 },
60                 function () { return $('#example tbody tr:eq(0) td').length == 4; }
61         );
62         
63         oTest.fnTest(
64                 "First cell is '1' - second column hidden",
65                 null,
66                 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "1"; }
67         );
68         
69         oTest.fnTest(
70                 "Second cell is '2' - second column hidden",
71                 null,
72                 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "2"; }
73         );
74         
75         oTest.fnTest(
76                 "First cell in fourth row is '10' (visibly the first) - second column hidden",
77                 null,
78                 function () { return $('#example thead tr:eq(3) th:eq(0)').html() == "10"; }
79         );
80         
81         oTest.fnTest(
82                 "First cell has colspan of 1",
83                 null,
84                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 1; }
85         );
86         
87         oTest.fnTest(
88                 "Second cell has colspan of 2",
89                 null,
90                 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('colspan') == 2; }
91         );
92         
93         oTest.fnTest(
94                 "First cell has rowspan of 1",
95                 null,
96                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 1; }
97         );
98         
99         oTest.fnTest(
100                 "Second cell has rowspan of 2",
101                 null,
102                 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 2; }
103         );
104         
105         oTest.fnTest(
106                 "First cell in last column is '11'",
107                 null,
108                 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 11; }
109         );
110         
111         oTest.fnTest(
112                 "First cell in last column has been truncated to one column",
113                 null,
114                 function () { return $('#example thead tr:eq(4) th:eq(0)')[0].getAttribute('colspan') == 1; }
115         );
116         
117         
118         oTest.fnTest( 
119                 "Hide the first two columns",
120                 function () {
121                         $('#example').dataTable().fnSetColumnVis( 0, false );
122                         $('#example').dataTable().fnSetColumnVis( 1, false );
123                 },
124                 function () { return $('#example tbody tr:eq(0) td').length == 3; }
125         );
126         
127         oTest.fnTest(
128                 "First cell is '2' - first two columns hidden",
129                 null,
130                 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "2"; }
131         );
132         
133         oTest.fnTest(
134                 "Second cell is '3' - first two columns hidden",
135                 null,
136                 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "3"; }
137         );
138         
139         oTest.fnTest(
140                 "First cell in third row is '6' - first two columns hidden",
141                 null,
142                 function () { return $('#example thead tr:eq(2) th:eq(0)').html() == "6"; }
143         );
144         
145         oTest.fnTest(
146                 "First cell has colspan of 2",
147                 null,
148                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('colspan') == 2; }
149         );
150         
151         oTest.fnTest(
152                 "First cell has rowspan of 2",
153                 null,
154                 function () { return $('#example thead tr:eq(0) th:eq(0)')[0].getAttribute('rowspan') == 2; }
155         );
156         
157         oTest.fnTest(
158                 "Second cell has rowspan of 1",
159                 null,
160                 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 1; }
161         );
162         
163         oTest.fnTest(
164                 "First cell in last column is '12'",
165                 null,
166                 function () { return $('#example thead tr:eq(4) th:eq(0)').html() == 12; }
167         );
168         
169         
170         oTest.fnTest( 
171                 "Hide the third column",
172                 function () {
173                         $('#example').dataTable().fnSetColumnVis( 0, true );
174                         $('#example').dataTable().fnSetColumnVis( 1, true );
175                         $('#example').dataTable().fnSetColumnVis( 2, false );
176                 },
177                 function () { return $('#example tbody tr:eq(0) td').length == 4; }
178         );
179         
180         oTest.fnTest(
181                 "First cell is '1' - third column hidden",
182                 null,
183                 function () { return $('#example thead tr:eq(0) th:eq(0)').html() == "1"; }
184         );
185         
186         oTest.fnTest(
187                 "Second cell is '2' - third column hidden",
188                 null,
189                 function () { return $('#example thead tr:eq(0) th:eq(1)').html() == "2"; }
190         );
191         
192         oTest.fnTest(
193                 "First cell (visible second) in third row is '6' - third column hidden",
194                 null,
195                 function () { return $('#example thead tr:eq(2) th:eq(0)').html() == "6"; }
196         );
197         
198         oTest.fnTest(
199                 "Second cell has colspan of 2",
200                 null,
201                 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('colspan') == 2; }
202         );
203         
204         oTest.fnTest(
205                 "Second cell has rowspan of 2",
206                 null,
207                 function () { return $('#example thead tr:eq(0) th:eq(1)')[0].getAttribute('rowspan') == 2; }
208         );
209         
210         oTest.fnTest(
211                 "Third row first cell (second visible) colspan is 1",
212                 null,
213                 function () { return $('#example thead tr:eq(2) th:eq(0)')[0].getAttribute('colspan') == 1; }
214         );
215         
216         oTest.fnTest(
217                 "Third row second cell (third visible) value is 7",
218                 null,
219                 function () { return $('#example thead tr:eq(2) th:eq(1)').html() == "7"; }
220         );
221         
222         oTest.fnTest(
223                 "Third row second cell (third visible) colspan is 1",
224                 null,
225                 function () { return $('#example thead tr:eq(2) th:eq(1)')[0].getAttribute('colspan') == 1; }
226         );
227         
228         oTest.fnTest(
229                 "Third row second cell (third visible) rowspan is 3",
230                 null,
231                 function () { return $('#example thead tr:eq(2) th:eq(1)')[0].getAttribute('rowspan') == 3; }
232         );
233         
234         
235         oTest.fnComplete();
236 } );